-
Notifications
You must be signed in to change notification settings - Fork 54
72 lines (60 loc) · 2.03 KB
/
binaries.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: Binaries
on:
push:
tags: [v*]
branches: [master]
pull_request:
branches: [master]
release:
types: [published]
jobs:
create-binaries:
strategy:
matrix:
goos: [linux]
goarch: [amd64, arm64, ppc64le, riscv64, s390x]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: stable # latest stable version of Go
- name: Build binary and create archive
id: build
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: "0"
run: |
echo Generating version file
go generate ./cmd
echo Building for $GOOS $GOARCH
go build -trimpath -ldflags='-s -w' -o dist/build/pebble ./cmd/pebble
# Get version via "pebble version" to ensure it matches that exactly
PEBBLE_VERSION=$(GOOS=linux GOARCH=amd64 go run ./cmd/pebble version --client)
ARCHIVE_FILE=pebble_${PEBBLE_VERSION}_${GOOS}_${GOARCH}.tar.gz
echo Creating archive $ARCHIVE_FILE
cp COPYING dist/build
cp README.md dist/build
tar -czf dist/$ARCHIVE_FILE -C dist/build .
# Share variables with subsequent steps
echo "ARCHIVE_FILE=${ARCHIVE_FILE}" >>$GITHUB_OUTPUT
echo "PEBBLE_VERSION=${PEBBLE_VERSION}" >>$GITHUB_OUTPUT
- name: Upload archive as Actions artifact
uses: actions/upload-artifact@v3
with:
name: ${{ steps.build.outputs.ARCHIVE_FILE }}
path: dist/${{ steps.build.outputs.ARCHIVE_FILE }}
- name: Upload archive to release
env:
ARCHIVE_FILE: ${{ steps.build.outputs.ARCHIVE_FILE }}
PEBBLE_VERSION: ${{ steps.build.outputs.PEBBLE_VERSION }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ github.event_name == 'release' }}
run: |
echo Uploading $ARCHIVE_FILE to release $PEBBLE_VERSION
gh release upload $PEBBLE_VERSION dist/$ARCHIVE_FILE