Skip to content

polish release workflow #2

polish release workflow

polish release workflow #2

Workflow file for this run

name: Release
on:
push:
tags: ["v*"]
permissions:
contents: write
jobs:
build:
name: Build ${{ matrix.target }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
suffix: ""
- os: macos-latest
target: x86_64-apple-darwin
suffix: ""
- os: macos-latest
target: aarch64-apple-darwin
suffix: ""
- os: windows-latest
target: x86_64-pc-windows-msvc
suffix: ".exe"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
- run: cargo build --release --target ${{ matrix.target }}
- name: Stage binary with unique name
shell: bash
run: |
mkdir -p artifacts
cp "target/${{ matrix.target }}/release/gitnibble${{ matrix.suffix }}" \
"artifacts/gitnibble-${{ matrix.target }}${{ matrix.suffix }}"
- uses: actions/upload-artifact@v4
with:
name: gitnibble-${{ matrix.target }}
path: artifacts/gitnibble-${{ matrix.target }}${{ matrix.suffix }}
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
pattern: gitnibble-*
path: dist
merge-multiple: true
- name: Make unix binaries executable
run: |
chmod +x dist/gitnibble-x86_64-unknown-linux-gnu
chmod +x dist/gitnibble-x86_64-apple-darwin
chmod +x dist/gitnibble-aarch64-apple-darwin
- name: Create GitHub release
run: |
gh release create "${{ github.ref_name }}" \
--title "${{ github.ref_name }}" \
--generate-notes \
dist/gitnibble-x86_64-unknown-linux-gnu \
dist/gitnibble-x86_64-apple-darwin \
dist/gitnibble-aarch64-apple-darwin \
dist/gitnibble-x86_64-pc-windows-msvc.exe
env:
GH_TOKEN: ${{ github.token }}