Release Build #23
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: Release Build | |
| # Runs when a GitHub Release is published (you create the release for an existing tag, or | |
| # create tag + release together in the UI). Assets are built and attached to that release. | |
| # Optional: workflow_dispatch with a tag for manual builds (creates/updates release assets). | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: "Existing git tag to build (e.g. v1.0.0)" | |
| required: true | |
| type: string | |
| permissions: | |
| contents: write | |
| packages: write | |
| env: | |
| CARGO_TERM_COLOR: always | |
| RUST_BACKTRACE: 1 | |
| jobs: | |
| metadata: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| tag: ${{ steps.meta.outputs.tag }} | |
| version: ${{ steps.meta.outputs.version }} | |
| steps: | |
| - id: meta | |
| run: | | |
| if [ "${{ github.event_name }}" = "release" ]; then | |
| TAG="${{ github.event.release.tag_name }}" | |
| else | |
| TAG="${{ github.event.inputs.tag }}" | |
| fi | |
| if [[ ! "$TAG" =~ ^v ]]; then | |
| echo "::error::Tag must start with v (got: $TAG)" | |
| exit 1 | |
| fi | |
| echo "tag=$TAG" >> "$GITHUB_OUTPUT" | |
| echo "version=${TAG#v}" >> "$GITHUB_OUTPUT" | |
| build-linux: | |
| needs: metadata | |
| runs-on: blacksmith-2vcpu-ubuntu-2204 | |
| container: | |
| image: ubuntu:latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ needs.metadata.outputs.tag }} | |
| - name: Install build dependencies | |
| run: | | |
| apt-get update | |
| apt-get install -y \ | |
| build-essential \ | |
| curl \ | |
| numactl \ | |
| pciutils \ | |
| ethtool \ | |
| dmidecode \ | |
| ipmitool \ | |
| pkg-config \ | |
| libssl-dev | |
| - name: Install Rust toolchain | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| toolchain: stable | |
| override: true | |
| target: x86_64-unknown-linux-gnu | |
| - name: Build Release Binary | |
| run: | | |
| cargo build --release --target x86_64-unknown-linux-gnu | |
| mkdir -p build/release | |
| cp target/x86_64-unknown-linux-gnu/release/hardware_report build/release/hardware_report-linux-x86_64 | |
| strip build/release/hardware_report-linux-x86_64 | |
| - name: Create tarball | |
| run: | | |
| VERSION="${{ needs.metadata.outputs.version }}" | |
| cd build/release | |
| tar czf "hardware_report-linux-x86_64-${VERSION}.tar.gz" hardware_report-linux-x86_64 | |
| sha256sum "hardware_report-linux-x86_64-${VERSION}.tar.gz" > "hardware_report-linux-x86_64-${VERSION}.tar.gz.sha256" | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: linux-release | |
| path: | | |
| build/release/*.tar.gz | |
| build/release/*.sha256 | |
| build-linux-arm64: | |
| needs: metadata | |
| runs-on: blacksmith-2vcpu-ubuntu-2204-arm | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ needs.metadata.outputs.tag }} | |
| - name: Install build dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| build-essential \ | |
| curl \ | |
| numactl \ | |
| pciutils \ | |
| ethtool \ | |
| dmidecode \ | |
| ipmitool \ | |
| pkg-config \ | |
| libssl-dev | |
| - name: Install Rust toolchain | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| toolchain: stable | |
| override: true | |
| - name: Build release binary | |
| run: | | |
| cargo build --release | |
| mkdir -p build/release | |
| cp target/release/hardware_report build/release/hardware_report-linux-aarch64 | |
| strip build/release/hardware_report-linux-aarch64 | |
| - name: Create tarball | |
| run: | | |
| VERSION="${{ needs.metadata.outputs.version }}" | |
| cd build/release | |
| tar czf "hardware_report-linux-aarch64-${VERSION}.tar.gz" hardware_report-linux-aarch64 | |
| sha256sum "hardware_report-linux-aarch64-${VERSION}.tar.gz" > "hardware_report-linux-aarch64-${VERSION}.tar.gz.sha256" | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: linux-arm64-release | |
| path: | | |
| build/release/*.tar.gz | |
| build/release/*.sha256 | |
| attach-assets: | |
| needs: | |
| - metadata | |
| - build-linux | |
| - build-linux-arm64 | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download Linux x86_64 artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: linux-release | |
| path: dist | |
| - name: Download Linux arm64 artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: linux-arm64-release | |
| path: dist | |
| - name: Upload release assets | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ needs.metadata.outputs.tag }} | |
| working_directory: dist | |
| fail_on_unmatched_files: true | |
| files: | | |
| *.tar.gz | |
| *.tar.gz.sha256 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |