|
1 | | -name: Release & Update Homebrew Formula |
| 1 | +name: Bump Homebrew Formula |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | release: |
5 | 5 | types: [published] |
6 | | - |
7 | | -permissions: |
8 | | - contents: write |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + tag: |
| 9 | + description: "Release tag to bump (e.g. v2.3.2)" |
| 10 | + required: true |
9 | 11 |
|
10 | 12 | jobs: |
11 | | - update-formula: |
| 13 | + bump: |
12 | 14 | runs-on: ubuntu-latest |
13 | 15 | steps: |
14 | | - - uses: actions/checkout@v4 |
15 | | - with: |
16 | | - ref: main |
17 | | - |
18 | | - - name: Get release tag |
| 16 | + - name: Resolve tag |
19 | 17 | id: tag |
20 | | - run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT" |
21 | | - |
22 | | - - name: Download source tarball and compute SHA256 |
23 | | - id: sha |
24 | | - run: | |
25 | | - TARBALL_URL="https://github.com/${{ github.repository }}/archive/refs/tags/${GITHUB_REF_NAME}.tar.gz" |
26 | | - SHA256=$(curl -sL "$TARBALL_URL" | shasum -a 256 | awk '{print $1}') |
27 | | - echo "sha256=$SHA256" >> "$GITHUB_OUTPUT" |
28 | | - echo "url=$TARBALL_URL" >> "$GITHUB_OUTPUT" |
29 | | -
|
30 | | - - name: Update formula version and SHA256 |
31 | | - run: | |
32 | | - python3 - <<'PYEOF' |
33 | | - import re |
34 | | -
|
35 | | - with open("Formula/agent-pulse.rb") as f: |
36 | | - content = f.read() |
37 | | -
|
38 | | - # Update the source url |
39 | | - content = re.sub( |
40 | | - r'( url )"https://github\.com/.*/archive/refs/tags/.*\.tar\.gz"', |
41 | | - rf'\1"${{ steps.sha.outputs.url }}"', |
42 | | - content, |
43 | | - count=1, |
44 | | - ) |
45 | | -
|
46 | | - # Update the source sha256 (the one right after the url line, before license) |
47 | | - content = re.sub( |
48 | | - r'( url "https://github\.com/.*\.tar\.gz"\n )sha256 ".*?"', |
49 | | - rf'\g<1>sha256 "${{ steps.sha.outputs.sha256 }}"', |
50 | | - content, |
51 | | - count=1, |
52 | | - ) |
53 | | -
|
54 | | - with open("Formula/agent-pulse.rb", "w") as f: |
55 | | - f.write(content) |
56 | | - PYEOF |
57 | | -
|
58 | | - - name: Verify formula syntax |
59 | | - run: ruby -c Formula/agent-pulse.rb |
60 | | - |
61 | | - - name: Commit and push updated formula |
62 | 18 | run: | |
63 | | - git config user.name "github-actions[bot]" |
64 | | - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
65 | | - git add Formula/agent-pulse.rb |
66 | | - git diff --cached --quiet && echo "No changes to commit" && exit 0 |
67 | | - git commit -m "Update Homebrew formula for ${GITHUB_REF_NAME} |
| 19 | + TAG="${{ github.event.release.tag_name || inputs.tag }}" |
| 20 | + echo "tag=$TAG" >> "$GITHUB_OUTPUT" |
68 | 21 |
|
69 | | - Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>" |
70 | | - git push origin main |
| 22 | + - uses: mislav/bump-homebrew-formula-action@v3 |
| 23 | + with: |
| 24 | + formula-name: agent-pulse |
| 25 | + formula-path: Formula/agent-pulse.rb |
| 26 | + homebrew-tap: DUBSOpenHub/homebrew-copilot-cli-agent-pulse |
| 27 | + base-branch: main |
| 28 | + tag-name: ${{ steps.tag.outputs.tag }} |
| 29 | + download-url: https://github.com/${{ github.repository }}/archive/refs/tags/${{ steps.tag.outputs.tag }}.tar.gz |
| 30 | + commit-message: | |
| 31 | + agent-pulse {{version}} |
| 32 | +
|
| 33 | + Created by https://github.com/mislav/bump-homebrew-formula-action |
| 34 | +
|
| 35 | + Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> |
| 36 | + env: |
| 37 | + COMMITTER_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }} |
0 commit comments