chore: multiple assets per release #25
Workflow file for this run
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: Build and Publish Release | |
on: | |
push: | |
tags: | |
- v** | |
workflow_dispatch: | |
jobs: | |
test: | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macOS-latest, windows-latest] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Setup Go Environment | |
uses: actions/setup-go@v2 | |
with: | |
go-version: 1.21 | |
- name: Run Tests | |
run: go test ./... | |
release: | |
if: contains(github.ref, 'tags/v') | |
permissions: write-all | |
name: Create GitHub Release | |
needs: [test] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Set Release Tag | |
id: get_tag | |
run: echo "::set-output name=tag::$(echo $GITHUB_REF | sed -n 's/refs\/tags\///p')" | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.get_tag.outputs.tag }} | |
release_name: Release ${{ steps.get_tag.outputs.tag }} | |
body: | | |
Describe your release here. | |
draft: true | |
prerelease: false | |
- name: Create Release URL File | |
run: echo "${{ steps.create_release.outputs.upload_url }}" > release_url.txt | |
- name: Save Release URL File for Publishing | |
uses: actions/upload-artifact@v1 | |
with: | |
name: release_url | |
path: release_url.txt | |
publish: | |
if: contains(github.ref, 'tags/v') | |
needs: [test, release] | |
permissions: write-all | |
name: Publish Binaries | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
include: | |
- goos: android | |
goarch: arm | |
- goos: darwin | |
goarch: 386 | |
- goos: darwin | |
goarch: amd64 | |
- goos: darwin | |
goarch: arm | |
- goos: darwin | |
goarch: arm64 | |
- goos: dragonfly | |
goarch: amd64 | |
- goos: freebsd | |
goarch: 386 | |
- goos: freebsd | |
goarch: amd64 | |
- goos: freebsd | |
goarch: arm | |
- goos: linux | |
goarch: 386 | |
- goos: linux | |
goarch: amd64 | |
- goos: linux | |
goarch: arm | |
- goos: linux | |
goarch: arm64 | |
- goos: linux | |
goarch: ppc64 | |
- goos: linux | |
goarch: ppc64le | |
- goos: linux | |
goarch: mips | |
- goos: linux | |
goarch: mipsle | |
- goos: linux | |
goarch: mips64 | |
- goos: linux | |
goarch: mips64le | |
- goos: netbsd | |
goarch: 386 | |
- goos: netbsd | |
goarch: amd64 | |
- goos: netbsd | |
goarch: arm | |
- goos: openbsd | |
goarch: 386 | |
- goos: openbsd | |
goarch: amd64 | |
- goos: openbsd | |
goarch: arm | |
- goos: plan9 | |
goarch: 386 | |
- goos: plan9 | |
goarch: amd64 | |
- goos: solaris | |
goarch: amd64 | |
- goos: windows | |
goarch: 386 | |
- goos: windows | |
goarch: amd64 | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Load Release URL File from Release Job | |
uses: actions/download-artifact@v1 | |
with: | |
name: release_url | |
- name: Get Tag from Git Reference | |
id: get_tag | |
run: echo "::set-output name=tag::$(echo $GITHUB_REF | sed -n 's/refs\/tags\///p')" | |
- name: Get Release File Name & Upload URL | |
id: get_release_info | |
env: | |
TAG_REF_NAME: ${{ github.ref }} | |
REPOSITORY_NAME: ${{ github.repository }} | |
run: | | |
echo ::set-output name=file_name::${REPOSITORY_NAME##*/}-${TAG_REF_NAME##*/v} # RepositoryName-v1.0.0 | |
value=`cat release_url/release_url.txt` | |
echo ::set-output name=upload_url::$value | |
- name: Setup Go Environment | |
uses: actions/setup-go@v2 | |
with: | |
go-version: 1.21 | |
- name: Build Binary | |
run: GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o ${{ steps.get_release_info.outputs.file_name }}-${{ matrix.goos }}-${{ matrix.goarch }} | |
- name: Upload Release Asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.get_release_info.outputs.upload_url }} | |
asset_path: ${{ steps.get_release_info.outputs.file_name }}-${{ matrix.goos }}-${{ matrix.goarch }} | |
asset_name: ${{ steps.get_release_info.outputs.file_name }}-${{ matrix.goos }}-${{ matrix.goarch }} | |
asset_content_type: application/octet-stream |