Closed atc0005 closed 1 year ago
Found this existing workflow that appears to be a fantastic starting point:
https://github.com/trntv/wilson/blob/master/.github/workflows/release.yml
name: Release
on: [create]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.13
uses: actions/setup-go@v1
with:
go-version: 1.13
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: Cache Go modules
uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build
run: |
GOOS=darwin GOARCH=amd64 go build -o bin/wilson_darwin_amd64 github.com/trntv/wilson/cmd/wilson
GOOS=linux GOARCH=amd64 go build -o bin/wilson_linux_amd64 github.com/trntv/wilson/cmd/wilson
GOOS=windows GOARCH=amd64 go build -o bin/wilson_windows_amd64 github.com/trntv/wilson/cmd/wilson
tar cvf - bin/wilson_darwin_amd64 | gzip -n > bin/wilson-darwin-amd64.tar.gz
tar cvf - bin/wilson_linux_amd64 | gzip -n > bin/wilson-linux-amd64.tar.gz
tar cvf - bin/wilson_windows_amd64 | gzip -n > bin/wilson-windows-amd64.tar.gz
sha256sum bin/wilson-darwin-amd64.tar.gz >> bin/checksums.txt
sha256sum bin/wilson-linux-amd64.tar.gz >> bin/checksums.txt
sha256sum bin/wilson-windows-amd64.tar.gz >> bin/checksums.txt
- name: Publish release
uses: ncipollo/release-action@v1
with:
artifacts: "bin/wilson_linux_amd64, bin/wilson_darwin_amd64, bin/wilson-linux-amd64.tar.gz, bin/wilson-darwin-amd64.tar.gz, bin/checksums.txt"
token: ${{ secrets.GITHUB_TOKEN }}
Worth noting:
https://github.com/go-task/task/blob/master/.goreleaser.yml
They're using goreleaser to build/generate release assets.
They're running goreleaser whenever a new tag is created:
https://github.com/go-task/task/blob/master/.github/workflows/release.yml
name: goreleaser
on:
push:
tags:
- '*'
jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.13.x
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v1
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
There doesn't appear to be an official "action" for this, but there are a number of community/marketplace implementations available to choose from.
This one stood out:
Reasoning:
I would rather have release assets generated via CI than me generating them locally and uploading them. While I don't mind doing the work myself, having CI handle the task should (hopefully) provide both a consistent result and would generate them files using a trusted/verifiable process.