Files
homebrew-software/.github/workflows/bump-xswitcher.yml
2025-06-19 17:00:28 -04:00

62 lines
2.0 KiB
YAML

name: Bump XSwitcher
on:
workflow_dispatch: # manual trigger
schedule:
- cron: '0 * * * *' # hourly check
repository_dispatch:
types: [release]
jobs:
bump-formula:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Setup Ruby (for Homebrew)
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1
- name: Install dependencies
run: gem install --no-document toml-rb
- name: Fetch latest release info
id: release
uses: actions/github-script@v6
with:
script: |
const { data: release } = await github.rest.repos.getLatestRelease({
owner: 'darwincereska',
repo: 'xswitcher'
})
return release
- name: Calculate SHA256 of tarball
id: sha256
run: |
curl -L -o release.tar.gz ${{ steps.release.outputs.data.tarball_url }}
sha256sum release.tar.gz | awk '{ print $1 }' > sha256.txt
echo "::set-output name=hash::$(cat sha256.txt)"
- name: Update formula file
run: |
VERSION=${{ steps.release.outputs.data.tag_name }}
SHA256=${{ steps.sha256.outputs.hash }}
FORMULA_FILE=Formula/xswitcher.rb
# Replace url and sha256 in the formula
sed -i "s|url \".*\"|url \"https://github.com/darwincereska/xswitcher/archive/refs/tags/${VERSION}.tar.gz\"|g" $FORMULA_FILE
sed -i "s/sha256 \".*\"/sha256 \"${SHA256}\"/g" $FORMULA_FILE
sed -i "s/version \".*\"/version \"${VERSION#v}\"/g" $FORMULA_FILE || echo "No version line to update"
- name: Commit and push changes
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Formula/xswitcher.rb
git commit -m "Bump xswitcher to $VERSION" || echo "No changes to commit"
git push origin HEAD:main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}