Update Wox Cask #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_VERSION}/${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_VERSION}/${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 "[email protected]" | |
git config --local user.name "GitHub Action" | |
git add Casks/wox.rb | |
git commit -m "$COMMIT_MSG" | |
git push |