|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + |
| 11 | +env: |
| 12 | + CARGO_TERM_COLOR: always |
| 13 | + |
| 14 | +jobs: |
| 15 | + build: |
| 16 | + name: Build ${{ matrix.target }} |
| 17 | + runs-on: ${{ matrix.os }} |
| 18 | + strategy: |
| 19 | + matrix: |
| 20 | + include: |
| 21 | + - os: macos-latest |
| 22 | + target: aarch64-apple-darwin |
| 23 | + - os: macos-13 |
| 24 | + target: x86_64-apple-darwin |
| 25 | + - os: ubuntu-latest |
| 26 | + target: x86_64-unknown-linux-gnu |
| 27 | + steps: |
| 28 | + - uses: actions/checkout@v4 |
| 29 | + |
| 30 | + - name: Install Rust |
| 31 | + uses: dtolnay/rust-toolchain@stable |
| 32 | + |
| 33 | + - name: Build |
| 34 | + run: cargo build --workspace --release |
| 35 | + |
| 36 | + - name: Package |
| 37 | + run: | |
| 38 | + TAG="${GITHUB_REF#refs/tags/}" |
| 39 | + DIR="codiv-${TAG}-${{ matrix.target }}" |
| 40 | + mkdir "$DIR" |
| 41 | + cp target/release/codiv target/release/codivd "$DIR/" |
| 42 | + cp LICENSE README.md "$DIR/" |
| 43 | + tar czf "${DIR}.tar.gz" "$DIR" |
| 44 | +
|
| 45 | + - name: Upload artifact |
| 46 | + uses: actions/upload-artifact@v4 |
| 47 | + with: |
| 48 | + name: codiv-${{ matrix.target }} |
| 49 | + path: codiv-*.tar.gz |
| 50 | + |
| 51 | + release: |
| 52 | + name: Create Release |
| 53 | + needs: build |
| 54 | + runs-on: ubuntu-latest |
| 55 | + steps: |
| 56 | + - uses: actions/download-artifact@v4 |
| 57 | + with: |
| 58 | + merge-multiple: true |
| 59 | + |
| 60 | + - name: Create GitHub Release |
| 61 | + uses: softprops/action-gh-release@v2 |
| 62 | + with: |
| 63 | + generate_release_notes: true |
| 64 | + files: codiv-*.tar.gz |
| 65 | + |
| 66 | + update-formula: |
| 67 | + name: Update Homebrew Formula |
| 68 | + needs: release |
| 69 | + runs-on: ubuntu-latest |
| 70 | + steps: |
| 71 | + - uses: actions/checkout@v4 |
| 72 | + with: |
| 73 | + ref: main |
| 74 | + |
| 75 | + - name: Update formula SHA256 hashes |
| 76 | + env: |
| 77 | + GH_TOKEN: ${{ github.token }} |
| 78 | + run: | |
| 79 | + TAG="${GITHUB_REF#refs/tags/}" |
| 80 | + gh release download "$TAG" --dir tarballs |
| 81 | +
|
| 82 | + SHA_ARM=$(shasum -a 256 tarballs/codiv-${TAG}-aarch64-apple-darwin.tar.gz | awk '{print $1}') |
| 83 | + SHA_INTEL=$(shasum -a 256 tarballs/codiv-${TAG}-x86_64-apple-darwin.tar.gz | awk '{print $1}') |
| 84 | + SHA_LINUX=$(shasum -a 256 tarballs/codiv-${TAG}-x86_64-unknown-linux-gnu.tar.gz | awk '{print $1}') |
| 85 | +
|
| 86 | + sed -i "s|SHA256_ARM_PLACEHOLDER|${SHA_ARM}|g" Formula/codiv.rb |
| 87 | + sed -i "s|SHA256_INTEL_PLACEHOLDER|${SHA_INTEL}|g" Formula/codiv.rb |
| 88 | + sed -i "s|SHA256_LINUX_PLACEHOLDER|${SHA_LINUX}|g" Formula/codiv.rb |
| 89 | +
|
| 90 | + # Also update the version/URLs |
| 91 | + sed -i "s|VERSION_PLACEHOLDER|${TAG}|g" Formula/codiv.rb |
| 92 | +
|
| 93 | + - name: Commit updated formula |
| 94 | + run: | |
| 95 | + git config user.name "github-actions[bot]" |
| 96 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 97 | + git add Formula/codiv.rb |
| 98 | + git commit -m "Update Homebrew formula for ${GITHUB_REF#refs/tags/}" || echo "No changes to commit" |
| 99 | + git push |
0 commit comments