@@ -2,53 +2,55 @@ name: Build
2
2
3
3
on :
4
4
workflow_call :
5
+ inputs :
6
+ snapshot :
7
+ description : " Whether to run in snapshot mode"
8
+ required : false
9
+ type : boolean
10
+ default : false
5
11
6
12
jobs :
7
13
build :
8
- name : Build Application
14
+ name : Build
9
15
runs-on : ubuntu-latest
16
+ permissions :
17
+ packages : write
18
+ contents : read
19
+ attestations : write
20
+ id-token : write
21
+ env :
22
+ CGO_ENABLED : 0
23
+ TAG : ${{ github.ref_name }}
10
24
steps :
11
- - name : Checkout code
25
+ - name : Checkout
12
26
uses : actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2
27
+ with :
28
+ fetch-depth : 0
13
29
14
30
- name : Set up Go
15
31
uses : actions/setup-go@5a083d0e9a84784eb32078397cf5459adecb4c40
16
32
with :
17
33
go-version : 1.24.0
18
34
19
- - name : Cache Go modules
20
- uses : actions/cache@9fa7e61ec7e1f44ac75218e7aaea81da8856fd11
35
+ - name : Login to Docker Hub
36
+ uses : docker/login-action@327cd5a69de6c009b9ce71bce8395f28e651bf99
21
37
with :
22
- path : ~/go/pkg/mod
23
- key : ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
24
- restore-keys : |
25
- ${{ runner.os }}-go-
38
+ username : ${{ secrets.DOCKERHUB_USERNAME }}
39
+ password : ${{ secrets.DOCKERHUB_TOKEN }}
26
40
27
- - name : Cache Go build cache
28
- uses : actions/cache@9fa7e61ec7e1f44ac75218e7aaea81da8856fd11
41
+ - name : Login to GHCR
42
+ uses : docker/login-action@327cd5a69de6c009b9ce71bce8395f28e651bf99
29
43
with :
30
- path : ~/go/pkg/mod/cache
31
- key : ${{ runner.os }}-build-${{ hashFiles('**/go.sum') }}
32
- restore-keys : |
33
- ${{ runner.os }}-build-
34
-
35
- - name : Install dependencies
36
- run : go mod download
37
-
38
- - name : Install templ
39
- run : go install github.com/a-h/templ/cmd/templ@latest
44
+ registry : ghcr.io
45
+ username : ${{ github.actor }}
46
+ password : ${{ secrets.GITHUB_TOKEN }}
40
47
41
- - name : Generate templates
42
- run : templ generate
43
-
44
- - name : Cache generated templates
45
- uses : actions/cache@9fa7e61ec7e1f44ac75218e7aaea81da8856fd11
48
+ - name : Run GoReleaser
49
+ uses : goreleaser/goreleaser-action@90a3faa9d0182683851fbfa97ca1a2cb983bfca3
46
50
with :
47
- path : ui/*.go
48
- key : ${{ runner.os }}-templ-${{ hashFiles('ui/*.templ') }}
49
- restore-keys : |
50
- ${{ runner.os }}-templ-
51
-
52
- - name : Build application
53
- run : |
54
- go build -o eui64-calculator ./cmd/server
51
+ distribution : goreleaser
52
+ version : v2.7.0
53
+ args : release --clean ${{ inputs.snapshot && '--snapshot' || '' }}
54
+ env :
55
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
56
+ DOCKERHUB_USERNAME : ${{ secrets.DOCKERHUB_USERNAME }}
0 commit comments