|
| 1 | +name: cocoindex-code-rs-release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*" |
| 7 | + release: |
| 8 | + types: [published] |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: write |
| 13 | + |
| 14 | +jobs: |
| 15 | + build: |
| 16 | + strategy: |
| 17 | + fail-fast: false |
| 18 | + matrix: |
| 19 | + include: |
| 20 | + - runner: ubuntu-latest |
| 21 | + target: x86_64-unknown-linux-gnu |
| 22 | + os: linux |
| 23 | + arch: x86_64 |
| 24 | + binary: cocoindex-code-rs |
| 25 | + - runner: ubuntu-latest |
| 26 | + target: aarch64-unknown-linux-gnu |
| 27 | + os: linux |
| 28 | + arch: aarch64 |
| 29 | + binary: cocoindex-code-rs |
| 30 | + - runner: macos-latest |
| 31 | + target: x86_64-apple-darwin |
| 32 | + os: macos |
| 33 | + arch: x86_64 |
| 34 | + binary: cocoindex-code-rs |
| 35 | + - runner: macos-latest |
| 36 | + target: aarch64-apple-darwin |
| 37 | + os: macos |
| 38 | + arch: aarch64 |
| 39 | + binary: cocoindex-code-rs |
| 40 | + |
| 41 | + runs-on: ${{ matrix.runner }} |
| 42 | + |
| 43 | + defaults: |
| 44 | + run: |
| 45 | + working-directory: cocoindex-rs |
| 46 | + |
| 47 | + steps: |
| 48 | + - name: Checkout |
| 49 | + uses: actions/checkout@v4 |
| 50 | + |
| 51 | + - name: Install Rust target |
| 52 | + run: rustup target add ${{ matrix.target }} |
| 53 | + |
| 54 | + - name: Install Linux cross toolchain |
| 55 | + if: runner.os == 'Linux' && matrix.target == 'aarch64-unknown-linux-gnu' |
| 56 | + run: | |
| 57 | + sudo apt-get update |
| 58 | + sudo apt-get install -y gcc-aarch64-linux-gnu |
| 59 | +
|
| 60 | + - name: Build binary |
| 61 | + env: |
| 62 | + CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc |
| 63 | + run: cargo build --release --target ${{ matrix.target }} |
| 64 | + |
| 65 | + - name: Package archive |
| 66 | + run: | |
| 67 | + mkdir -p dist |
| 68 | + cp target/${{ matrix.target }}/release/${{ matrix.binary }} dist/${{ matrix.binary }} |
| 69 | + chmod +x dist/${{ matrix.binary }} |
| 70 | + tar -czf ../${{ matrix.binary }}-${{ matrix.os }}-${{ matrix.arch }}.tar.gz -C dist ${{ matrix.binary }} |
| 71 | +
|
| 72 | + - name: Upload build artifact |
| 73 | + uses: actions/upload-artifact@v4 |
| 74 | + with: |
| 75 | + name: ${{ matrix.binary }}-${{ matrix.os }}-${{ matrix.arch }} |
| 76 | + path: ${{ github.workspace }}/${{ matrix.binary }}-${{ matrix.os }}-${{ matrix.arch }}.tar.gz |
| 77 | + |
| 78 | + - name: Upload release asset |
| 79 | + if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'release' |
| 80 | + uses: softprops/action-gh-release@v2 |
| 81 | + with: |
| 82 | + files: ${{ github.workspace }}/${{ matrix.binary }}-${{ matrix.os }}-${{ matrix.arch }}.tar.gz |
0 commit comments