modified to use the musl for a static build #6
Workflow file for this run
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 Build | |
on: | |
push: | |
tags: | |
- 'v*.*.*' | |
workflow_dispatch: | |
permissions: | |
contents: write | |
packages: write | |
issues: write | |
pull-requests: write | |
env: | |
CARGO_TERM_COLOR: always | |
RUST_BACKTRACE: 1 | |
jobs: | |
create-release: | |
runs-on: ubuntu-latest | |
outputs: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
version: ${{ steps.version.outputs.version }} | |
steps: | |
- name: Get version from tag | |
id: version | |
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: Release ${{ github.ref_name }} | |
draft: false | |
prerelease: false | |
build-linux: | |
needs: create-release | |
runs-on: ubuntu-latest | |
container: | |
image: ubuntu:latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install build dependencies | |
run: | | |
apt-get update | |
apt-get install -y \ | |
build-essential \ | |
curl \ | |
numactl \ | |
pciutils \ | |
ethtool \ | |
dmidecode \ | |
ipmitool \ | |
musl-tools # <-- Add musl-tools so we can build musl binaries | |
- name: Install Rust toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
override: true | |
# Add the musl target | |
target: x86_64-unknown-linux-musl | |
- name: Build Release Binary (musl) | |
run: | | |
cargo build --release --target x86_64-unknown-linux-musl | |
mkdir -p build/release | |
# Rename the musl-based binary | |
cp target/x86_64-unknown-linux-musl/release/hardware_report build/release/hardware_report-linux-x86_64 | |
# Optional: 'strip' the binary to reduce size | |
strip build/release/hardware_report-linux-x86_64 | |
- name: Create tarball | |
run: | | |
cd build/release | |
tar czf hardware_report-linux-x86_64-${{ needs.create-release.outputs.version }}.tar.gz hardware_report-linux-x86_64 | |
sha256sum hardware_report-linux-x86_64-${{ needs.create-release.outputs.version }}.tar.gz > hardware_report-linux-x86_64-${{ needs.create-release.outputs.version }}.tar.gz.sha256 | |
- name: Upload Release Asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.create-release.outputs.upload_url }} | |
asset_path: build/release/hardware_report-linux-x86_64-${{ needs.create-release.outputs.version }}.tar.gz | |
asset_name: hardware_report-linux-x86_64-${{ needs.create-release.outputs.version }}.tar.gz | |
asset_content_type: application/gzip | |
- name: Upload SHA256 checksum | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.create-release.outputs.upload_url }} | |
asset_path: build/release/hardware_report-linux-x86_64-${{ needs.create-release.outputs.version }}.tar.gz.sha256 | |
asset_name: hardware_report-linux-x86_64-${{ needs.create-release.outputs.version }}.tar.gz.sha256 | |
asset_content_type: text/plain | |