-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (137 loc) · 4.75 KB
/
Copy pathci.yml
File metadata and controls
145 lines (137 loc) · 4.75 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: ci
on:
push:
branches: [main]
tags: ["v*"]
pull_request:
# Opt every JS-based action into Node 24 ahead of GitHub's 2026-09-16
# Node 20 EOL. The handful of actions we use (checkout@v4, setup-go@v5,
# golangci-lint-action@v7, setup-node@v4, pnpm/action-setup@v4) still
# ship as Node 20 bundles; this flag keeps them on a supported runtime
# without forcing a major-version churn through each action. Remove
# once Node 24 becomes the runner default.
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- run: go vet ./...
- run: go test -race -count=1 ./...
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
# golangci-lint-action v7 is the first major that parses the v2
# config schema declared in .golangci.yml. v6 + v1.x silently
# fails on `version: "2"`.
- uses: golangci/golangci-lint-action@v7
with:
version: v2.0
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- run: go build -o /tmp/api-log ./cmd/api-log
integration:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run integration test (dev-stack)
run: bash tests/integration/run.sh
# Build + push the api-log image on a version tag. The image is the
# same Dockerfile the dev-stack and demo composes build from; tags map
# 1:1 with git tags.
release:
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
needs: [test, lint, build, integration]
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/metadata-action@v5
id: meta
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest
- uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION=${{ github.ref_name }}
# Cross-compile native binaries (linux + darwin + windows × amd64 + arm64,
# minus windows/arm64) and attach archives + checksums to the GitHub
# release. See .goreleaser.yml. Runs in parallel with `release` (Docker
# / GHCR) above; both gate on the same test/lint/build/integration set.
release-binaries:
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
needs: [test, lint, build, integration]
permissions:
contents: write # release upload
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # GoReleaser needs the tag history
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
# Build the release body from CHANGELOG.md so the GitHub release page
# carries the same content as the file readers/CI have always read.
# If no matching section exists, fall back to the tag annotation so the
# release body is never empty (was the v0.1.1/v0.1.2 retro-fix trigger).
- name: Build release notes from CHANGELOG
run: |
set -euo pipefail
version="${GITHUB_REF_NAME#v}"
awk -v v="$version" '
BEGIN { hit = 0 }
/^## \[/ {
if (hit) { exit }
if ($0 ~ "^## \\[" v "\\]") { hit = 1; next }
}
hit { print }
' CHANGELOG.md > /tmp/release-notes.md
if [ ! -s /tmp/release-notes.md ]; then
echo "WARNING: no [$version] CHANGELOG section; using tag annotation as body" >&2
git tag -l --format='%(contents)' "$GITHUB_REF_NAME" > /tmp/release-notes.md
fi
echo "----- /tmp/release-notes.md preview -----"
head -30 /tmp/release-notes.md
- uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: latest
args: release --clean --release-notes /tmp/release-notes.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}