Created
January 18, 2024 20:43
-
-
Save magickatt/5d15e4cd8e675aa513bb5b78e2ded2e7 to your computer and use it in GitHub Desktop.
Upload multi-architecture Go binaries to GitHub release
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: Latest Release | |
# Customise for the tag format you are using | |
on: | |
push: | |
tags: | |
- v* | |
# Required for the release action to upload artifacts | |
permissions: | |
contents: write | |
jobs: | |
build-go-artifacts: | |
name: Build | |
runs-on: ubuntu-latest | |
# Customise for as many architectures as necessary | |
strategy: | |
matrix: | |
goosarch: | |
- 'darwin/amd64' | |
- 'darwin/arm64' | |
- 'linux/amd64' | |
- 'linux/arm64' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.20.12' | |
- name: Determine OS and architecture information | |
run: | | |
GOOSARCH=${{matrix.goosarch}} | |
GOOS=${GOOSARCH%/*} | |
GOARCH=${GOOSARCH#*/} | |
BINARY_NAME=sactl-$GOOS-$GOARCH | |
echo "BINARY_NAME=$BINARY_NAME" >> $GITHUB_ENV | |
echo "GOOS=$GOOS" >> $GITHUB_ENV | |
echo "GOARCH=$GOARCH" >> $GITHUB_ENV | |
mkdir artifacts | |
- name: Build artifacts | |
run: | | |
go build -o "artifacts/$BINARY_NAME" -v | |
- name: Upload artifacts to release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: artifacts/* | |
append_body: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment