Skip to content

Commit e3abc12

Browse files
Update GitHub Action workflows
1 parent 4b242e4 commit e3abc12

File tree

3 files changed

+45
-117
lines changed

3 files changed

+45
-117
lines changed

.github/workflows/build.yaml

+35-33
Original file line numberDiff line numberDiff line change
@@ -2,53 +2,55 @@ name: Build
22

33
on:
44
workflow_call:
5+
inputs:
6+
snapshot:
7+
description: "Whether to run in snapshot mode"
8+
required: false
9+
type: boolean
10+
default: false
511

612
jobs:
713
build:
8-
name: Build Application
14+
name: Build
915
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 }}
1024
steps:
11-
- name: Checkout code
25+
- name: Checkout
1226
uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2
27+
with:
28+
fetch-depth: 0
1329

1430
- name: Set up Go
1531
uses: actions/setup-go@5a083d0e9a84784eb32078397cf5459adecb4c40
1632
with:
1733
go-version: 1.24.0
1834

19-
- name: Cache Go modules
20-
uses: actions/cache@9fa7e61ec7e1f44ac75218e7aaea81da8856fd11
35+
- name: Login to Docker Hub
36+
uses: docker/login-action@327cd5a69de6c009b9ce71bce8395f28e651bf99
2137
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 }}
2640

27-
- name: Cache Go build cache
28-
uses: actions/cache@9fa7e61ec7e1f44ac75218e7aaea81da8856fd11
41+
- name: Login to GHCR
42+
uses: docker/login-action@327cd5a69de6c009b9ce71bce8395f28e651bf99
2943
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 }}
4047

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
4650
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 }}

.github/workflows/release-dev.yaml

+3-40
Original file line numberDiff line numberDiff line change
@@ -20,46 +20,9 @@ jobs:
2020
uses: ./.github/workflows/test.yaml
2121

2222
build-and-publish:
23+
uses: ./.github/workflows/build.yaml
2324
needs:
2425
- test
2526
- lint
26-
runs-on: ubuntu-latest
27-
steps:
28-
- name: Checkout
29-
uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2
30-
with:
31-
fetch-depth: 0
32-
33-
- name: Set up Go
34-
uses: actions/setup-go@5a083d0e9a84784eb32078397cf5459adecb4c40
35-
with:
36-
go-version: 1.24.0
37-
38-
- name: Install templ
39-
run: go install github.com/a-h/templ/cmd/templ@latest
40-
41-
- name: Generate templates
42-
run: templ generate
43-
44-
- name: Login to Docker Hub
45-
uses: docker/login-action@327cd5a69de6c009b9ce71bce8395f28e651bf99
46-
with:
47-
username: ${{ secrets.DOCKERHUB_USERNAME }}
48-
password: ${{ secrets.DOCKERHUB_TOKEN }}
49-
50-
- name: Login to GHCR
51-
uses: docker/login-action@327cd5a69de6c009b9ce71bce8395f28e651bf99
52-
with:
53-
registry: ghcr.io
54-
username: ${{ github.actor }}
55-
password: ${{ secrets.GITHUB_TOKEN }}
56-
57-
- name: Run GoReleaser
58-
uses: goreleaser/goreleaser-action@90a3faa9d0182683851fbfa97ca1a2cb983bfca3
59-
with:
60-
distribution: goreleaser
61-
version: v2.7.0
62-
args: release --clean --snapshot
63-
env:
64-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65-
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
27+
with:
28+
snapshot: true

.github/workflows/release.yaml

+7-44
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ name: Release (Production)
22

33
on:
44
push:
5-
branches:
6-
- main
5+
tags:
6+
- "v[0-9]+.[0-9]+.[0-9]+"
77
workflow_dispatch: {}
88

99
permissions:
@@ -18,55 +18,18 @@ jobs:
1818
uses: ./.github/workflows/test.yaml
1919

2020
build:
21-
name: Build
22-
runs-on: ubuntu-latest
23-
permissions:
24-
packages: write
25-
contents: read
26-
attestations: write
27-
id-token: write
21+
uses: ./.github/workflows/build.yaml
2822
needs:
2923
- test
3024
- lint
31-
env:
32-
CGO_ENABLED: 0
33-
TAG: ${{ github.ref_name }}
34-
steps:
35-
- name: Checkout
36-
uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2
37-
38-
- name: Set up Go
39-
uses: actions/setup-go@5a083d0e9a84784eb32078397cf5459adecb4c40
40-
with:
41-
go-version: 1.24.0
42-
43-
- name: Login to Docker Hub
44-
uses: docker/login-action@327cd5a69de6c009b9ce71bce8395f28e651bf99
45-
with:
46-
username: ${{ secrets.DOCKERHUB_USERNAME }}
47-
password: ${{ secrets.DOCKERHUB_TOKEN }}
48-
49-
- name: Login to GHCR
50-
uses: docker/login-action@327cd5a69de6c009b9ce71bce8395f28e651bf99
51-
with:
52-
registry: ghcr.io
53-
username: ${{ github.actor }}
54-
password: ${{ secrets.GITHUB_TOKEN }}
55-
56-
- name: Run GoReleaser
57-
uses: goreleaser/goreleaser-action@90a3faa9d0182683851fbfa97ca1a2cb983bfca3
58-
with:
59-
distribution: goreleaser
60-
version: v2.7.0
61-
args: release --clean --snapshot
62-
env:
63-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64-
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
6525

6626
renew-docs:
6727
name: Refresh pkg.go.dev
6828
needs: build
6929
runs-on: ubuntu-latest
7030
steps:
7131
- name: Pull new module version
72-
uses: nicholas-fedor/go-proxy-pull-action@2c0cd90fca4f4c81efcc530ee6435752a261aea9
32+
uses: nicholas-fedor/go-proxy-pull-action@4678aed75a75576047e0bc4c15e10dd6eff95baf
33+
with:
34+
goproxy: https://proxy.golang.org
35+
import_path: github.com/nicholas-fedor/eui64-calculator

0 commit comments

Comments
 (0)