Update cd.yml #20
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
push: | |
tags: | |
- "v*.*.*" | |
jobs: | |
build-release: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
# Linux | |
- os: ubuntu-latest | |
target: x86_64-unknown-linux-musl | |
archive: tar.gz | |
archive-cmd: tar czf | |
sha-cmd: sha256sum | |
- os: ubuntu-latest | |
target: aarch64-unknown-linux-musl | |
archive: tar.gz | |
archive-cmd: tar czf | |
sha-cmd: sha256sum | |
- os: ubuntu-latest | |
target: arm-unknown-linux-musleabihf | |
archive: tar.gz | |
archive-cmd: tar czf | |
sha-cmd: sha256sum | |
- os: ubuntu-latest | |
target: loongarch64-unknown-linux-gnu | |
archive: tar.gz | |
archive-cmd: tar czf | |
sha-cmd: sha256sum | |
# MacOS | |
- os: macos-latest | |
target: x86_64-apple-darwin | |
archive: zip | |
archive-cmd: zip -r | |
sha-cmd: shasum -a 256 | |
- os: macos-latest | |
target: aarch64-apple-darwin | |
archive: zip | |
archive-cmd: zip -r | |
sha-cmd: shasum -a 256 | |
# Windows | |
- os: windows-latest | |
target: x86_64-pc-windows-msvc | |
archive: zip | |
archive-cmd: 7z a | |
sha-cmd: sha256sum | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
- name: Installing Rust toolchain | |
uses: dtolnay/rust-toolchain@master | |
with: | |
target: ${{ matrix.target }} | |
toolchain: stable | |
- uses: Swatinem/rust-cache@v2 | |
- name: Build for Linux | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
cargo install --force --locked bindgen-cli | |
cargo install cross --git https://github.com/cross-rs/cross | |
cross build --release --target ${{ matrix.target }} | |
- name: Build for Darwin and Windows | |
if: matrix.os == 'macos-latest' || matrix.os == 'windows-latest' | |
run: cargo build --release --target ${{ matrix.target }} | |
- name: Packaging final binaries | |
shell: bash | |
run: | | |
src=$(pwd) | |
stage=$(mktemp -d) | |
ver=${GITHUB_REF#refs/tags/} | |
asset_name="tuistash-$ver-${{ matrix.target }}.${{ matrix.archive }}" | |
ASSET_PATH="$src/$asset_name" | |
CHECKSUM_PATH="$ASSET_PATH.sha256" | |
cp target/${{ matrix.target }}/release/tuistash $stage/ | |
cd $stage | |
${{ matrix.archive-cmd }} $ASSET_PATH * | |
cd $src | |
${{ matrix.sha-cmd }} $asset_name > $CHECKSUM_PATH | |
if [ "$RUNNER_OS" == "Windows" ]; then | |
echo "ASSET_PATH=$(cygpath -m $ASSET_PATH)" >> $GITHUB_ENV | |
echo "CHECKSUM_PATH=$(cygpath -m $CHECKSUM_PATH)" >> $GITHUB_ENV | |
else | |
echo "ASSET_PATH=$ASSET_PATH" >> $GITHUB_ENV | |
echo "CHECKSUM_PATH=$CHECKSUM_PATH" >> $GITHUB_ENV | |
fi | |
- name: Releasing assets | |
uses: softprops/action-gh-release@v1 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
fail_on_unmatched_files: true | |
files: | | |
${{ env.ASSET_PATH }} | |
${{ env.CHECKSUM_PATH }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |