|
| 1 | +# Workflow to build statically linked MUSL based release binaries |
| 2 | + |
| 3 | +name: Build and Release Binaries |
| 4 | + |
| 5 | +# This workflow runs when a new GitHub Release is created. |
| 6 | +on: |
| 7 | + release: |
| 8 | + types: [created] |
| 9 | + # Allows you to run this workflow manually from the Actions tab |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +jobs: |
| 13 | + build-and-release: |
| 14 | + name: Build for ${{ matrix.target }} |
| 15 | + runs-on: "rust:1.81" |
| 16 | + |
| 17 | + # We use a build matrix to build for both architectures |
| 18 | + strategy: |
| 19 | + matrix: |
| 20 | + target: |
| 21 | + - x86_64-unknown-linux-musl |
| 22 | + - aarch64-unknown-linux-musl |
| 23 | + |
| 24 | + steps: |
| 25 | + - name: Checkout code |
| 26 | + uses: actions/checkout@v4 |
| 27 | + |
| 28 | + - name: Install Rust toolchain |
| 29 | + run: | |
| 30 | + apt update |
| 31 | + apt install -y clang mold |
| 32 | + rustup target add ${{ matrix.target }} |
| 33 | +
|
| 34 | + - name: Build binary |
| 35 | + run: cargo build --release --target ${{ matrix.target }} |
| 36 | + |
| 37 | + - name: Prepare binary for upload |
| 38 | + id: prepare_binary |
| 39 | + run: | |
| 40 | + local bin_name="cobertura_split" |
| 41 | + local bin_path="target/${{ matrix.target }}/release/${bin_name}" |
| 42 | + local asset_name="${bin_name}-${{ matrix.target }}" |
| 43 | + mv "${bin_path}" "${asset_name}" |
| 44 | + echo "ASSET_PATH=./${asset_name}" >> $GITHUB_ENV |
| 45 | + echo "ASSET_NAME=${asset_name}" >> $GITHUB_ENV |
| 46 | + local bin_name="lcov2xml" |
| 47 | + local bin_path="target/${{ matrix.target }}/release/${bin_name}" |
| 48 | + local asset_name="${bin_name}-${{ matrix.target }}" |
| 49 | + mv "${bin_path}" "${asset_name}" |
| 50 | + echo "ASSET2_PATH=./${asset_name}" >> $GITHUB_ENV |
| 51 | + echo "ASSET2_NAME=${asset_name}" >> $GITHUB_ENV |
| 52 | +
|
| 53 | + - name: Upload Release Asset |
| 54 | + uses: actions/upload-release-asset@v1 |
| 55 | + env: |
| 56 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 57 | + with: |
| 58 | + upload_url: ${{ github.event.release.upload_url }} |
| 59 | + asset_path: ${{ env.ASSET_PATH }} |
| 60 | + asset_name: ${{ env.ASSET_NAME }} |
| 61 | + asset_content_type: application/octet-stream |
| 62 | + |
| 63 | + - name: Upload Release Asset2 |
| 64 | + uses: actions/upload-release-asset@v1 |
| 65 | + env: |
| 66 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 67 | + with: |
| 68 | + upload_url: ${{ github.event.release.upload_url }} |
| 69 | + asset_path: ${{ env.ASSET2_PATH }} |
| 70 | + asset_name: ${{ env.ASSET2_NAME }} |
| 71 | + asset_content_type: application/octet-stream |
0 commit comments