|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' |
| 7 | + |
| 8 | +env: |
| 9 | + CARGO_TERM_COLOR: always |
| 10 | + RUST_BACKTRACE: 1 |
| 11 | + |
| 12 | +jobs: |
| 13 | + build: |
| 14 | + name: Build ${{ matrix.target }} |
| 15 | + runs-on: ${{ matrix.os }} |
| 16 | + strategy: |
| 17 | + fail-fast: false |
| 18 | + matrix: |
| 19 | + include: |
| 20 | + - os: ubuntu-latest |
| 21 | + target: x86_64-unknown-linux-musl |
| 22 | + artifact_name: cloud-cli |
| 23 | + asset_name: cloud-cli-linux-amd64 |
| 24 | + use_cross: true |
| 25 | + - os: ubuntu-latest |
| 26 | + target: aarch64-unknown-linux-gnu |
| 27 | + artifact_name: cloud-cli |
| 28 | + asset_name: cloud-cli-linux-arm64 |
| 29 | + use_cross: true |
| 30 | + |
| 31 | + steps: |
| 32 | + - uses: actions/checkout@v3 |
| 33 | + |
| 34 | + - name: Setup Rust toolchain |
| 35 | + uses: dtolnay/rust-toolchain@stable |
| 36 | + with: |
| 37 | + targets: ${{ matrix.target }} |
| 38 | + |
| 39 | + - name: Install cross |
| 40 | + run: cargo install cross |
| 41 | + |
| 42 | + - name: Build with Cross |
| 43 | + run: cross build --release --target ${{ matrix.target }} |
| 44 | + |
| 45 | + - name: Prepare artifacts |
| 46 | + shell: bash |
| 47 | + run: | |
| 48 | + mkdir -p dist |
| 49 | + cp "target/${{ matrix.target }}/release/${{ matrix.artifact_name }}" "dist/${{ matrix.asset_name }}" |
| 50 | + chmod +x "dist/${{ matrix.asset_name }}" |
| 51 | +
|
| 52 | + - name: Upload artifacts |
| 53 | + uses: actions/upload-artifact@v4 |
| 54 | + with: |
| 55 | + name: ${{ matrix.asset_name }} |
| 56 | + path: dist/${{ matrix.asset_name }} |
| 57 | + if-no-files-found: error |
| 58 | + |
| 59 | + release: |
| 60 | + name: Create Release |
| 61 | + needs: build |
| 62 | + runs-on: ubuntu-latest |
| 63 | + steps: |
| 64 | + - name: Checkout code |
| 65 | + uses: actions/checkout@v3 |
| 66 | + |
| 67 | + - name: Download all artifacts |
| 68 | + uses: actions/download-artifact@v4 |
| 69 | + with: |
| 70 | + path: artifacts |
| 71 | + |
| 72 | + - name: Create Release |
| 73 | + id: create_release |
| 74 | + uses: softprops/action-gh-release@v1 |
| 75 | + with: |
| 76 | + files: artifacts/**/* |
| 77 | + draft: false |
| 78 | + prerelease: false |
| 79 | + generate_release_notes: true |
| 80 | + env: |
| 81 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments