|
| 1 | +--- |
| 2 | +name: Release |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + tags: |
| 7 | + - '*' |
| 8 | + |
| 9 | +jobs: |
| 10 | + ci: |
| 11 | + name: Run CI |
| 12 | + uses: ./.github/workflows/ci-reusable.yml |
| 13 | + |
| 14 | + release: |
| 15 | + needs: ci |
| 16 | + runs-on: ${{ matrix.runs-on }} |
| 17 | + timeout-minutes: 15 |
| 18 | + strategy: |
| 19 | + fail-fast: false |
| 20 | + matrix: |
| 21 | + include: |
| 22 | + - runs-on: windows-latest |
| 23 | + target: x86_64-pc-windows-msvc |
| 24 | + |
| 25 | + - runs-on: windows-latest |
| 26 | + target: i686-pc-windows-msvc |
| 27 | + |
| 28 | + - runs-on: windows-latest |
| 29 | + target: aarch64-pc-windows-msvc |
| 30 | + |
| 31 | + - runs-on: ubuntu-latest |
| 32 | + target: x86_64-unknown-linux-musl |
| 33 | + |
| 34 | + - runs-on: ubuntu-latest |
| 35 | + target: i686-unknown-linux-musl |
| 36 | + |
| 37 | + - runs-on: ubuntu-latest |
| 38 | + target: aarch64-unknown-linux-musl |
| 39 | + |
| 40 | + steps: |
| 41 | + - uses: actions/checkout@v4 |
| 42 | + |
| 43 | + - uses: actions-rust-lang/setup-rust-toolchain@v1 |
| 44 | + with: |
| 45 | + components: clippy, rustfmt |
| 46 | + rustflags: "" |
| 47 | + target: ${{ matrix.target }} |
| 48 | + |
| 49 | + - name: Install cross |
| 50 | + if: ${{ matrix.runs-on == 'ubuntu-latest' }} |
| 51 | + run: cargo install cross --git https://github.com/cross-rs/cross |
| 52 | + |
| 53 | + - name: Build (Windows) |
| 54 | + if: ${{ matrix.runs-on == 'windows-latest' }} |
| 55 | + run: cargo build --release --all-features --target=${{ matrix.target }} |
| 56 | + |
| 57 | + - name: Build (Linux - cross compilation) |
| 58 | + if: ${{ matrix.runs-on == 'ubuntu-latest' }} |
| 59 | + run: cross build --release --all-features --target=${{ matrix.target }} |
| 60 | + |
| 61 | + - name: Create a zip (windows) |
| 62 | + id: create-zip |
| 63 | + if: ${{ matrix.runs-on == 'windows-latest' }} |
| 64 | + run: | |
| 65 | + mkdir release |
| 66 | + cp LICENSE release/ |
| 67 | + cp target/${{ matrix.target }}/release/csm.exe release/ |
| 68 | + Compress-Archive -Path release/* -DestinationPath csm-${{ github.ref_name }}-${{ matrix.target }}.zip |
| 69 | + echo "archive=csm-${{ github.ref_name }}-${{ matrix.target }}.zip" >> $GITHUB_OUTPUT |
| 70 | +
|
| 71 | + - name: Create a tar.gz (linux) |
| 72 | + id: create-tar |
| 73 | + if: ${{ matrix.runs-on == 'ubuntu-latest' }} |
| 74 | + run: | |
| 75 | + mkdir release |
| 76 | + cp LICENSE release/ |
| 77 | + cp target/${{ matrix.target }}/release/csm release/ |
| 78 | + tar -czvf csm-${{ github.ref_name }}-${{ matrix.target }}.tar.gz -C release . |
| 79 | + echo "archive=csm-${{ github.ref_name }}-${{ matrix.target }}.tar.gz" >> $GITHUB_OUTPUT |
| 80 | +
|
| 81 | + - name: Set archive output |
| 82 | + id: archive |
| 83 | + run: echo "file=${{ steps.create-zip.outputs.archive }}${{ steps.create-tar.outputs.archive }}" >> $GITHUB_OUTPUT |
| 84 | + |
| 85 | + - name: Release |
| 86 | + uses: softprops/action-gh-release@v2 |
| 87 | + if: github.ref_type == 'tag' |
| 88 | + with: |
| 89 | + files: ${{ steps.archive.outputs.file }} |
0 commit comments