Skip to content

Commit

Permalink
ci: Separate back out commit push so Homebrew's magic works
Browse files Browse the repository at this point in the history
  • Loading branch information
dbanty committed Jan 31, 2024
1 parent 342e873 commit 0c0ce23
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"customType": "regex",
"fileMatch": [
"^Formula/knope.rb$",
"^.github/workflows/test-and-build.yml$"
"^.github/workflows/update-formula.yml$"
],
"matchStrings": [
"https:\\/\\/github\\.com\\/knope-dev\\/knope\\/archive\\/refs\\/tags\\/v(?<currentValue>.*)\\.tar\\.gz",
Expand Down
37 changes: 1 addition & 36 deletions .github/workflows/test-and-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,11 @@ on:
- main
pull_request:
jobs:
update-sha:
runs-on: ubuntu-latest
outputs:
sha-changed: ${{ steps.check-sha.outputs.changed }}
steps:
- uses: actions/[email protected]
with:
ref: ${{ github.head_ref }}
- name: Download Knope Source
run: curl -o source.tgz https://codeload.github.com/knope-dev/knope/tar.gz/refs/tags/v0.13.0
- name: Get new SHA
run: echo "NEW_SHA=$(shasum -a 256 source.tgz | cut -d ' ' -f 1)" >> $GITHUB_ENV
- name: Update Formula
id: update-formula
run: sed -i "s#^ sha256 .*# sha256 \"${{ env.NEW_SHA }}\"#" Formula/knope.rb
- name: Check if SHA changed
id: check-sha
run: echo "changed=$(git diff --exit-code Formula/knope.rb > /dev/null && echo no || echo yes)" >> $GITHUB_OUTPUT
- name: Commit back new SHA if it changed
if: steps.check-sha.outputs.changed == 'yes'
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add Formula/knope.rb
git commit -m "Update SHA to ${{ env.NEW_SHA }}"
git push
- name: Save formula as artifact
uses: actions/upload-artifact@v3
with:
name: formula
path: Formula/knope.rb

test-formula-and-build-bottles:
strategy:
matrix:
os: [ubuntu-latest, macos-13, macos-14]
runs-on: ${{ matrix.os }}
needs:
- update-sha
steps:
- name: Set up Homebrew
id: set-up-homebrew
Expand Down Expand Up @@ -82,9 +48,8 @@ jobs:
publish-bottles:
needs:
- test-formula-and-build-bottles
- update-sha
runs-on: ubuntu-latest
if: needs.update-sha.outputs.sha-changed == 'yes'
if: contains(github.event.pull_request.labels.*.name, 'pr-pull')
permissions:
contents: write
packages: none
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/update-formula.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Update Formula
on:
pull_request:
paths:
- .github/workflows/update-formula.yml
jobs:
update-sha:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
token: ${{ secrets.PAT }}
- name: Download Knope Source
run: curl -o source.tgz https://codeload.github.com/knope-dev/knope/tar.gz/refs/tags/v0.13.0
- name: Get new SHA
run: echo "NEW_SHA=$(shasum -a 256 source.tgz | cut -d ' ' -f 1)" >> $GITHUB_ENV
- name: Update Formula
id: update-formula
run: sed -i "s#^ sha256 .*# sha256 \"${{ env.NEW_SHA }}\"#" Formula/knope.rb
- name: Check if SHA changed
id: check-sha
run: echo "changed=$(git diff --exit-code Formula/knope.rb > /dev/null && echo no || echo yes)" >> $GITHUB_OUTPUT
- name: Commit back new SHA if it changed
if: steps.check-sha.outputs.changed == 'yes'
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add Formula/knope.rb
git commit -m "Update SHA to ${{ env.NEW_SHA }}"
git push
- name: Label PR to trigger release
if: steps.check-sha.outputs.changed == 'yes'
run: gh pr edit ${{ github.event.number }} --add-label "pr-pull"

0 comments on commit 0c0ce23

Please sign in to comment.