|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*" |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + strategy: |
| 14 | + matrix: |
| 15 | + include: |
| 16 | + - target: aarch64-apple-darwin |
| 17 | + os: macos-latest |
| 18 | + - target: x86_64-apple-darwin |
| 19 | + os: macos-13 |
| 20 | + runs-on: ${{ matrix.os }} |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v4 |
| 23 | + - uses: dtolnay/rust-toolchain@stable |
| 24 | + with: |
| 25 | + targets: ${{ matrix.target }} |
| 26 | + - name: Build |
| 27 | + run: cargo build --release --target ${{ matrix.target }} |
| 28 | + - name: Package |
| 29 | + run: | |
| 30 | + cd target/${{ matrix.target }}/release |
| 31 | + tar -czf semantic-diff-${{ github.ref_name }}-${{ matrix.target }}.tar.gz semantic-diff |
| 32 | + shasum -a 256 semantic-diff-${{ github.ref_name }}-${{ matrix.target }}.tar.gz > semantic-diff-${{ github.ref_name }}-${{ matrix.target }}.tar.gz.sha256 |
| 33 | + - uses: actions/upload-artifact@v4 |
| 34 | + with: |
| 35 | + name: semantic-diff-${{ matrix.target }} |
| 36 | + path: | |
| 37 | + target/${{ matrix.target }}/release/semantic-diff-${{ github.ref_name }}-${{ matrix.target }}.tar.gz |
| 38 | + target/${{ matrix.target }}/release/semantic-diff-${{ github.ref_name }}-${{ matrix.target }}.tar.gz.sha256 |
| 39 | +
|
| 40 | + release: |
| 41 | + needs: build |
| 42 | + runs-on: ubuntu-latest |
| 43 | + steps: |
| 44 | + - uses: actions/download-artifact@v4 |
| 45 | + with: |
| 46 | + merge-multiple: true |
| 47 | + - name: Create or update release |
| 48 | + env: |
| 49 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 50 | + GH_REPO: ${{ github.repository }} |
| 51 | + run: | |
| 52 | + # Upload binaries to the existing release (created by tag push) |
| 53 | + gh release upload ${{ github.ref_name }} \ |
| 54 | + semantic-diff-${{ github.ref_name }}-aarch64-apple-darwin.tar.gz \ |
| 55 | + semantic-diff-${{ github.ref_name }}-aarch64-apple-darwin.tar.gz.sha256 \ |
| 56 | + semantic-diff-${{ github.ref_name }}-x86_64-apple-darwin.tar.gz \ |
| 57 | + semantic-diff-${{ github.ref_name }}-x86_64-apple-darwin.tar.gz.sha256 \ |
| 58 | + --clobber |
| 59 | +
|
| 60 | + update-homebrew: |
| 61 | + needs: release |
| 62 | + runs-on: ubuntu-latest |
| 63 | + steps: |
| 64 | + - uses: actions/download-artifact@v4 |
| 65 | + with: |
| 66 | + merge-multiple: true |
| 67 | + - name: Read SHA256 sums |
| 68 | + id: sha |
| 69 | + run: | |
| 70 | + echo "arm64=$(cat semantic-diff-${{ github.ref_name }}-aarch64-apple-darwin.tar.gz.sha256 | awk '{print $1}')" >> "$GITHUB_OUTPUT" |
| 71 | + echo "x86_64=$(cat semantic-diff-${{ github.ref_name }}-x86_64-apple-darwin.tar.gz.sha256 | awk '{print $1}')" >> "$GITHUB_OUTPUT" |
| 72 | + - uses: actions/checkout@v4 |
| 73 | + with: |
| 74 | + repository: alankyshum/homebrew-tap |
| 75 | + token: ${{ secrets.HOMEBREW_TAP_TOKEN }} |
| 76 | + - name: Update formula |
| 77 | + env: |
| 78 | + VERSION: ${{ github.ref_name }} |
| 79 | + SHA_ARM64: ${{ steps.sha.outputs.arm64 }} |
| 80 | + SHA_X86: ${{ steps.sha.outputs.x86_64 }} |
| 81 | + run: | |
| 82 | + VER="${VERSION#v}" |
| 83 | + cat > Formula/semantic-diff.rb << FORMULA |
| 84 | + class SemanticDiff < Formula |
| 85 | + desc "Terminal diff viewer with AI-powered semantic grouping via Claude CLI" |
| 86 | + homepage "https://github.com/alankyshum/semantic-diff" |
| 87 | + version "${VER}" |
| 88 | + license "MIT" |
| 89 | +
|
| 90 | + on_macos do |
| 91 | + if Hardware::CPU.arm? |
| 92 | + url "https://github.com/alankyshum/semantic-diff/releases/download/${VERSION}/semantic-diff-${VERSION}-aarch64-apple-darwin.tar.gz" |
| 93 | + sha256 "${SHA_ARM64}" |
| 94 | + elsif Hardware::CPU.intel? |
| 95 | + url "https://github.com/alankyshum/semantic-diff/releases/download/${VERSION}/semantic-diff-${VERSION}-x86_64-apple-darwin.tar.gz" |
| 96 | + sha256 "${SHA_X86}" |
| 97 | + end |
| 98 | + end |
| 99 | +
|
| 100 | + def install |
| 101 | + bin.install "semantic-diff" |
| 102 | + end |
| 103 | +
|
| 104 | + test do |
| 105 | + assert_match "semantic-diff", shell_output("#{bin}/semantic-diff --help") |
| 106 | + end |
| 107 | + end |
| 108 | + FORMULA |
| 109 | + # Remove leading whitespace from heredoc |
| 110 | + sed -i 's/^ //' Formula/semantic-diff.rb |
| 111 | + - name: Commit and push |
| 112 | + run: | |
| 113 | + git config user.name "github-actions[bot]" |
| 114 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 115 | + git add Formula/semantic-diff.rb |
| 116 | + git commit -m "Update semantic-diff to ${{ github.ref_name }}" |
| 117 | + git push |
0 commit comments