Skip to content

Commit 53002fc

Browse files
add workflow to update formula on new release automatically
VCMI repo would send Repository Dispatch Event whenever new release is published
1 parent 824a047 commit 53002fc

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

.github/workflows/vcmi-release.yml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Update with new release
2+
on:
3+
repository_dispatch:
4+
types: [on-release]
5+
permissions:
6+
contents: write
7+
jobs:
8+
update-formula:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: find URLs of macOS assets
12+
shell: python
13+
run: |
14+
import json
15+
envFile = open('${{ github.env }}', 'a')
16+
release = json.loads('''${{ toJSON(github.event.client_payload.release) }}''')
17+
for asset in release['assets']:
18+
artifactName = asset['name']
19+
if 'macOS-intel' in artifactName:
20+
envFile.write(f"INTEL_URL={asset['browser_download_url']}\n")
21+
elif 'macOS-arm' in artifactName:
22+
envFile.write(f"ARM_URL={asset['browser_download_url']}\n")
23+
24+
- uses: actions/checkout@v4
25+
- name: update formula with new version and asset hashes
26+
run: |
27+
tag="${{ github.event.client_payload.release.tag_name }}"
28+
intelHash=$(curl -L "$INTEL_URL" | sha256sum | cut -d ' ' -f 1)
29+
armHash=$( curl -L "$ARM_URL" | sha256sum | cut -d ' ' -f 1)
30+
sed -E -i \
31+
-e "s/version \".+/version \"$tag\"/" \
32+
-e "s/intel: \"\\w+\"/intel: \"$intelHash\"/" \
33+
-e "s/arm: \"\\w+\"/arm: \"$armHash\"/" \
34+
Casks/vcmi.rb
35+
36+
git config user.name "github-actions[bot]"
37+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
38+
git add .
39+
git commit -m "$tag"
40+
git push

0 commit comments

Comments
 (0)