init: added workflows for auto bump

This commit is contained in:
Darwin Cereska
2025-06-19 17:00:28 -04:00
parent 685588b28a
commit f3e11be100
2 changed files with 122 additions and 0 deletions

61
.github/workflows/bump-ttymer.yml vendored Normal file
View File

@@ -0,0 +1,61 @@
name: Bump TTYmer
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: 'ttymer'
})
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/ttymer.rb
# Replace url and sha256 in the formula
sed -i "s|url \".*\"|url \"https://github.com/darwincereska/ttymer/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/ttymer.rb
git commit -m "Bump ttymer to $VERSION" || echo "No changes to commit"
git push origin HEAD:main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}