|
| 1 | +name: Release |
| 2 | +on: |
| 3 | + push: |
| 4 | + tags: |
| 5 | + - "v[0-9]+.[0-9]+.[0-9]+" |
| 6 | + |
| 7 | +env: |
| 8 | + CARGO_TERM_COLOR: always |
| 9 | + |
| 10 | +jobs: |
| 11 | + build: |
| 12 | + name: Build ${{ matrix.target.name }} package |
| 13 | + runs-on: ${{ matrix.target.os }} |
| 14 | + strategy: |
| 15 | + matrix: |
| 16 | + target: |
| 17 | + [ |
| 18 | + { name: x86_64-unknown-linux-gnu, os: ubuntu-latest }, |
| 19 | + { name: aarch64-apple-darwin, os: macos-latest }, |
| 20 | + { name: x86_64-apple-darwin, os: macos-latest }, |
| 21 | + { |
| 22 | + name: x86_64-pc-windows-msvc, |
| 23 | + os: windows-latest, |
| 24 | + extension: .exe, |
| 25 | + }, |
| 26 | + ] |
| 27 | + steps: |
| 28 | + - name: Fetch latest code |
| 29 | + uses: actions/checkout@v3 |
| 30 | + - name: Setup Rust toolchain |
| 31 | + run: rustup target add ${{ matrix.target.name }} |
| 32 | + - name: Build |
| 33 | + run: cargo build --release --locked --target ${{ matrix.target.name }} |
| 34 | + - name: Compress |
| 35 | + run: | |
| 36 | + mv target/${{ matrix.target.name }}/release/<NAME>${{ matrix.target.extension }} . |
| 37 | + zstd --ultra -22 -o <NAME>-${{ matrix.target.name }}.zst <NAME>${{ matrix.target.extension }} |
| 38 | + - name: Collect artifact |
| 39 | + run: | |
| 40 | + mkdir -p artifacts |
| 41 | + mv <NAME>-${{ matrix.target.name }}.zst artifacts |
| 42 | + - name: Upload artifact |
| 43 | + uses: actions/upload-artifact@v3.1.2 |
| 44 | + with: |
| 45 | + name: artifacts |
| 46 | + path: artifacts |
| 47 | + |
| 48 | + release: |
| 49 | + name: Release |
| 50 | + runs-on: ubuntu-latest |
| 51 | + needs: [build] |
| 52 | + steps: |
| 53 | + - name: Download artifacts |
| 54 | + uses: actions/download-artifact@v3 |
| 55 | + with: |
| 56 | + name: artifacts |
| 57 | + path: artifacts |
| 58 | + - name: Hash |
| 59 | + run: | |
| 60 | + cd artifacts |
| 61 | + sha256sum * | tee ../SHA256 |
| 62 | + md5sum * | tee ../MD5 |
| 63 | + mv ../SHA256 . |
| 64 | + mv ../MD5 . |
| 65 | + - name: Publish |
| 66 | + uses: softprops/action-gh-release@v1 |
| 67 | + with: |
| 68 | + discussion_category_name: Announcements |
| 69 | + generate_release_notes: true |
| 70 | + files: artifacts/* |
| 71 | + |
| 72 | + # publish-on-crates-io: |
| 73 | + # name: Publish on crates.io |
| 74 | + # runs-on: ubuntu-latest |
| 75 | + # steps: |
| 76 | + # - name: Fetch latest code |
| 77 | + # uses: actions/checkout@v3 |
| 78 | + # - name: Login |
| 79 | + # run: cargo login ${{ secrets.CARGO_REGISTRY_TOKEN }} |
| 80 | + # - name: Publish |
| 81 | + # run: .maintain/release.sh |
| 82 | + |
| 83 | + clean-artifacts: |
| 84 | + name: Clean artifacts |
| 85 | + if: always() |
| 86 | + needs: [release] |
| 87 | + steps: |
| 88 | + - name: Clean artifacts |
| 89 | + uses: geekyeggo/delete-artifact@v2 |
| 90 | + with: |
| 91 | + name: artifacts |
| 92 | + runs-on: ubuntu-latest |
0 commit comments