Skip to content

Commit

Permalink
Configure cask update
Browse files Browse the repository at this point in the history
  • Loading branch information
Reeywhaar committed Sep 5, 2023
1 parent a2e3694 commit 43b89a8
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,53 @@ jobs:
- name: "Notarize app"
run: xcrun notarytool submit MiddleMe.zip --keychain-profile notarytool --wait

- name: "Create cask env"
run: |
SHA=$(shasum -a 256 -sha256 MiddleMe.zip | awk '{print $1}') && \
echo "ARTEFACT_SHA256=$(echo $SHA)" >> cask.env && \
VERSION=$(sed -n '/MARKETING_VERSION/{s/MARKETING_VERSION = //;s/;//;s/^[[:space:]]*//;p;q;}' ./MiddleMe.xcodeproj/project.pbxproj) && \
echo "ARTEFACT_VERSION=$(echo $VERSION)" >> cask.env
- uses: actions/upload-artifact@v3
with:
name: cask.env
path: cask.env

- name: "Create Release"
uses: softprops/action-gh-release@78c309ef59fdb9557cd6574f2e0be552936ed728
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: MiddleMe.zip
bump_homebrew:
name: Bump homebrew cask
runs-on: ubuntu-latest
needs: release
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v3
with:
name: cask.env
- name: Set git identity
run: |
git config --global user.email "[email protected]"
git config --global user.name "runner"
- name: Load cask env
run: |
cat cask.env >> $GITHUB_ENV
- uses: actions/checkout@v2
with:
ref: main
path: tap
repository: "reeywhaar/homebrew-tap"
token: ${{ secrets.TAP_REPO_TOKEN }}
- name: Update formula
run: ruby update_cask.rb tap/Casks/middleme.rb $ARTEFACT_VERSION $ARTEFACT_SHA256
- name: Commit
run: git add . && git commit -m "MiddleMe $ARTEFACT_VERSION"
working-directory: tap
- name: Push
run: git push origin main
working-directory: tap
env:
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.TAP_REPO_TOKEN }}
16 changes: 16 additions & 0 deletions update_cask.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
def main
file = ARGV[0]
version = ARGV[1]
sha = ARGV[2]

content = File.read(file)
content = content.gsub(/# version-placeholder\n.*$/, "# version-placeholder\n version \"#{version}\"")
content = content.gsub(/# sha256-placeholder\n.*$/, "# sha256-placeholder\n sha256 \"#{sha}\"")
content = content.gsub(/^\s+revision.*$/, "")

File.open(file, "w") do |f|
f.write(content)
end
end

main

0 comments on commit 43b89a8

Please sign in to comment.