Skip to content

Commit

Permalink
ci: implement update homebrew formula job
Browse files Browse the repository at this point in the history
  • Loading branch information
fbozic committed Jan 20, 2025
1 parent 26c7f81 commit 355b3ae
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 1 deletion.
76 changes: 76 additions & 0 deletions .github/workflows/fb-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: FB Test

on:
push:
branches:
- ci/homebrew-formula-generate

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- name: Set matrix output
uses: cloudposse/github-action-matrix-outputs-write@v1
id: out
with:
matrix-step-name: build-result
matrix-key: ${{ matrix.os }}
outputs: |-
releaseRequire: true
version: 0.3.0
trigger_brew_update:
needs: build
runs-on: ubuntu-latest
steps:
- id: get-matrix-outputs
uses: cloudposse/github-action-matrix-outputs-read@v1
with:
matrix-step-name: build-result
- name: Debug
run: echo ${{ steps.get-matrix-outputs.outputs.result }}
- name: Create GitHub App Token
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.GH_APP_ID }}
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
repositories: |
homebrew-tap
- name: Get GitHub App User ID
id: get-user-id
run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
- name: Configure Git
run: |
git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]'
git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com'
- name: Checkout homebrew-tap
uses: actions/checkout@v4
with:
repository: ${{ github.repository_owner }}/homebrew-tap
token: ${{ steps.app-token.outputs.token }}
persist-credentials: false
- name: Update Formula
run: |
# Read the JSON array from the file
json_array='["ubuntu-latest", "macos-latest"]'
for matrix_key in $(echo "${json_array}" | jq -r '.[]'); do
release_required=$(echo '${{ steps.get-matrix-outputs.outputs.result }}' | jq -r '.releaseRequired["'"${matrix_key}"'"]')
version=$(echo '${{ steps.get-matrix-outputs.outputs.result }}' | jq -r '.version["'"${matrix_key}"'"]')
if [ "${release_required}" == "true" ]; then
echo "Release is required for ${matrix_key}. Version: ${version}"
else
echo "Release is not required for ${matrix_key}."
fi
done
echo "Updating formula"
cat generate-formula.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Rust binaries release
name: Release

on:
push:
Expand Down

0 comments on commit 355b3ae

Please sign in to comment.