|
| 1 | +name: "Update Homewbrew Cask" |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + types: closed |
| 8 | + workflow_dispatch: |
| 9 | + inputs: |
| 10 | + ref: |
| 11 | + description: 'Commit SHA to build' |
| 12 | + required: true |
| 13 | + default: 'main' |
| 14 | + type: string |
| 15 | + |
| 16 | +jobs: |
| 17 | + build-and-update: |
| 18 | + if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch' |
| 19 | + runs-on: ubuntu-22.04 |
| 20 | + steps: |
| 21 | + - id: checkout-ref |
| 22 | + run: | |
| 23 | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then |
| 24 | + echo "ref=${{ github.event.inputs.ref }}" >> $GITHUB_OUTPUT |
| 25 | + else |
| 26 | + echo "ref=${{ github.event.pull_request.merge_commit_sha }}" >> $GITHUB_OUTPUT |
| 27 | + fi |
| 28 | + - uses: actions/checkout@v4 |
| 29 | + with: |
| 30 | + ref: ${{ steps.checkout-ref.outputs.ref }} |
| 31 | + fetch-depth: 0 |
| 32 | + - uses: actions/setup-go@v5 |
| 33 | + with: |
| 34 | + go-version-file: go.mod |
| 35 | + - uses: goreleaser/goreleaser-action@v6 |
| 36 | + with: |
| 37 | + args: release --snapshot --clean |
| 38 | + - uses: aws-actions/configure-aws-credentials@v5 |
| 39 | + with: |
| 40 | + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 41 | + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 42 | + aws-region: us-east-2 |
| 43 | + - run: | |
| 44 | + sha_hash=${{ steps.checkout-ref.outputs.ref }} |
| 45 | + short_hash=${sha_hash:0:9} |
| 46 | + for artifact in dist/super-${short_hash}*; do aws s3 cp $artifact s3://super-prereleases/${short_hash}/ ; done |
| 47 | + - uses: actions/checkout@v4 |
| 48 | + with: |
| 49 | + repository: brimdata/homebrew-tap |
| 50 | + token: ${{ secrets.PAT_TOKEN }} |
| 51 | + path: homebrew-tap |
| 52 | + - run: | |
| 53 | + mkdir -p homebrew-tap/Casks |
| 54 | + cp dist/homebrew/Casks/super.rb homebrew-tap/Casks |
| 55 | + cd homebrew-tap |
| 56 | + git config --global user.name 'Brim Automation' |
| 57 | + git config --global user.email 'automation@brimdata.com' |
| 58 | + git add Casks/super.rb |
| 59 | + git commit -am "update super Homebrew Cask to ${{ steps.checkout-ref.outputs.ref }}" || true |
| 60 | + git push |
0 commit comments