chore(deps): update actions/checkout action to v6 #2
Workflow file for this run
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] | |
| tags: ["v*"] | |
| 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 | |
| zig_target: x86_64-linux-gnu | |
| - target: i686-unknown-linux-gnu | |
| zig_target: x86-linux-gnu | |
| - target: aarch64-unknown-linux-gnu | |
| zig_target: aarch64-linux-gnu | |
| - target: arm-unknown-linux-gnueabihf | |
| zig_target: arm-linux-gnueabihf | |
| - target: armv7-unknown-linux-gnueabihf | |
| zig_target: arm-linux-gnueabihf | |
| - target: riscv64gc-unknown-linux-gnu | |
| zig_target: riscv64-linux-gnu | |
| - target: powerpc64le-unknown-linux-gnu | |
| zig_target: powerpc64le-linux-gnu | |
| - target: s390x-unknown-linux-gnu | |
| zig_target: s390x-linux-gnu | |
| - target: loongarch64-unknown-linux-gnu | |
| zig_target: loongarch64-linux-gnu | |
| # ---- musl targets (static binaries) ---- | |
| - target: x86_64-unknown-linux-musl | |
| zig_target: x86_64-linux-musl | |
| musl: true | |
| - target: i686-unknown-linux-musl | |
| zig_target: x86-linux-musl | |
| musl: true | |
| - target: aarch64-unknown-linux-musl | |
| zig_target: aarch64-linux-musl | |
| musl: true | |
| - target: arm-unknown-linux-musleabihf | |
| zig_target: arm-linux-musleabihf | |
| musl: true | |
| - target: armv7-unknown-linux-musleabihf | |
| zig_target: arm-linux-musleabihf | |
| musl: true | |
| - target: riscv64gc-unknown-linux-musl | |
| zig_target: riscv64-linux-musl | |
| musl: true | |
| - target: powerpc64le-unknown-linux-musl | |
| zig_target: powerpc64le-linux-musl | |
| musl: true | |
| - target: loongarch64-unknown-linux-musl | |
| zig_target: loongarch64-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: Configure Zig linker | |
| run: | | |
| # Create zig cc wrapper that filters unsupported linker flags | |
| cat > /usr/local/bin/zig-cc << 'WRAPPER' | |
| #!/usr/bin/env python3 | |
| import sys, os | |
| args = [a for a in sys.argv[1:] if not a.startswith("-Wl,-melf_")] | |
| os.execvp("zig", ["zig", "cc", "-target", os.environ["ZIG_TARGET"]] + args) | |
| WRAPPER | |
| chmod +x /usr/local/bin/zig-cc | |
| # Set linker for this matrix target | |
| TARGET_UPPER="$(echo '${{ matrix.target }}' | tr 'a-z-' 'A-Z_')" | |
| echo "CARGO_TARGET_${TARGET_UPPER}_LINKER=zig-cc" >> "$GITHUB_ENV" | |
| echo "ZIG_TARGET=${{ matrix.zig_target }}" >> "$GITHUB_ENV" | |
| - 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 build \ | |
| -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@v4 | |
| with: | |
| name: hid-rgb-ctl-${{ matrix.target }} | |
| path: hid-rgb-ctl-${{ matrix.target }} | |
| tag: | |
| if: github.ref == 'refs/heads/master' && startsWith(github.event.head_commit.message, 'release:') | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Extract version and create tag | |
| run: | | |
| # Parse version from commit message "release: x.y.z" | |
| 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 | |
| TAG="v${VERSION}" | |
| echo "Creating tag $TAG" | |
| git tag "$TAG" | |
| git push origin "$TAG" | |
| release: | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| merge-multiple: true | |
| - name: List artifacts | |
| run: ls -lh artifacts/ | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: artifacts/* | |
| generate_release_notes: true |