Skip to content

Commit 8f98c9e

Browse files
feat(build): Migrate build to goreleaser
1 parent f733f49 commit 8f98c9e

File tree

4 files changed

+86
-47
lines changed

4 files changed

+86
-47
lines changed

.github/workflows/presubmit.yml

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,53 +10,57 @@ env:
1010
GOLINT_ARGS: -v --allow-parallel-runners --timeout=10m --disable errcheck
1111

1212
jobs:
13-
test:
13+
build:
1414
runs-on: ubuntu-latest
1515
steps:
1616
- name: Checkout ⤵️
1717
uses: actions/checkout@v4
1818

19+
- name: Version 🔢
20+
shell: bash
21+
id: version
22+
run: |
23+
if [ "${{ github.event_name }}" == "pull_request" ]; then
24+
echo "GIT_SHA_SHORT="$(echo "${{ github.event.pull_request.head.sha }}" | head -c 8)"" >> "$GITHUB_OUTPUT"
25+
exit 0
26+
fi
27+
echo "GIT_SHA_SHORT="$(git log --format="%H" -n 1 | head -c 8)"" >> "$GITHUB_OUTPUT"
28+
1929
- name: Setup Go 🛠️
2030
uses: actions/setup-go@v5
2131
with:
2232
go-version: ${{ env.GO_VERSION }}
2333

24-
- name: Test pkg library 🔎
34+
- name: Test pkg library 🧪
2535
run: |
2636
cd pkg
27-
go test ./...
37+
go test -race -mod=readonly ./...
2838
29-
- name: Test CloudFormation runtime 🔎
39+
- name: Test 🧪
3040
run: |
3141
cd runtimes/cloudformation
32-
go test ./...
33-
34-
- name: Lint pkg library 🪥
35-
uses: golangci/golangci-lint-action@v6
36-
with:
37-
version: v1.60
38-
working-directory: ./pkg
39-
args: ${{ env.GOLINT_ARGS }}
40-
41-
- name: Lint CloudFormation runtime 🪥
42+
go test -race -mod=readonly ./...
43+
44+
- name: Lint 🪥
4245
uses: golangci/golangci-lint-action@v6
4346
with:
4447
version: v1.60
4548
working-directory: ./runtimes/cloudformation/cmd/handler
4649
args: ${{ env.GOLINT_ARGS }}
4750

48-
build:
49-
runs-on: ubuntu-latest
50-
steps:
51-
- name: Checkout ⤵️
52-
uses: actions/checkout@v4
53-
54-
- name: Setup Go 🛠️
55-
uses: actions/setup-go@v5
51+
- name: Run GoReleaser 🏗️
52+
id: goreleaser
53+
uses: goreleaser/goreleaser-action@v6
5654
with:
57-
go-version: ${{ env.GO_VERSION }}
55+
args: build --clean --snapshot --parallelism=1
56+
workdir: ./runtimes/cloudformation
57+
env:
58+
BUILD_VERSION: ${{ steps.version.outputs.GIT_SHA_SHORT }}
59+
GORELEASER_CURRENT_TAG: "0.0.0"
5860

59-
- name: Build handler 🏗️
60-
run: |
61-
cd runtimes/cloudformation/cmd/handler
62-
go build .
61+
- name: Archive Artifacts
62+
uses: actions/upload-artifact@v4
63+
with:
64+
name: handler-${{ steps.version.outputs.GIT_SHA_SHORT }}
65+
path: |
66+
./runtimes/cloudformation/dist

.github/workflows/release.yml

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,40 +21,45 @@ jobs:
2121
with:
2222
go-version: ${{ env.GO_VERSION }}
2323

24-
- name: Test pkg library 🔎
24+
- name: Test pkg library 🧪
2525
run: |
2626
cd pkg
27-
go test ./...
27+
go test -race -mod=readonly ./...
2828
29-
- name: Lint pkg library 🪥
30-
uses: golangci/golangci-lint-action@v6
31-
with:
32-
version: v1.60
33-
working-directory: ./pkg
34-
args: ${{ env.GOLINT_ARGS }}
35-
36-
- name: Test CloudFormation runtime 🔎
29+
- name: Test 🧪
3730
run: |
3831
cd runtimes/cloudformation
39-
go test ./...
40-
41-
- name: Lint CloudFormation runtime 🪥
32+
go test -race -mod=readonly ./...
33+
34+
- name: Lint 🪥
4235
uses: golangci/golangci-lint-action@v6
4336
with:
4437
version: v1.60
4538
working-directory: ./runtimes/cloudformation/cmd/handler
4639
args: ${{ env.GOLINT_ARGS }}
4740

48-
- name: Build handler 🏗️
49-
run: |
50-
cd runtimes/cloudformation/cmd/handler
51-
go build .
41+
- name: Run GoReleaser 🏗️
42+
id: goreleaser
43+
uses: goreleaser/goreleaser-action@v6
44+
with:
45+
args: build --clean --snapshot --parallelism=1
46+
workdir: ./runtimes/cloudformation
47+
env:
48+
BUILD_VERSION: ${{ github.ref_name }}
49+
GORELEASER_CURRENT_TAG: "0.0.0"
50+
51+
- name: Archive Artifacts
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: handler-${{ github.ref_name }}
55+
path: |
56+
./runtimes/cloudformation/dist
5257
5358
- name: Create release 🌟
5459
uses: softprops/action-gh-release@v2
5560
env:
5661
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5762
with:
5863
files: |
59-
runtimes/cloudformation/cmd/handler/handler
64+
./runtimes/cloudformation/dist
6065
name: ${{ github.ref_name }}

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
.idea/
22

3-
/runtimes/cloudformation/agent-kilt.zip
43
/runtimes/cloudformation/cmd/cfn-apply-kilt/cfn-apply-kilt
54
/runtimes/cloudformation/cmd/cfn-image-info/cfn-image-info
6-
/runtimes/cloudformation/cmd/handler/handler
5+
/runtimes/cloudformation/dist
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
version: 2
2+
3+
project_name: launcher
4+
5+
archives:
6+
- id: launcher
7+
formats: ["binary"]
8+
9+
builds:
10+
- id: default
11+
no_unique_dist_dir: true
12+
binary: handler/handler-{{ .Os }}-{{ .Arch }}
13+
main: ./cmd/handler
14+
goos:
15+
- linux
16+
goarch:
17+
- amd64
18+
- arm64
19+
goamd64:
20+
- v1
21+
mod_timestamp: "{{ .CommitTimestamp }}"
22+
env:
23+
- CGO_ENABLED=0
24+
ldflags:
25+
- -s -w
26+
- -X main.version={{ .Version }}
27+
- -X main.commit={{ .Commit }}
28+
- -X main.date={{ .Date }}
29+
30+
snapshot:
31+
version_template: "{{ .Env.BUILD_VERSION }}"

0 commit comments

Comments
 (0)