release #13
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: | |
release: | |
types: [published] | |
workflow_dispatch: | |
permissions: | |
contents: write | |
jobs: | |
rust-release: | |
strategy: | |
matrix: | |
# prettier-ignore | |
cfg: | |
- { os: macos-latest , target: x86_64-apple-darwin , cross: false } | |
- { os: macos-latest , target: aarch64-apple-darwin , cross: true } | |
- { os: ubuntu-latest , target: x86_64-unknown-linux-musl , cross: false } | |
- { os: ubuntu-latest , target: aarch64-unknown-linux-musl , cross: true } | |
- { os: windows-latest , target: x86_64-pc-windows-msvc , cross: false } | |
- { os: windows-latest , target: aarch64-pc-windows-msvc , cross: true } | |
runs-on: ${{ matrix.cfg.os }} | |
env: | |
CARGO: cargo | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Rust toolchain | |
uses: dtolnay/rust-toolchain@v1 | |
with: | |
toolchain: "1.70" | |
targets: ${{ matrix.cfg.target }} | |
- name: Cache cargo | |
uses: Swatinem/rust-cache@v2 | |
- name: Use cross | |
if: matrix.cfg.cross | |
run: | | |
cargo install cross | |
echo "CARGO=cross" >> $GITHUB_ENV | |
- name: Build release binary | |
run: | | |
${{ env.CARGO }} build --verbose --release --target=${{ matrix.cfg.target }} | |
- name: Pack assets (*nix) | |
if: matrix.cfg.os != 'windows-latest' | |
shell: bash | |
run: | | |
asset=nerdfix-${{ matrix.cfg.target }}.tar.gz | |
cp target/${{ matrix.cfg.target }}/release/nerdfix nerdfix | |
strip nerdfix | |
tar -czvf nerdfix-${{ matrix.cfg.target }}.tar.gz nerdfix | |
echo "ASSET=$asset" >> $GITHUB_ENV | |
- name: Pack assets (Windows) | |
if: matrix.cfg.os == 'windows-latest' | |
shell: bash | |
run: | | |
asset=nerdfix-${{ matrix.cfg.target }}.zip | |
cp target/${{ matrix.cfg.target }}/release/nerdfix.exe nerdfix.exe | |
7z a $asset nerdfix.exe | |
echo "ASSET=$asset" >> $GITHUB_ENV | |
- name: Upload release asset | |
uses: softprops/action-gh-release@v1 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
files: ${{ env.ASSET }} |