|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*" |
| 7 | + |
| 8 | +env: |
| 9 | + CARGO_TERM_COLOR: always |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + name: Build ${{ matrix.os }} |
| 14 | + runs-on: ${{ matrix.os }} |
| 15 | + strategy: |
| 16 | + fail-fast: false |
| 17 | + matrix: |
| 18 | + os: |
| 19 | + - ubuntu-latest |
| 20 | + - macos-latest |
| 21 | + |
| 22 | + steps: |
| 23 | + - name: Checkout repository |
| 24 | + uses: actions/checkout@v4 |
| 25 | + |
| 26 | + - name: Install Rust toolchain |
| 27 | + uses: dtolnay/rust-toolchain@stable |
| 28 | + |
| 29 | + - name: Cache Rust build artifacts |
| 30 | + uses: Swatinem/rust-cache@v2 |
| 31 | + |
| 32 | + - name: Compute artifact names |
| 33 | + shell: bash |
| 34 | + run: | |
| 35 | + echo "TARGET=$(rustc -vV | sed -n 's/^host: //p')" >> "$GITHUB_ENV" |
| 36 | + echo "VERSION=${GITHUB_REF_NAME}" >> "$GITHUB_ENV" |
| 37 | +
|
| 38 | + - name: Build release binary |
| 39 | + run: cargo build --locked --release |
| 40 | + |
| 41 | + - name: Package release archive |
| 42 | + shell: bash |
| 43 | + run: | |
| 44 | + ARCHIVE_BASENAME="hue-${VERSION}-${TARGET}" |
| 45 | + rm -rf dist |
| 46 | + mkdir -p dist |
| 47 | + cp target/release/hue "dist/hue" |
| 48 | + cp README.md "dist/README.md" |
| 49 | +
|
| 50 | + tar -C dist -czf "${ARCHIVE_BASENAME}.tar.gz" . |
| 51 | + shasum -a 256 "${ARCHIVE_BASENAME}.tar.gz" > "${ARCHIVE_BASENAME}.tar.gz.sha256" |
| 52 | +
|
| 53 | + - name: Upload release artifacts |
| 54 | + uses: actions/upload-artifact@v4 |
| 55 | + with: |
| 56 | + name: release-${{ env.TARGET }} |
| 57 | + path: | |
| 58 | + hue-${{ env.VERSION }}-${{ env.TARGET }}.tar.gz |
| 59 | + hue-${{ env.VERSION }}-${{ env.TARGET }}.tar.gz.sha256 |
| 60 | +
|
| 61 | + publish: |
| 62 | + name: Publish GitHub release |
| 63 | + runs-on: ubuntu-latest |
| 64 | + needs: build |
| 65 | + permissions: |
| 66 | + contents: write |
| 67 | + |
| 68 | + steps: |
| 69 | + - name: Download release artifacts |
| 70 | + uses: actions/download-artifact@v4 |
| 71 | + with: |
| 72 | + path: release-artifacts |
| 73 | + pattern: release-* |
| 74 | + merge-multiple: true |
| 75 | + |
| 76 | + - name: Publish release |
| 77 | + uses: softprops/action-gh-release@v2 |
| 78 | + with: |
| 79 | + files: release-artifacts/* |
| 80 | + generate_release_notes: true |
0 commit comments