|
| 1 | +name: release |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - main |
| 6 | + tags: |
| 7 | + - v*.*.* |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +jobs: |
| 11 | + build: |
| 12 | + strategy: |
| 13 | + matrix: |
| 14 | + mode: [release, debug] |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v3 |
| 18 | + |
| 19 | + - name: Setup Rust Toolchain |
| 20 | + uses: actions-rs/toolchain@v1 |
| 21 | + with: |
| 22 | + profile: minimal |
| 23 | + toolchain: nightly |
| 24 | + target: riscv64imac-unknown-none-elf |
| 25 | + override: true |
| 26 | + |
| 27 | + - name: Cache Dependencies |
| 28 | + uses: Swatinem/rust-cache@v2 |
| 29 | + with: |
| 30 | + key: ${{ matrix.mode }} |
| 31 | + |
| 32 | + - name: Build (release mode) |
| 33 | + if: matrix.mode == 'release' |
| 34 | + run: cargo make |
| 35 | + |
| 36 | + - name: Build (debug mode) |
| 37 | + if: matrix.mode == 'debug' |
| 38 | + run: cargo make --debug |
| 39 | + |
| 40 | + - name: Compress and Rename Artifact |
| 41 | + run: | |
| 42 | + gzip -c target/riscv64imac-unknown-none-elf/${{ matrix.mode }}/rustsbi-qemu.bin > rustsbi-qemu-${{ matrix.mode }}.gz |
| 43 | + zip rustsbi-qemu-${{ matrix.mode }}.zip target/riscv64imac-unknown-none-elf/${{ matrix.mode }}/rustsbi-qemu.bin |
| 44 | +
|
| 45 | + - name: Upload Artifacts |
| 46 | + uses: actions/upload-artifact@v2 |
| 47 | + with: |
| 48 | + name: rustsbi-qemu-${{ matrix.mode }} |
| 49 | + path: | |
| 50 | + rustsbi-qemu-${{ matrix.mode }}.gz |
| 51 | + rustsbi-qemu-${{ matrix.mode }}.zip |
| 52 | +
|
| 53 | + release: |
| 54 | + runs-on: ubuntu-latest |
| 55 | + needs: build |
| 56 | + steps: |
| 57 | + - uses: actions/checkout@v3 |
| 58 | + |
| 59 | + - name: Download Artifacts |
| 60 | + uses: actions/download-artifact@v2 |
| 61 | + with: |
| 62 | + path: artifacts |
| 63 | + |
| 64 | + - name: List Artifacts |
| 65 | + run: ls -R ./artifacts |
| 66 | + |
| 67 | + - name: Set current date as environment variable |
| 68 | + run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV |
| 69 | + |
| 70 | + - name: Check if pre-release |
| 71 | + id: check |
| 72 | + run: | |
| 73 | + if [[ $GITHUB_REF =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then |
| 74 | + echo "PRE_RELEASE=false" >> $GITHUB_OUTPUT |
| 75 | + else |
| 76 | + echo "PRE_RELEASE=true" >> $GITHUB_OUTPUT |
| 77 | + fi |
| 78 | +
|
| 79 | + - name: Get Changelog |
| 80 | + id: changelog-reader |
| 81 | + |
| 82 | + with: |
| 83 | + version: ${{ (steps.check.outputs.PRE_RELEASE && 'Unreleased') || github.ref_name }} |
| 84 | + |
| 85 | + - name: Create Release |
| 86 | + uses: softprops/action-gh-release@v1 |
| 87 | + with: |
| 88 | + tag_name: ${{ steps.changelog-reader.outputs.version }} |
| 89 | + name: ${{ (github.ref_type == 'tag' && steps.changelog-reader.outputs.version) || format('Prereleased {0}', env.CURRENT_DATE) }} |
| 90 | + body: ${{ steps.changelog-reader.outputs.changes }} |
| 91 | + prerelease: ${{ steps.changelog-reader.outputs.status == 'unreleased' }} |
| 92 | + target_commitish: ${{ github.sha }} |
| 93 | + files: | |
| 94 | + artifacts/**/* |
0 commit comments