You've already forked homebrew-objdiff
Initial commit
This commit is contained in:
88
.gitea/workflows/update-formula.yml
Normal file
88
.gitea/workflows/update-formula.yml
Normal file
@@ -0,0 +1,88 @@
|
||||
name: Update Formulas
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 6 * * *'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
update:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout tap
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Check for new release
|
||||
id: check
|
||||
shell: bash
|
||||
run: |
|
||||
RELEASE=$(curl -sf \
|
||||
-H "Accept: application/vnd.github+json" \
|
||||
https://api.github.com/repos/encounter/objdiff/releases/latest)
|
||||
|
||||
VERSION=$(echo "$RELEASE" | jq -r '.tag_name' | sed 's/^v//')
|
||||
CURRENT=$(grep 'version "' Formula/objdiff-cli.rb | head -1 | sed 's/.*version "\([^"]*\)".*/\1/')
|
||||
|
||||
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
||||
echo "current=$CURRENT" >> "$GITHUB_OUTPUT"
|
||||
|
||||
if [ "$VERSION" = "$CURRENT" ]; then
|
||||
echo "changed=false" >> "$GITHUB_OUTPUT"
|
||||
echo "Already on $VERSION, nothing to do."
|
||||
else
|
||||
echo "changed=true" >> "$GITHUB_OUTPUT"
|
||||
echo "Updating $CURRENT -> $VERSION"
|
||||
echo "$RELEASE" > /tmp/release.json
|
||||
fi
|
||||
|
||||
- name: Update formulas
|
||||
if: steps.check.outputs.changed == 'true'
|
||||
run: |
|
||||
VERSION="${{ steps.check.outputs.version }}"
|
||||
|
||||
# Pull sha256 from the digest field GitHub already provides in the API —
|
||||
# no need to download any binaries.
|
||||
extract_sha() {
|
||||
jq -r --arg name "\$1" \
|
||||
'.assets[] | select(.name == $name) | .digest | ltrimstr("sha256:")' \
|
||||
/tmp/release.json
|
||||
}
|
||||
|
||||
# Replace sha256 line identified by the trailing comment (the binary name).
|
||||
update_sha() {
|
||||
local file="\$1" name="\$2"
|
||||
local sha
|
||||
sha=$$(extract_sha "$$name")
|
||||
sed -i "s|sha256 \"[a-f0-9]*\" # $$name|sha256 \"$$sha\" # $$name|" "$$file"
|
||||
}
|
||||
|
||||
# Bump version in both formulas (url lines use #{version} interpolation,
|
||||
# so they update automatically)
|
||||
sed -i "s|version \"[^\"]*\"|version \"$VERSION\"|" Formula/objdiff-cli.rb
|
||||
sed -i "s|version \"[^\"]*\"|version \"$VERSION\"|" Formula/objdiff.rb
|
||||
|
||||
# Update sha256s — CLI
|
||||
update_sha Formula/objdiff-cli.rb objdiff-cli-macos-arm64
|
||||
update_sha Formula/objdiff-cli.rb objdiff-cli-macos-x86_64
|
||||
update_sha Formula/objdiff-cli.rb objdiff-cli-linux-aarch64
|
||||
update_sha Formula/objdiff-cli.rb objdiff-cli-linux-x86_64
|
||||
|
||||
# Update sha256s — GUI
|
||||
update_sha Formula/objdiff.rb objdiff-macos-arm64
|
||||
update_sha Formula/objdiff.rb objdiff-macos-x86_64
|
||||
update_sha Formula/objdiff.rb objdiff-linux-x86_64
|
||||
|
||||
- name: Commit and push
|
||||
if: steps.check.outputs.changed == 'true'
|
||||
env:
|
||||
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
git config user.name "gitea-actions[bot]"
|
||||
git config user.email "gitea-actions[bot]@noreply"
|
||||
# Re-point origin to include the token so push is authenticated.
|
||||
# GITHUB_SERVER_URL in Gitea Actions is your instance URL.
|
||||
git remote set-url origin \
|
||||
"https://x-access-token:$${TOKEN}@$${GITHUB_SERVER_URL#https://}/${GITHUB_REPOSITORY}.git"
|
||||
git add Formula/
|
||||
git commit -m "chore: bump objdiff to v${{ steps.check.outputs.version }}"
|
||||
git push
|
||||
Reference in New Issue
Block a user