2023-03-02 12:11:39 +00:00
|
|
|
name: Release
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
tags:
|
|
|
|
- v[0-9]+.[0-9]+.[0-9]+*
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
release:
|
2023-07-10 03:17:42 +00:00
|
|
|
name: Publish to GitHub Release
|
2023-03-02 12:11:39 +00:00
|
|
|
permissions:
|
|
|
|
contents: write
|
|
|
|
outputs:
|
|
|
|
rc: ${{ steps.check-tag.outputs.rc }}
|
|
|
|
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
include:
|
|
|
|
- target: aarch64-unknown-linux-musl
|
|
|
|
os: ubuntu-latest
|
|
|
|
use-cross: true
|
|
|
|
cargo-flags: ""
|
|
|
|
- target: aarch64-apple-darwin
|
|
|
|
os: macos-latest
|
|
|
|
use-cross: true
|
|
|
|
cargo-flags: ""
|
2023-10-27 06:26:46 +00:00
|
|
|
- target: aarch64-pc-windows-msvc
|
|
|
|
os: windows-latest
|
|
|
|
use-cross: true
|
|
|
|
cargo-flags: ""
|
2023-03-02 12:11:39 +00:00
|
|
|
- target: x86_64-apple-darwin
|
|
|
|
os: macos-latest
|
|
|
|
cargo-flags: ""
|
|
|
|
- target: x86_64-pc-windows-msvc
|
|
|
|
os: windows-latest
|
|
|
|
cargo-flags: ""
|
|
|
|
- target: x86_64-unknown-linux-musl
|
|
|
|
os: ubuntu-latest
|
|
|
|
use-cross: true
|
|
|
|
cargo-flags: ""
|
|
|
|
- target: i686-unknown-linux-musl
|
|
|
|
os: ubuntu-latest
|
|
|
|
use-cross: true
|
|
|
|
cargo-flags: ""
|
|
|
|
- target: i686-pc-windows-msvc
|
|
|
|
os: windows-latest
|
|
|
|
use-cross: true
|
|
|
|
cargo-flags: ""
|
2024-04-07 14:02:05 +00:00
|
|
|
- target: armv7-unknown-linux-musleabihf
|
|
|
|
os: ubuntu-latest
|
|
|
|
use-cross: true
|
|
|
|
cargo-flags: ""
|
|
|
|
- target: arm-unknown-linux-musleabihf
|
|
|
|
os: ubuntu-latest
|
|
|
|
use-cross: true
|
|
|
|
cargo-flags: ""
|
2023-03-02 12:11:39 +00:00
|
|
|
|
|
|
|
runs-on: ${{matrix.os}}
|
2023-07-10 03:33:38 +00:00
|
|
|
env:
|
|
|
|
BUILD_CMD: cargo
|
2023-03-02 12:11:39 +00:00
|
|
|
|
|
|
|
steps:
|
2024-04-04 08:04:16 +00:00
|
|
|
- uses: actions/checkout@v4
|
2023-03-02 12:11:39 +00:00
|
|
|
|
|
|
|
- name: Check Tag
|
|
|
|
id: check-tag
|
|
|
|
shell: bash
|
|
|
|
run: |
|
2023-07-10 03:33:38 +00:00
|
|
|
ver=${GITHUB_REF##*/}
|
|
|
|
echo "version=$ver" >> $GITHUB_OUTPUT
|
|
|
|
if [[ "$ver" =~ [0-9]+.[0-9]+.[0-9]+$ ]]; then
|
|
|
|
echo "rc=false" >> $GITHUB_OUTPUT
|
2023-03-02 12:11:39 +00:00
|
|
|
else
|
2023-07-10 03:33:38 +00:00
|
|
|
echo "rc=true" >> $GITHUB_OUTPUT
|
2023-03-02 12:11:39 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
- name: Install Rust Toolchain Components
|
2023-07-10 03:33:38 +00:00
|
|
|
uses: dtolnay/rust-toolchain@stable
|
2023-03-02 12:11:39 +00:00
|
|
|
with:
|
2023-07-10 03:33:38 +00:00
|
|
|
targets: ${{ matrix.target }}
|
|
|
|
|
|
|
|
- name: Install cross
|
|
|
|
if: matrix.use-cross
|
|
|
|
uses: taiki-e/install-action@v2
|
|
|
|
with:
|
|
|
|
tool: cross
|
|
|
|
|
|
|
|
- name: Overwrite build command env variable
|
|
|
|
if: matrix.use-cross
|
|
|
|
shell: bash
|
|
|
|
run: echo "BUILD_CMD=cross" >> $GITHUB_ENV
|
2023-03-02 12:11:39 +00:00
|
|
|
|
|
|
|
- name: Show Version Information (Rust, cargo, GCC)
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
gcc --version || true
|
|
|
|
rustup -V
|
|
|
|
rustup toolchain list
|
|
|
|
rustup default
|
|
|
|
cargo -V
|
|
|
|
rustc -V
|
|
|
|
|
|
|
|
- name: Build
|
2023-07-10 03:33:38 +00:00
|
|
|
shell: bash
|
|
|
|
run: $BUILD_CMD build --locked --release --target=${{ matrix.target }} ${{ matrix.cargo-flags }}
|
2023-03-02 12:11:39 +00:00
|
|
|
|
|
|
|
- name: Build Archive
|
|
|
|
shell: bash
|
|
|
|
id: package
|
|
|
|
env:
|
|
|
|
target: ${{ matrix.target }}
|
|
|
|
version: ${{ steps.check-tag.outputs.version }}
|
|
|
|
run: |
|
|
|
|
set -euxo pipefail
|
|
|
|
|
|
|
|
bin=${GITHUB_REPOSITORY##*/}
|
2023-07-15 08:14:30 +00:00
|
|
|
dist_dir=`pwd`/dist
|
2023-03-02 12:11:39 +00:00
|
|
|
name=$bin-$version-$target
|
|
|
|
executable=target/$target/release/$bin
|
|
|
|
|
|
|
|
if [[ "$RUNNER_OS" == "Windows" ]]; then
|
|
|
|
executable=$executable.exe
|
|
|
|
fi
|
|
|
|
|
2023-07-15 08:14:30 +00:00
|
|
|
mkdir $dist_dir
|
|
|
|
cp $executable $dist_dir
|
|
|
|
cd $dist_dir
|
2023-03-02 12:11:39 +00:00
|
|
|
|
|
|
|
if [[ "$RUNNER_OS" == "Windows" ]]; then
|
2023-07-15 08:14:30 +00:00
|
|
|
archive=$dist_dir/$name.zip
|
2023-03-02 12:11:39 +00:00
|
|
|
7z a $archive *
|
2023-07-15 08:14:30 +00:00
|
|
|
echo "archive=dist/$name.zip" >> $GITHUB_OUTPUT
|
2023-03-02 12:11:39 +00:00
|
|
|
else
|
2023-07-15 08:14:30 +00:00
|
|
|
archive=$dist_dir/$name.tar.gz
|
|
|
|
tar -czf $archive *
|
|
|
|
echo "archive=dist/$name.tar.gz" >> $GITHUB_OUTPUT
|
2023-03-02 12:11:39 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
- name: Publish Archive
|
2024-04-04 08:04:16 +00:00
|
|
|
uses: softprops/action-gh-release@v2
|
2023-03-02 12:11:39 +00:00
|
|
|
if: ${{ startsWith(github.ref, 'refs/tags/') }}
|
|
|
|
with:
|
|
|
|
draft: false
|
|
|
|
files: ${{ steps.package.outputs.archive }}
|
|
|
|
prerelease: ${{ steps.check-tag.outputs.rc == 'true' }}
|
|
|
|
|
|
|
|
publish-crate:
|
|
|
|
name: Publish to crates.io
|
|
|
|
if: ${{ needs.release.outputs.rc == 'false' }}
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: release
|
|
|
|
steps:
|
2024-04-04 08:04:16 +00:00
|
|
|
- uses: actions/checkout@v4
|
2023-03-02 12:11:39 +00:00
|
|
|
|
2023-07-10 03:33:38 +00:00
|
|
|
- uses: dtolnay/rust-toolchain@stable
|
|
|
|
|
|
|
|
- name: Publish
|
2023-03-02 12:11:39 +00:00
|
|
|
env:
|
|
|
|
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_API_TOKEN }}
|
|
|
|
run: cargo publish
|