-
Notifications
You must be signed in to change notification settings - Fork 0
186 lines (158 loc) · 5.03 KB
/
Copy pathcontainer.yml
File metadata and controls
186 lines (158 loc) · 5.03 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
name: Test and publish container
on:
pull_request:
push:
branches: [main]
tags: ["v*"]
schedule:
- cron: "0 6 * * 1"
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v6
with:
version: "0.8.15"
enable-cache: true
- uses: actions/setup-python@v5
with:
python-version: "3.14"
- name: Install locked dependencies
run: uv sync --locked
- name: Run tests
run: uv run python -m unittest discover -s tests -v
- name: Verify installed CLI
run: uv run stands-engine --version
image-smoke:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- name: Build local smoke image
uses: docker/build-push-action@v6
with:
context: .
file: Containerfile
load: true
tags: stands-engine:smoke
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Run image smoke test
run: docker run --rm stands-engine:smoke --version
- name: Scan image
uses: aquasecurity/trivy-action@v0.36.0
with:
image-ref: stands-engine:smoke
format: table
exit-code: "1"
ignore-unfixed: true
severity: HIGH,CRITICAL
trivyignores: .trivyignore.yaml
publish:
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
needs: image-smoke
permissions:
contents: read
packages: write
id-token: write
steps:
- uses: actions/checkout@v4
- name: Validate release metadata
shell: bash
run: |
package_version="$(
python -c 'import tomllib; print(tomllib.load(open("pyproject.toml", "rb"))["project"]["version"])'
)"
expected_tag="v${package_version}"
notes_file=".github/release-notes/${GITHUB_REF_NAME}.md"
if [[ "${GITHUB_REF_NAME}" != "${expected_tag}" ]]; then
echo "::error::Tag ${GITHUB_REF_NAME} does not match package version ${package_version}"
exit 1
fi
if [[ ! -s "${notes_file}" ]]; then
echo "::error::Release notes file ${notes_file} is missing or empty"
exit 1
fi
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate image metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/stands-engine
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha
- name: Build and publish multi-platform image
uses: docker/build-push-action@v6
with:
context: .
file: Containerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
provenance: mode=max
sbom: true
cache-from: type=gha
cache-to: type=gha,mode=max
release:
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
needs: publish
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Create GitHub release
uses: actions/github-script@v7
env:
RELEASE_NOTES_FILE: .github/release-notes/${{ github.ref_name }}.md
with:
script: |
const fs = require("fs");
const tag = context.ref.replace("refs/tags/", "");
const releaseName = `Stands Engine ${tag}`;
const body = fs.readFileSync(
process.env.RELEASE_NOTES_FILE,
"utf8",
).trim();
try {
const { data: existingRelease } =
await github.rest.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag,
});
core.info(
`Release ${existingRelease.html_url} already exists; skipping creation.`,
);
} catch (error) {
if (error.status !== 404) {
throw error;
}
const { data: release } = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: tag,
name: releaseName,
body,
draft: false,
prerelease: false,
generate_release_notes: true,
make_latest: "true",
});
core.info(`Published ${release.html_url}`);
}