mirror of
https://github.com/darwincereska/homebrew-software.git
synced 2026-02-12 04:04:41 -05:00
80 lines
2.5 KiB
YAML
80 lines
2.5 KiB
YAML
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 tarball URL
|
|
id: release
|
|
uses: actions/github-script@v6
|
|
with:
|
|
result-encoding: string
|
|
script: |
|
|
const release = await github.rest.repos.getLatestRelease({
|
|
owner: 'darwincereska',
|
|
repo: 'ttymer'
|
|
});
|
|
return release.data.tarball_url;
|
|
|
|
- name: Calculate SHA256 of tarball
|
|
id: sha256
|
|
run: |
|
|
curl -L -o release.tar.gz "${{ steps.release.outputs.result }}"
|
|
SHA256=$(sha256sum release.tar.gz | awk '{ print $1 }')
|
|
echo "hash=$SHA256" >> $GITHUB_OUTPUT
|
|
|
|
- name: Get release version
|
|
id: version
|
|
uses: actions/github-script@v6
|
|
with:
|
|
result-encoding: string
|
|
script: |
|
|
const release = await github.rest.repos.getLatestRelease({
|
|
owner: 'darwincereska',
|
|
repo: 'ttymer'
|
|
});
|
|
return release.data.tag_name;
|
|
|
|
- name: Update formula file
|
|
run: |
|
|
VERSION=${{ steps.version.outputs.result }}
|
|
SHA256=${{ steps.sha256.outputs.hash }}
|
|
FORMULA_FILE=Formula/ttymer.rb
|
|
|
|
echo "Updating formula to version $VERSION with sha256 $SHA256"
|
|
|
|
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 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/ttymer.rb
|
|
if ! git diff --cached --quiet; then
|
|
git commit -m "Auto-update to build ${{ steps.version.outputs.result }}"
|
|
git push
|
|
else
|
|
echo "No changes to commit"
|