-
Notifications
You must be signed in to change notification settings - Fork 0
129 lines (111 loc) · 3.65 KB
/
Copy pathbuild.yml
File metadata and controls
129 lines (111 loc) · 3.65 KB
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
125
126
127
128
129
name: Build and publish Docker image
on:
push:
branches: ["main"]
tags: ["v*.*.*"]
pull_request:
branches: ["main"]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-test:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
checks: write
steps:
- uses: actions/checkout@v7
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: "1.26"
- name: Cache Go modules & tools
uses: actions/cache@v6
with:
path: |
~/.cache/go-build
~/go/pkg/mod
~/go/bin
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Test
run: |
export PATH=$(go env GOPATH)/bin:$PATH
go install gotest.tools/gotestsum@latest
mkdir -p ./test-reports/
gotestsum --junitfile=./test-reports/junit.xml --format github-actions -- -v -coverprofile=profile.cov -coverpkg=./... ./...
- name: Collect test results
if: always()
uses: actions/upload-artifact@v7
with:
name: test-reports
path: ./test-reports/
- name: Publish test results
uses: mikepenz/action-junit-report@v6
if: always()
with:
report_paths: "./test-reports/junit.xml"
comment: true
include_passed: true
detailed_summary: true
- name: Upload coverage to Coveralls
uses: shogo82148/actions-goveralls@v1
continue-on-error: true
with:
path-to-profile: profile.cov
- name: Lint
uses: golangci/golangci-lint-action@v9
docker-publish:
concurrency:
group: "publishing"
needs:
- build-and-test
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
steps:
- name: Checkout repository with full history
uses: actions/checkout@v7
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: "Log into registry: ${{ env.REGISTRY }}"
if: github.event_name != 'pull_request'
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=semver,pattern=v{{version}}
type=semver,pattern=v{{major}}.{{minor}}
type=semver,pattern=v{{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}
type=sha
labels: |
maintainer=rm-hull
org.opencontainers.image.description=A high-performance Go API for spatial search and retrieval of UK postcode polygons and codepoints.
org.opencontainers.image.source = "https://github.com/map-services/postcode-polygons"
org.opencontainers.image.licenses=MIT
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v7
with:
context: .
platforms: linux/amd64 #,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max