release: 0.2.4 #12
This file contains hidden or 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: Build & Release | |
| on: | |
| push: | |
| branches: [master] | |
| pull_request: | |
| branches: [master] | |
| permissions: | |
| contents: read | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # ---- GNU targets ---- | |
| - target: x86_64-unknown-linux-gnu | |
| - target: i686-unknown-linux-gnu | |
| - target: aarch64-unknown-linux-gnu | |
| - target: arm-unknown-linux-gnueabihf | |
| - target: armv7-unknown-linux-gnueabihf | |
| - target: riscv64gc-unknown-linux-gnu | |
| - target: powerpc64le-unknown-linux-gnu | |
| - target: s390x-unknown-linux-gnu | |
| - target: loongarch64-unknown-linux-gnu | |
| # ---- musl targets (static binaries) ---- | |
| - target: x86_64-unknown-linux-musl | |
| musl: true | |
| - target: i686-unknown-linux-musl | |
| musl: true | |
| - target: aarch64-unknown-linux-musl | |
| musl: true | |
| - target: arm-unknown-linux-musleabihf | |
| musl: true | |
| - target: armv7-unknown-linux-musleabihf | |
| musl: true | |
| - target: riscv64gc-unknown-linux-musl | |
| musl: true | |
| - target: powerpc64le-unknown-linux-musl | |
| musl: true | |
| - target: loongarch64-unknown-linux-musl | |
| musl: true | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Install Rust nightly with rust-src | |
| uses: dtolnay/rust-toolchain@nightly | |
| with: | |
| components: rust-src | |
| - name: Install Zig | |
| uses: mlugg/setup-zig@v2 | |
| - name: Install cargo-zigbuild | |
| run: pip install cargo-zigbuild | |
| - name: Build | |
| run: | | |
| RUSTFLAGS="-Zunstable-options -Cpanic=immediate-abort" | |
| if [ "${{ matrix.musl }}" = "true" ]; then | |
| RUSTFLAGS="$RUSTFLAGS -Clink-self-contained=no" | |
| fi | |
| export RUSTFLAGS | |
| cargo +nightly zigbuild \ | |
| -Z build-std=std,panic_abort \ | |
| --target ${{ matrix.target }} \ | |
| --release | |
| - name: Package binary | |
| run: | | |
| src="target/${{ matrix.target }}/release/hid-rgb-ctl" | |
| dst="hid-rgb-ctl-${{ matrix.target }}" | |
| cp "$src" "$dst" | |
| chmod +x "$dst" | |
| ls -lh "$dst" | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: hid-rgb-ctl-${{ matrix.target }} | |
| path: hid-rgb-ctl-${{ matrix.target }} | |
| release: | |
| if: github.ref == 'refs/heads/master' && startsWith(github.event.head_commit.message, 'release:') | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Extract version | |
| id: version | |
| run: | | |
| VERSION="$(echo '${{ github.event.head_commit.message }}' | head -1 | sed 's/^release:[[:space:]]*//')" | |
| if ! echo "$VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+'; then | |
| echo "::error::Invalid version '$VERSION' — expected semver (e.g. 0.3.0)" | |
| exit 1 | |
| fi | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| echo "tag=v$VERSION" >> "$GITHUB_OUTPUT" | |
| - name: Create or update tag | |
| run: | | |
| TAG="${{ steps.version.outputs.tag }}" | |
| git tag -f "$TAG" | |
| git push origin "$TAG" --force | |
| - name: Delete existing release (if any) | |
| run: | | |
| TAG="${{ steps.version.outputs.tag }}" | |
| gh release delete "$TAG" --yes 2>/dev/null || true | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v8 | |
| with: | |
| path: artifacts | |
| merge-multiple: true | |
| - name: List artifacts | |
| run: ls -lh artifacts/ | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.version.outputs.tag }} | |
| name: ${{ steps.version.outputs.tag }} | |
| files: artifacts/* | |
| generate_release_notes: true |