-
Notifications
You must be signed in to change notification settings - Fork 2
58 lines (55 loc) · 1.64 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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 -o $output_name ./cmd/world
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