refactor: move main.go to cmd/world (#13) #29
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 | |
on: | |
pull_request: | |
branches: | |
- main | |
push: | |
branches: | |
- main | |
workflow_call: | |
inputs: | |
create_release: | |
description: 'Check if workflows called from Github Release event.' | |
default: false | |
required: false | |
type: boolean | |
jobs: | |
go-build: | |
name: Run Go Build | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
go-version: [1.21.x] | |
goos: [linux, windows, darwin] | |
goarch: [amd64] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up Docker Build | |
uses: docker/setup-buildx-action@v2 | |
- name: Install Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ matrix.go-version }} | |
cache-dependency-path: "go.sum" | |
- name: Build ${{ matrix.goos }}/${{ matrix.goarch }} | |
id: build | |
run: | | |
output_name=world_${{ matrix.goos }}_${{ matrix.goarch }} | |
[ ${{ matrix.goos }} = "windows" ] && output_name+=".exe" | |
env GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build ./cmd/world -o $output_name | |
echo "output_name=$output_name" >> $GITHUB_OUTPUT | |
- name: Compress Build Binary | |
uses: a7ul/[email protected] | |
id: compress | |
with: | |
command: c | |
files: | | |
./${{ steps.build.outputs.output_name }} | |
outPath: ${{ steps.build.outputs.output_name }}.tar.gz | |
- name: Upload binary to Github artifact | |
if: ${{ inputs.create_release }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: world-${{ matrix.goos }}-${{ matrix.goarch }} | |
path: ./world*.tar.gz |