Build and Release #14
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 Release | |
on: | |
workflow_dispatch: | |
inputs: | |
tag_name: | |
description: 'The tag name for the release' | |
required: true | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
include: | |
- platform: macos-11 | |
goos: darwin | |
goarch: arm64 | |
- platform: ubuntu-latest | |
goos: linux | |
goarch: amd64 | |
steps: | |
- name: Set up Go | |
uses: actions/setup-go@v2 | |
with: | |
go-version: '^1.17' | |
- name: Check out code | |
uses: actions/checkout@v2 | |
- name: Build | |
run: | | |
env GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o up_${{ matrix.goos }}_${{ matrix.goarch }} | |
- name: Upload artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: up_${{ matrix.goos }}_${{ matrix.goarch }} | |
path: ./up_${{ matrix.goos }}_${{ matrix.goarch }} | |
create-release: | |
needs: build | |
runs-on: ubuntu-latest | |
outputs: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
steps: | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.event.inputs.tag_name }} | |
release_name: Release ${{ github.event.inputs.tag_name }} | |
draft: false | |
prerelease: false | |
upload-release-asset: | |
needs: create-release | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
include: | |
- platform: macos-11 | |
goos: darwin | |
goarch: arm64 | |
- platform: ubuntu-latest | |
goos: linux | |
goarch: amd64 | |
steps: | |
- name: Download all artifacts | |
uses: actions/download-artifact@v2 | |
with: | |
name: up_${{ matrix.goos }}_${{ matrix.goarch }} | |
path: ./artifacts | |
- name: Upload Release Asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.create-release.outputs.upload_url }} | |
asset_path: ./artifacts/up_${{ matrix.goos }}_${{ matrix.goarch }} | |
asset_name: up_${{ matrix.goos }}_${{ matrix.goarch }} | |
asset_content_type: application/octet-stream |