-
Notifications
You must be signed in to change notification settings - Fork 0
41 lines (33 loc) · 1.98 KB
/
update_cask.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
name: Update Wox Cask
on:
workflow_dispatch: # only dispatch manually
jobs:
update_cask:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: Update cask
run: |
LATEST_RELEASE_VERSION=$(curl --silent "https://api.github.com/repos/wox-launcher/wox/releases/latest" | grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/')
echo "Latest version: $LATEST_RELEASE_VERSION"
LATEST_AMD64_FILENAME=$(curl --silent "https://api.github.com/repos/wox-launcher/wox/releases/latest" | grep 'mac-amd64' | sed -n 's/.*"name": "\(.*\)".*/\1/p')
LATEST_AMD64_SHA=$(curl -sL "https://github.com/wox-launcher/wox/releases/download/v${LATEST_RELEASE}/${LATEST_AMD64_FILENAME}" | sha256sum | cut -f 1 -d " ")
echo "Latest amd64 SHA: $LATEST_AMD64_SHA"
LATEST_ARM64_FILENAME=$(curl --silent "https://api.github.com/repos/wox-launcher/wox/releases/latest" | grep 'mac-arm64' | sed -n 's/.*"name": "\(.*\)".*/\1/p')
LATEST_ARM64_SHA=$(curl -sL "https://github.com/wox-launcher/wox/releases/download/v${LATEST_RELEASE}/${LATEST_ARM64_FILENAME}" | sha256sum | cut -f 1 -d " ")
echo "Latest arm64 SHA: $LATEST_ARM64_SHA"
sed -i "s/version .*/version \"v${LATEST_RELEASE_VERSION}\"/" Casks/wox.rb
sed -i "/on_arm do/,/end/ s/sha256 .*/sha256 \"${LATEST_ARM64_SHA}\"/" Casks/wox.rb
sed -i "/on_intel do/,/end/ s/sha256 .*/sha256 \"${LATEST_AMD64_SHA}\"/" Casks/wox.rb
echo "LATEST_RELEASE_VERSION=$LATEST_RELEASE_VERSION" >> $GITHUB_ENV
- name: Commit and push changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
COMMIT_MSG="Update Wox cask to v${{ env.LATEST_RELEASE_VERSION }}"
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add Casks/wox.rb
git commit -m "$COMMIT_MSG"
git push