-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change wash Formula update workflow to use Goreleaser
Signed-off-by: Joonas Bergius <joonas@cosmonic.com>
- Loading branch information
1 parent
5fb317d
commit af5139e
Showing
4 changed files
with
138 additions
and
13 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,82 @@ | ||
name: brew formula update | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
wash_version: | ||
description: "Version of wash, without the `v`, to release to homebrew" | ||
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 | ||
default: "0.18.0" | ||
type: string | ||
|
||
jobs: | ||
update-release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Prepare Formula | ||
- 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: Normalize inputs for pipeline use | ||
uses: actions/github-script@v7 | ||
id: normalize_inputs | ||
with: | ||
script: | | ||
const input_tag = context.payload.inputs.tag_version | ||
const input_prefix = context.payload.inputs.tag_prefix | ||
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: | ||
WASMCLOUD_URL: https://github.com/wasmCloud/wash/archive/v${{ inputs.wash_version }}.tar.gz | ||
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: | | ||
mkdir tmp | ||
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: | | ||
wasmcloud_url=$WASMCLOUD_URL | ||
wasmcloud_sha=$(curl -sL $WASMCLOUD_URL | shasum -a 256 | cut -d ' ' -f 1) | ||
cp dist/homebrew/Formula/wash.rb Formula/wash.rb | ||
cat ./template/wash.txt | sed "s|WASMCLOUD_URL|$wasmcloud_url|" | sed "s|WASMCLOUD_SHA|$wasmcloud_sha|" > Formula/wash.rb | ||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v5 | ||
with: | ||
commit-message: bump wash to v${{ inputs.wash_version }} | ||
title: wash v${{ inputs.wash_version }} | ||
body: This is the release of wash v${{ inputs.wash_version }}. Once tests pass properly, add the `pr-pull` label to this PR to release. | ||
branch: release/v${{ inputs.wash_version }} | ||
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 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Goreleaser output directory | ||
dist/ | ||
# Temporary files for update pipeline | ||
tmp/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
project_name: wash | ||
|
||
builds: | ||
- main: tmp/main.go | ||
goos: | ||
- linux | ||
- darwin | ||
goarch: | ||
- amd64 | ||
- arm64 | ||
binary: wash | ||
hooks: | ||
post: | ||
- ./.goreleaser_hook.sh {{ .Arch }} {{ .Os }} {{ .Path }} | ||
|
||
archives: | ||
- format: binary | ||
|
||
brews: | ||
- name: wash | ||
goamd64: v1 | ||
url_template: https://github.com/wasmCloud/wasmCloud/releases/download/{{ indexOrDefault .Env "RELEASE_NAME" "" }}/{{ .Binary }}-{{ if eq .Arch "arm64" }}aarch64{{ else }}x86_64{{ end }}-{{ if eq .Os "darwin" }}apple-darwin{{ else }}unknown-linux-musl{{ end }} | ||
license: "Apache-2.0" | ||
folder: Formula | ||
homepage: "https://wasmcloud.com/" | ||
description: "WAsmcloud SHell - a comprehensive command-line tool for wasmCloud development" | ||
skip_upload: true | ||
test: | | ||
system "#{bin}/wash", "-V" | ||
install: | | ||
bin.install "{{ .Binary }}-{{ if eq .Arch "arm64" }}aarch64{{ else }}x86_64{{ end }}-{{ if eq .Os "darwin" }}apple-darwin{{ else }}unknown-linux-musl{{ end }}" => "{{ .Binary }}" | ||
repository: | ||
owner: wasmCloud | ||
name: homebrew-wasmcloud | ||
|
||
checksum: | ||
name_template: "checksums.txt" | ||
|
||
changelog: | ||
skip: true | ||
|
||
release: | ||
disable: true |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env bash | ||
|
||
go_arch=$1 | ||
go_os=$2 | ||
output_path=$3 | ||
|
||
# Make Go -> Rust arch/os mapping | ||
case $go_arch in | ||
amd64) rust_arch='x86_64' ;; | ||
arm64) rust_arch='aarch64' ;; | ||
*) echo "unknown arch: $go_arch" && exit 1 ;; | ||
esac | ||
case $go_os in | ||
linux) rust_os='unknown-linux-musl' ;; | ||
darwin) rust_os='apple-darwin' ;; | ||
windows) rust_os='windows' ;; | ||
*) echo "unknown os: $go_os" && exit 1 ;; | ||
esac | ||
|
||
# This deletes the output path before we attempt to place the Rust binaries there, | ||
# so that in the case we fail to download or `find` the Rust binaries below, the | ||
# pipeline will fail and we can investigate. | ||
rm "${output_path}" | ||
# Find the artifacts in tmp/ and move them over to dist/ where the Go binaries would be. | ||
find tmp -type f -name "*${rust_arch}-${rust_os}*" -exec mv {} "${output_path}" \; |