|
4 | 4 | push:
|
5 | 5 | tags:
|
6 | 6 | - "v*"
|
7 |
| - workflow_dispatch: |
8 | 7 |
|
9 | 8 | env:
|
10 | 9 | CARGO_TERM_COLOR: always
|
11 | 10 |
|
12 | 11 | jobs:
|
13 |
| - build: |
14 |
| - runs-on: ubuntu-latest |
15 |
| - |
| 12 | + release: |
| 13 | + name: "Release" |
| 14 | + runs-on: ${{ matrix.os }} |
| 15 | + strategy: |
| 16 | + matrix: |
| 17 | + include: |
| 18 | + - os: ubuntu-latest |
| 19 | + artifact_name: scanr |
| 20 | + asset_name: scanr-linux-gnu-amd64 |
| 21 | + - os: windows-latest |
| 22 | + artifact_name: scanr.exe |
| 23 | + asset_name: scanr-windows-amd64.exe |
| 24 | + - os: macos-latest |
| 25 | + artifact_name: scanr |
| 26 | + asset_name: scanr-darwin-amd64 |
16 | 27 | steps:
|
17 |
| - - name: Check out the repository |
18 |
| - uses: actions/checkout@v4 |
19 |
| - |
20 |
| - - name: Set up Rust |
| 28 | + - name: Checkout repository |
| 29 | + uses: actions/checkout@v2 |
| 30 | + - name: Set up Rust toolchain |
21 | 31 | uses: actions-rs/toolchain@v1
|
22 | 32 | with:
|
| 33 | + profile: minimal |
23 | 34 | toolchain: stable
|
| 35 | + override: true |
| 36 | + - name: Build release |
| 37 | + run: cargo build --release --locked |
| 38 | + - name: Set prerelease flag (non-Windows) |
| 39 | + if: runner.os != 'Windows' |
| 40 | + run: | |
| 41 | + if [ $(echo ${{ github.ref }} | grep "rc") ]; then |
| 42 | + echo "PRERELEASE=true" >> $GITHUB_ENV |
| 43 | + echo "PRERELEASE=true" |
| 44 | + else |
| 45 | + echo "PRERELEASE=false" >> $GITHUB_ENV |
| 46 | + echo "PRERELEASE=false" |
| 47 | + fi |
| 48 | + echo $PRERELEASE |
| 49 | + VERSION=$(echo ${{ github.ref }} | sed 's/refs\/tags\///g') |
| 50 | + echo "VERSION=$VERSION" >> $GITHUB_ENV |
| 51 | + echo "VERSION=$VERSION" |
| 52 | + - name: Set prerelease flag (Windows) |
| 53 | + if: runner.os == 'Windows' |
| 54 | + shell: powershell |
| 55 | + run: | |
| 56 | + $full = "${{ github.ref }}" |
24 | 57 |
|
25 |
| - - name: Build the project |
26 |
| - run: cargo build --release |
27 |
| - |
28 |
| - publish: |
29 |
| - needs: build |
30 |
| - runs-on: ubuntu-latest |
31 |
| - |
32 |
| - steps: |
33 |
| - - name: Check out the repository |
34 |
| - uses: actions/checkout@v4 |
| 58 | + if ( $full -like '*rc*' ) { |
| 59 | + echo "PRERELEASE=true" >> $env:GITHUB_ENV |
| 60 | + echo "PRERELEASE=true" |
| 61 | + } else { |
| 62 | + echo "PRERELEASE=false" >> $env:GITHUB_ENV |
| 63 | + echo "PRERELEASE=false" |
| 64 | + } |
35 | 65 |
|
36 |
| - - name: Set up Rust |
37 |
| - uses: actions-rs/toolchain@v1 |
| 66 | + $trimmed = $full -replace 'refs/tags/','' |
| 67 | + echo "VERSION=$trimmed" >> $env:GITHUB_ENV |
| 68 | + echo "VERSION=$trimmed" |
| 69 | + - name: Upload release assets |
| 70 | + uses: svenstaro/upload-release-action@v2 |
38 | 71 | with:
|
39 |
| - toolchain: stable |
40 |
| - |
41 |
| - - name: Publish to crates.io |
42 |
| - env: |
43 |
| - CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} |
44 |
| - run: cargo publish |
| 72 | + repo_token: ${{ secrets.PERSONAL_GITHUB_TOKEN }} |
| 73 | + file: target/release/${{ matrix.artifact_name }} |
| 74 | + asset_name: ${{ matrix.asset_name }} |
| 75 | + tag: ${{ github.ref }} |
| 76 | + prerelease: ${{ env.PRERELEASE }} |
| 77 | + release_name: "scanr ${{ env.VERSION }}" |
| 78 | + body: "Please refer to **[CHANGELOG.md](https://github.com/trinhminhtriet/scanr/blob/master/CHANGELOG.md)** for information on this release." |
0 commit comments