From 96b816d96de5d3c2f96007de2930f7a24582c5ae Mon Sep 17 00:00:00 2001 From: Darwin Cereska Date: Thu, 19 Jun 2025 17:15:34 -0400 Subject: [PATCH] asrtar --- .github/workflows/bump-ttymer.yml | 73 +++++++++++----------------- .github/workflows/bump-xswitcher.yml | 73 +++++++++++----------------- 2 files changed, 56 insertions(+), 90 deletions(-) diff --git a/.github/workflows/bump-ttymer.yml b/.github/workflows/bump-ttymer.yml index d7f69c9..5c45010 100644 --- a/.github/workflows/bump-ttymer.yml +++ b/.github/workflows/bump-ttymer.yml @@ -1,69 +1,51 @@ -name: Bump TTYmer +name: Bump TTYmer Formula on: - workflow_dispatch: # manual trigger + workflow_dispatch: schedule: - - cron: '0 * * * *' # hourly check - repository_dispatch: - types: [release] + - cron: '0 * * * *' jobs: - bump-formula: + bump: runs-on: ubuntu-latest + steps: - - name: Checkout repo + - name: Checkout tap 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 + - name: Fetch latest release from GitHub + id: fetch uses: actions/github-script@v6 with: - result-encoding: string + result-encoding: json script: | const release = await github.rest.repos.getLatestRelease({ owner: 'darwincereska', repo: 'ttymer' }); - return release.data.tarball_url; + return { + version: release.data.tag_name, + url: release.data.tarball_url + }; - - name: Calculate SHA256 of tarball - id: sha256 + - name: Download tarball and compute SHA256 + id: compute run: | - curl -L -o release.tar.gz "${{ steps.release.outputs.result }}" - SHA256=$(sha256sum release.tar.gz | awk '{ print $1 }') - echo "hash=$SHA256" >> $GITHUB_OUTPUT + curl -L -o ttymer.tar.gz "${{ steps.fetch.outputs.url }}" + SHA256=$(sha256sum ttymer.tar.gz | awk '{ print $1 }') + echo "sha256=$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 + - name: Update Formula run: | - VERSION=${{ steps.version.outputs.result }} - SHA256=${{ steps.sha256.outputs.hash }} - FORMULA_FILE=Formula/ttymer.rb + VERSION=${{ steps.fetch.outputs.version }} + SHA256=${{ steps.compute.outputs.sha256 }} + FORMULA=Formula/ttymer.rb - echo "Updating formula to version $VERSION with sha256 $SHA256" + echo "Updating $FORMULA to version $VERSION" - 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" + sed -i "s|url \".*\"|url \"https://github.com/darwincereska/ttymer/archive/refs/tags/${VERSION}.tar.gz\"|g" "$FORMULA" + 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: @@ -73,7 +55,8 @@ jobs: 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 }}" + VERSION=${{ steps.fetch.outputs.version }} + git commit -m "Auto-update ttymer to $VERSION" git push else echo "No changes to commit" diff --git a/.github/workflows/bump-xswitcher.yml b/.github/workflows/bump-xswitcher.yml index 69ca52e..0740ffa 100644 --- a/.github/workflows/bump-xswitcher.yml +++ b/.github/workflows/bump-xswitcher.yml @@ -1,69 +1,51 @@ -name: Bump XSwitcher +name: Bump XSwitcher Formula on: - workflow_dispatch: # manual trigger + workflow_dispatch: schedule: - - cron: '0 * * * *' # hourly check - repository_dispatch: - types: [release] + - cron: '0 * * * *' jobs: - bump-formula: + bump: runs-on: ubuntu-latest + steps: - - name: Checkout repo + - name: Checkout tap 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 + - name: Fetch latest release from GitHub + id: fetch uses: actions/github-script@v6 with: - result-encoding: string + result-encoding: json script: | const release = await github.rest.repos.getLatestRelease({ owner: 'darwincereska', repo: 'xswitcher' }); - return release.data.tarball_url; + return { + version: release.data.tag_name, + url: release.data.tarball_url + }; - - name: Calculate SHA256 of tarball - id: sha256 + - name: Download tarball and compute SHA256 + id: compute run: | - curl -L -o release.tar.gz "${{ steps.release.outputs.result }}" - SHA256=$(sha256sum release.tar.gz | awk '{ print $1 }') - echo "hash=$SHA256" >> $GITHUB_OUTPUT + curl -L -o xswitcher.tar.gz "${{ steps.fetch.outputs.url }}" + SHA256=$(sha256sum xswitcher.tar.gz | awk '{ print $1 }') + echo "sha256=$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: 'xswitcher' - }); - return release.data.tag_name; - - - name: Update formula file + - name: Update Formula run: | - VERSION=${{ steps.version.outputs.result }} - SHA256=${{ steps.sha256.outputs.hash }} - FORMULA_FILE=Formula/xswitcher.rb + VERSION=${{ steps.fetch.outputs.version }} + SHA256=${{ steps.compute.outputs.sha256 }} + FORMULA=Formula/xswitcher.rb - echo "Updating formula to version $VERSION with sha256 $SHA256" + echo "Updating $FORMULA to version $VERSION" - 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" + sed -i "s|url \".*\"|url \"https://github.com/darwincereska/xswitcher/archive/refs/tags/${VERSION}.tar.gz\"|g" "$FORMULA" + 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: @@ -73,7 +55,8 @@ jobs: git config user.email "actions@github.com" git add Formula/xswitcher.rb if ! git diff --cached --quiet; then - git commit -m "Auto-update to build ${{ steps.version.outputs.result }}" + VERSION=${{ steps.fetch.outputs.version }} + git commit -m "Auto-update xswitcher to $VERSION" git push else echo "No changes to commit"