diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 63efd44..f59594b 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -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 "runner@example.com" + 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 }} diff --git a/update_cask.rb b/update_cask.rb new file mode 100644 index 0000000..1f380c0 --- /dev/null +++ b/update_cask.rb @@ -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 \ No newline at end of file