|
| 1 | +name: release |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - master |
| 6 | + tags: |
| 7 | + - v*.*.* |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +jobs: |
| 11 | + build: |
| 12 | + strategy: |
| 13 | + matrix: |
| 14 | + include: |
| 15 | + - { target: x86_64-unknown-linux-gnu, os: ubuntu-20.04, suffix: .gz } |
| 16 | + - { target: x86_64-apple-darwin, os: macos-latest, suffix: .gz } |
| 17 | + - { target: aarch64-apple-darwin, os: macos-latest, suffix: .gz } |
| 18 | + - { target: x86_64-pc-windows-msvc, os: windows-latest, suffix: .zip } |
| 19 | + runs-on: ${{ matrix.os }} |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v3 |
| 22 | + - uses: actions-rs/toolchain@v1 |
| 23 | + with: |
| 24 | + toolchain: stable |
| 25 | + profile: minimal |
| 26 | + target: ${{ matrix.target }} |
| 27 | + override: true |
| 28 | + - name: Cache Dependencies |
| 29 | + uses: Swatinem/rust-cache@v1 |
| 30 | + with: |
| 31 | + key: ${{ matrix.target }} |
| 32 | + - uses: actions-rs/cargo@v1 |
| 33 | + with: |
| 34 | + command: build |
| 35 | + args: --target ${{ matrix.target }} --release |
| 36 | + |
| 37 | + - name: (Not Windows) Move executables and compress |
| 38 | + if: ${{ matrix.os != 'windows-latest' }} |
| 39 | + run: gzip -c target/${{ matrix.target }}/release/svdtools > svdtools-${{ matrix.target }}${{ matrix.suffix }} |
| 40 | + |
| 41 | + - name: (Windows) Move executables and compress |
| 42 | + if: ${{ matrix.os == 'windows-latest' }} |
| 43 | + run: Compress-Archive -Path target\${{ matrix.target }}\release\svdtools.exe -DestinationPath svdtools-${{ matrix.target }}${{ matrix.suffix }} |
| 44 | + |
| 45 | + - uses: actions/upload-artifact@v3 |
| 46 | + with: |
| 47 | + name: svdtools-${{ matrix.target }} |
| 48 | + path: svdtools-${{ matrix.target }}${{ matrix.suffix }} |
| 49 | + |
| 50 | + release: |
| 51 | + name: release |
| 52 | + runs-on: ubuntu-latest |
| 53 | + needs: [build] |
| 54 | + steps: |
| 55 | + - uses: actions/checkout@v3 |
| 56 | + - uses: actions/download-artifact@v3 |
| 57 | + with: |
| 58 | + path: artifacts |
| 59 | + - run: ls -R ./artifacts |
| 60 | + |
| 61 | + - name: Set current date as environment variable |
| 62 | + run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV |
| 63 | + |
| 64 | + - id: changelog-reader |
| 65 | + |
| 66 | + with: |
| 67 | + path: ./CHANGELOG-rust.md |
| 68 | + version: ${{ (github.ref_type == 'tag' && github.ref_name) || 'Unreleased' }} |
| 69 | + |
| 70 | + - uses: softprops/action-gh-release@v1 |
| 71 | + with: |
| 72 | + tag_name: ${{ steps.changelog-reader.outputs.version }} |
| 73 | + name: ${{ (github.ref_type == 'tag' && steps.changelog-reader.outputs.version) || format('Prereleased {0}', env.CURRENT_DATE) }} |
| 74 | + body: ${{ steps.changelog-reader.outputs.changes }} |
| 75 | + prerelease: ${{ steps.changelog-reader.outputs.status == 'unreleased' }} |
| 76 | + files: | |
| 77 | + artifacts/**/* |
0 commit comments