mirror of
https://github.com/darwincereska/homebrew-software.git
synced 2026-02-12 12:04:42 -05:00
64 lines
2.0 KiB
YAML
64 lines
2.0 KiB
YAML
name: Bump xswitcher Formula
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
schedule:
|
|
- cron: '0 * * * *' # every hour
|
|
|
|
jobs:
|
|
bump:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout tap repo
|
|
uses: actions/checkout@v3
|
|
with:
|
|
persist-credentials: true
|
|
|
|
- name: Fetch latest release tag from GitHub
|
|
id: fetch
|
|
uses: actions/github-script@v6
|
|
with:
|
|
script: |
|
|
const release = await github.rest.repos.getLatestRelease({
|
|
owner: 'darwincereska',
|
|
repo: 'xswitcher'
|
|
});
|
|
core.setOutput("version", release.data.tag_name);
|
|
|
|
- name: Download archive from refs/tags and compute SHA256
|
|
id: compute
|
|
run: |
|
|
VERSION=${{ steps.fetch.outputs.version }}
|
|
ARCHIVE_URL="https://github.com/darwincereska/xswitcher/archive/refs/tags/${VERSION}.tar.gz"
|
|
echo "Downloading archive: $ARCHIVE_URL"
|
|
curl -L -o xswitcher.tar.gz "$ARCHIVE_URL"
|
|
SHA256=$(sha256sum xswitcher.tar.gz | awk '{ print $1 }')
|
|
echo "sha256=$SHA256" >> $GITHUB_OUTPUT
|
|
|
|
- name: Update Formula (version & sha256 only)
|
|
run: |
|
|
VERSION=${{ steps.fetch.outputs.version }}
|
|
SHA256=${{ steps.compute.outputs.sha256 }}
|
|
FORMULA=Formula/xswitcher.rb
|
|
|
|
echo "Updating $FORMULA to version $VERSION"
|
|
|
|
sed -i "s/sha256 \".*\"/sha256 \"$SHA256\"/g" "$FORMULA"
|
|
sed -i "s/version \".*\"/version \"${VERSION#v}\"/g" "$FORMULA" || echo "No version field to replace"
|
|
|
|
- name: Commit and push if changed
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
git config user.name "GitHub Actions"
|
|
git config user.email "actions@github.com"
|
|
git add Formula/xswitcher.rb
|
|
if ! git diff --cached --quiet; then
|
|
VERSION=${{ steps.fetch.outputs.version }}
|
|
git commit -m "bump: Updated xswitcher to $VERSION"
|
|
git push
|
|
else
|
|
echo "No changes to commit"
|
|
fi
|