| 1 | name: Release |
| 2 | on: |
| 3 | push: |
| 4 | tags: |
| 5 | - "v*" |
| 6 | |
| 7 | permissions: |
| 8 | contents: write |
| 9 | |
| 10 | jobs: |
| 11 | build: |
| 12 | name: Build ${{ matrix.target }} |
| 13 | runs-on: ${{ matrix.os }} |
| 14 | strategy: |
| 15 | matrix: |
| 16 | include: |
| 17 | - target: x86_64-unknown-linux-gnu |
| 18 | os: ubuntu-latest |
| 19 | binary: nmrs-tui |
| 20 | asset: nmrs-tui-x86_64-linux |
| 21 | - target: aarch64-unknown-linux-gnu |
| 22 | os: ubuntu-latest |
| 23 | binary: nmrs-tui |
| 24 | asset: nmrs-tui-aarch64-linux |
| 25 | steps: |
| 26 | - uses: actions/checkout@v7 |
| 27 | - name: Install Rust |
| 28 | uses: dtolnay/rust-toolchain@stable |
| 29 | with: |
| 30 | targets: ${{ matrix.target }} |
| 31 | - name: Install cross |
| 32 | run: cargo install cross |
| 33 | - name: Build |
| 34 | run: cross build --release --target ${{ matrix.target }} |
| 35 | - name: Rename binary |
| 36 | run: cp target/${{ matrix.target }}/release/${{ matrix.binary }} ${{ matrix.asset }} |
| 37 | - name: Upload artifact |
| 38 | uses: actions/upload-artifact@v7 |
| 39 | with: |
| 40 | name: ${{ matrix.asset }} |
| 41 | path: ${{ matrix.asset }} |
| 42 | |
| 43 | release: |
| 44 | name: Create Release |
| 45 | needs: build |
| 46 | runs-on: ubuntu-latest |
| 47 | steps: |
| 48 | - uses: actions/checkout@v7 |
| 49 | - name: Download all artifacts |
| 50 | uses: actions/download-artifact@v8 |
| 51 | with: |
| 52 | path: artifacts |
| 53 | merge-multiple: true |
| 54 | - name: Get changelog entry |
| 55 | id: changelog |
| 56 | run: | |
| 57 | VERSION=${GITHUB_REF#refs/tags/v} |
| 58 | NOTES=$(awk "/## \[$VERSION\]/{flag=1; next} /## \[/{flag=0} flag" CHANGELOG.md) |
| 59 | echo "notes<<EOF" >> $GITHUB_OUTPUT |
| 60 | echo "$NOTES" >> $GITHUB_OUTPUT |
| 61 | echo "EOF" >> $GITHUB_OUTPUT |
| 62 | - name: Upload to GitHub Release |
| 63 | uses: softprops/action-gh-release@v3 |
| 64 | with: |
| 65 | body: ${{ steps.changelog.outputs.notes }} |
| 66 | files: artifacts/* |
