brew formula update #33
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: brew formula update | |
on: | |
repository_dispatch: | |
types: [brew-formula-update] | |
workflow_dispatch: | |
inputs: | |
tag_prefix: | |
description: "Prefix for the release tag to pull from (i.e. wash-cli)" | |
default: "wash-cli" | |
required: false | |
type: string | |
tag_version: | |
description: "Tag to pull" | |
required: true | |
type: string | |
jobs: | |
update-release: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
# This is needed by Goreleaser to build the placeholder Go binary. | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: 1.21 | |
- name: Set Variables | |
if: github.event_name == 'workflow_dispatch' | |
run: | | |
echo "input_tag=${{ github.event.inputs.tag_version }}" >> "$GITHUB_ENV" | |
echo "input_prefix=${{ github.event.inputs.tag_prefix }}" >> "$GITHUB_ENV" | |
- name: Set Variables | |
if: github.event_name == 'repository_dispatch' | |
run: | | |
echo "input_tag=${{ github.event.client_payload.tag_version }}" >> "$GITHUB_ENV" | |
echo "input_prefix=${{ github.event.client_payload.tag_prefix }}" >> "$GITHUB_ENV" | |
- name: Normalize inputs for pipeline use | |
uses: actions/github-script@v7 | |
id: normalize_inputs | |
env: | |
input_tag: ${{ env.input_tag }} | |
input_prefix: ${{ env.input_prefix }} | |
with: | |
script: | | |
const { input_tag, input_prefix } = process.env | |
const tag_no_v = input_tag.replaceAll('v', '') | |
const tag_with_v = 'v' + tag_no_v | |
const prefix = input_prefix.replace(/^-+/g, '').replace(/-+$/g, '') | |
const release_name = prefix + '-' + tag_with_v | |
core.setOutput('tag_no_v', tag_no_v) | |
core.setOutput('tag_with_v', tag_with_v) | |
core.setOutput('release_name', release_name) | |
- name: Download release artifacts | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
gh -R wasmcloud/wasmcloud release download ${{ steps.normalize_inputs.outputs.release_name }} -D tmp/ -p '*apple-darwin*' -p '*unknown-linux*' | |
- name: Setup placeholder files for Goreleaser | |
shell: bash | |
run: | | |
cat <<EOF > tmp/main.go | |
package main | |
func main() {} | |
EOF | |
- name: Run Goreleaser | |
uses: goreleaser/goreleaser-action@v5 | |
with: | |
distribution: goreleaser | |
version: latest | |
args: release --clean --skip validate | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
RELEASE_NAME: ${{ steps.normalize_inputs.outputs.release_name }} | |
GORELEASER_CURRENT_TAG: ${{ steps.normalize_inputs.outputs.tag_no_v }} | |
- name: Copy the new Formula over | |
run: | | |
cp dist/homebrew/Formula/wash.rb Formula/wash.rb | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@v6 | |
with: | |
commit-message: bump wash to ${{ steps.normalize_inputs.outputs.tag_with_v }} | |
title: wash ${{ steps.normalize_inputs.outputs.tag_with_v }} | |
body: This is the release of wash ${{ steps.normalize_inputs.outputs.tag_with_v }}. Once tests pass properly, add the `pr-pull` label to this PR to release. | |
branch: release/${{ steps.normalize_inputs.outputs.release_name }} | |
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> | |
committer: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> | |
signoff: true |