build and release for multiple platforms #6
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
# This workflow will build a golang project | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go | |
name: Go build and release | |
on: | |
push: | |
tags: | |
- 'v*.*.*' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: v3 | |
steps: | |
- name: check out code | |
uses: actions/checkout@v3 | |
- name: Get tag name | |
id: get_tag | |
run: echo ::set-output name=TAG::${GITHUB_REF#refs/tags/} | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.21.3' | |
- name: Tidy | |
run: go mod tidy | |
- name: Build | |
run: go build -v -o grok cmd/grok/main.go | |
- name: Build for linux | |
env: | |
VERSION: ${{ steps.get_tag.outputs.TAG }} | |
run: | | |
mkdir -p release | |
CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w -X main.Version=${VERSION}" -o release/grok-${VERSION}-linux ./v3/cmd/grok/main.go | |
- name: Build for Windows | |
env: | |
VERSION: ${{ steps.get_tag.outputs.TAG }} | |
run: | | |
CGO_ENABLED=0 GOOS=windows go build -ldflags="-s -w -X main.Version=${VERSION}" -o release/grok-${VERSION}-windows.exe ./v3/cmd/grok/main.go | |
- name: Build for macOS | |
env: | |
VERSION: ${{ steps.get_tag.outputs.TAG }} | |
run: | | |
CGO_ENABLED=0 GOOS=darwin go build -ldflags="-s -w -X main.Version=${VERSION}" -o release/grok-${VERSION}-macOS ./v3/cmd/grok/main.go | |
- name: Archive production artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: binaries-${{ steps.get_tag.outputs.TAG }} | |
path: release/ | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: release/* | |
tag_name: ${{ steps.get_tag.outputs.TAG }} | |
draft: false | |
prerelease: false | |