|
| 1 | +name: Seamless Release (CI-Augmented Tag) |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' |
| 7 | + |
| 8 | +jobs: |
| 9 | + build-rust: |
| 10 | + name: Build Rust (${{ matrix.os }}-${{ matrix.arch }}) |
| 11 | + runs-on: ${{ matrix.os }} |
| 12 | + strategy: |
| 13 | + fail-fast: false |
| 14 | + matrix: |
| 15 | + include: |
| 16 | + - os: ubuntu-latest |
| 17 | + arch: amd64 |
| 18 | + target: x86_64-unknown-linux-gnu |
| 19 | + - os: ubuntu-latest |
| 20 | + arch: arm64 |
| 21 | + target: aarch64-unknown-linux-gnu |
| 22 | + - os: macos-latest |
| 23 | + arch: amd64 |
| 24 | + target: x86_64-apple-darwin |
| 25 | + - os: macos-latest |
| 26 | + arch: arm64 |
| 27 | + target: aarch64-apple-darwin |
| 28 | + - os: windows-latest |
| 29 | + arch: amd64 |
| 30 | + target: x86_64-pc-windows-gnu |
| 31 | + |
| 32 | + steps: |
| 33 | + - uses: actions/checkout@v4 |
| 34 | + |
| 35 | + - name: Install Rust |
| 36 | + uses: dtolnay/rust-toolchain@stable |
| 37 | + with: |
| 38 | + targets: ${{ matrix.target }} |
| 39 | + |
| 40 | + - name: Install Cross-Compilation Tools (Linux ARM64) |
| 41 | + if: matrix.target == 'aarch64-unknown-linux-gnu' |
| 42 | + run: | |
| 43 | + sudo apt-get update |
| 44 | + sudo apt-get install -y gcc-aarch64-linux-gnu |
| 45 | +
|
| 46 | + - name: Build Rust Library |
| 47 | + working-directory: zerobus-ffi |
| 48 | + run: | |
| 49 | + cargo build --release --target ${{ matrix.target }} |
| 50 | + env: |
| 51 | + CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc |
| 52 | + |
| 53 | + - name: Prepare Artifact |
| 54 | + shell: bash |
| 55 | + run: | |
| 56 | + mkdir -p dist/${{ runner.os == 'macOS' && 'darwin' || (runner.os == 'Windows' && 'windows' || 'linux') }}_${{ matrix.arch }} |
| 57 | + if [ "${{ runner.os }}" = "Windows" ]; then |
| 58 | + cp zerobus-ffi/target/${{ matrix.target }}/release/libzerobus_ffi.a dist/windows_${{ matrix.arch }}/libzerobus_ffi.a || \ |
| 59 | + cp zerobus-ffi/target/${{ matrix.target }}/release/zerobus_ffi.lib dist/windows_${{ matrix.arch }}/libzerobus_ffi.a |
| 60 | + else |
| 61 | + cp zerobus-ffi/target/${{ matrix.target }}/release/libzerobus_ffi.a dist/${{ runner.os == 'macOS' && 'darwin' || 'linux' }}_${{ matrix.arch }}/libzerobus_ffi.a |
| 62 | + fi |
| 63 | +
|
| 64 | + - name: Upload Artifact |
| 65 | + uses: actions/upload-artifact@v4 |
| 66 | + with: |
| 67 | + name: lib-${{ matrix.os }}-${{ matrix.arch }} |
| 68 | + path: dist/ |
| 69 | + |
| 70 | + update-tag: |
| 71 | + name: Update Tag with Binaries |
| 72 | + needs: build-rust |
| 73 | + runs-on: ubuntu-latest |
| 74 | + permissions: |
| 75 | + contents: write |
| 76 | + steps: |
| 77 | + - uses: actions/checkout@v4 |
| 78 | + with: |
| 79 | + fetch-depth: 0 |
| 80 | + |
| 81 | + - name: Download all artifacts |
| 82 | + uses: actions/download-artifact@v4 |
| 83 | + with: |
| 84 | + path: lib-artifacts |
| 85 | + merge-multiple: true |
| 86 | + |
| 87 | + - name: Prepare lib directory |
| 88 | + run: | |
| 89 | + mkdir -p lib |
| 90 | + cp -r lib-artifacts/* lib/ |
| 91 | + rm -rf lib-artifacts |
| 92 | +
|
| 93 | + - name: Commit and Force-Push Tag |
| 94 | + run: | |
| 95 | + git config --global user.name "github-actions[bot]" |
| 96 | + git config --global user.email "github-actions[bot]@users.noreply.github.com" |
| 97 | + |
| 98 | + # Add the lib directory even though it's gitignored |
| 99 | + git add -f lib/ |
| 100 | + |
| 101 | + # Create an augmented commit |
| 102 | + git commit -m "Release ${{ github.ref_name }} with pre-built binaries" |
| 103 | + |
| 104 | + # Force update the tag to this new commit |
| 105 | + git tag -f ${{ github.ref_name }} |
| 106 | + git push origin ${{ github.ref_name }} --force |
| 107 | +
|
0 commit comments