From f3e11be100c279d8c4e360165f70c0a691d4876e Mon Sep 17 00:00:00 2001 From: Darwin Cereska Date: Thu, 19 Jun 2025 17:00:28 -0400 Subject: [PATCH] init: added workflows for auto bump --- .github/workflows/bump-ttymer.yml | 61 ++++++++++++++++++++++++++++ .github/workflows/bump-xswitcher.yml | 61 ++++++++++++++++++++++++++++ 2 files changed, 122 insertions(+) create mode 100644 .github/workflows/bump-ttymer.yml create mode 100644 .github/workflows/bump-xswitcher.yml diff --git a/.github/workflows/bump-ttymer.yml b/.github/workflows/bump-ttymer.yml new file mode 100644 index 0000000..3b35193 --- /dev/null +++ b/.github/workflows/bump-ttymer.yml @@ -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 }} diff --git a/.github/workflows/bump-xswitcher.yml b/.github/workflows/bump-xswitcher.yml new file mode 100644 index 0000000..f634d0d --- /dev/null +++ b/.github/workflows/bump-xswitcher.yml @@ -0,0 +1,61 @@ +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 }}