-
-
Notifications
You must be signed in to change notification settings - Fork 4
124 lines (105 loc) · 3.9 KB
/
go.build.yaml
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
name: Build
on:
push:
branches-ignore:
- '**'
tags:
- 'v*.*.*'
jobs:
build:
name: Build
runs-on: ubuntu-latest
outputs:
darwin_sha256sum: ${{ steps.calculate-checksums-darwin.outputs.darwin_sha256sum }}
linux_sha256sum: ${{ steps.calculate-checksums-linux.outputs.linux_sha256sum }}
steps:
- name: Set up Go 1.22
uses: actions/setup-go@v4
with:
go-version: '1.22'
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Get dependencies
run: |
go generate -v
go install -v
- name: Build
run: |
targets=${@-"darwin/amd64 linux/amd64"}
for target in $targets; do
os="$(echo $target | cut -d '/' -f1)"
arch="$(echo $target | cut -d '/' -f2)"
echo "--> Building project for: ${os}/${arch}"
GOOS=$os GOARCH=$arch CGO_ENABLED=0 go build -ldflags "-X github.com/flownative/localbeach/pkg/version.Version=${GITHUB_REF#refs/*/}" -o beach .
zip "beach_${os}_${arch}.zip" beach
ls -la
done
- name: Archive build result (darwin)
uses: actions/upload-artifact@v3
with:
name: beach-osx
path: beach_darwin_amd64.zip
- name: Archive build result (linux)
uses: actions/upload-artifact@v3
with:
name: beach-linux
path: beach_linux_amd64.zip
- name: Create Release
uses: ncipollo/release-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
allowUpdates: true
artifactErrorsFailBuild: true
artifacts: "beach_linux_amd64.zip,beach_darwin_amd64.zip"
artifactContentType: application/zip
generateReleaseNotes: false
makeLatest: true
name: Release ${{ github.ref }}
- name: Calculate checksum (darwin)
id: calculate-checksums-darwin
run: echo "darwin_sha256sum=$(sha256sum beach_darwin_amd64.zip | awk '//{print $1}')" >> $GITHUB_OUTPUT
- name: Calculate checksum (linux)
id: calculate-checksums-linux
run: echo "linux_sha256sum=$(sha256sum beach_linux_amd64.zip | awk '//{print $1}')" >> $GITHUB_OUTPUT
homebrew:
name: Homebrew release
runs-on: ubuntu-latest
needs: build
steps:
- name: Check out Go code
uses: actions/checkout@v4
- name: Check out Homebrew code
uses: actions/checkout@v4
with:
repository: flownative/homebrew-flownative
path: homebrew
- name: Copy formula template
run: cp .github/workflows/localbeach.rb.tpl homebrew/Formula/localbeach.rb
- name: Set RELEASE_VERSION env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
# see: https://github.com/bluwy/substitute-string-action
- name: Substitute Homebrew variables
uses: bluwy/substitute-string-action@v2
with:
_input-file: homebrew/Formula/localbeach.rb
_output-file: homebrew/Formula/localbeach.rb
_format-key: "{{key}}"
version: ${{ env.RELEASE_VERSION }}
darwin_sha256sum: ${{ needs.build.outputs.darwin_sha256sum }}
linux_sha256sum: ${{ needs.build.outputs.linux_sha256sum }}
- name: Commit update
run: |
cd homebrew
git config --local --unset-all "http.https://github.com/.extraheader"
git config --global user.email "[email protected]"
git config --global user.name "Flownative Bot"
git add Formula/localbeach.rb
git commit -m 'localbeach: update to ${{ github.ref }}'
- name: Push to git
uses: ad-m/[email protected]
with:
github_token: ${{ secrets.FLOWNATIVE_BOT_TOKEN }}
repository: flownative/homebrew-flownative
directory: homebrew