Skip to content

Commit a93f13c

Browse files
kolyshkinclaude
andcommitted
Publish swagger.yaml from GitHub Actions on push to main and tags
Add a 'Publish swagger' workflow that builds pkg/api/swagger.yaml and uploads it to the libpod-master-releases GCS bucket (swagger-latest.yaml for main, swagger-<tag>.yaml for tags), reusing the same gcsupld container as Cirrus with GCPJSON/GCPNAME supplied via repository secrets. Per-PR uploads to libpod-pr-releases are dropped, as nothing consumes them. The gcsupld image tag is hardcoded (copied from .cirrus.yml IMAGE_SUFFIX) rather than read at runtime, since Cirrus CI is to be decommissioned soon. Remove the now-migrated swagger_task from .cirrus.yml (and its success_task dependency) and the _run_swagger handler from hack/ci/runner.sh, and update docs/README.md to point at the new workflow. While at it, fix the link in docs/README.md to hack/ci/README.md#docs-task, which had been dangling ever since that file was removed in 2020 by commit 2c9084e. Note: requires GCPJSON and GCPNAME to be configured as GitHub repository secrets before the upload step can succeed. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
1 parent 1472dcd commit a93f13c

4 files changed

Lines changed: 74 additions & 86 deletions

File tree

.cirrus.yml

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -380,31 +380,6 @@ bindings_task:
380380
time_script: '$SCRIPT_BASE/logcollector.sh time'
381381

382382

383-
# Build the "libpod" API documentation `swagger.yaml` and
384-
# publish it to google-cloud-storage (GCS).
385-
swagger_task:
386-
name: "Test Swagger"
387-
alias: swagger
388-
depends_on: *build
389-
gce_instance: *standardvm
390-
env:
391-
<<: *stdenvars
392-
TEST_FLAVOR: swagger
393-
CTR_FQIN: 'quay.io/libpod/gcsupld:${IMAGE_SUFFIX}'
394-
GCPJSON: ENCRYPTED[927dc01e755eaddb4242b0845cf86c9098d1e3dffac38c70aefb1487fd8b4fe6dd6ae627b3bffafaba70e2c63172664e]
395-
GCPNAME: ENCRYPTED[c145e9c16b6fb88d476944a454bf4c1ccc84bb4ecaca73bdd28bdacef0dfa7959ebc8171a27b2e4064d66093b2cdba49]
396-
GCPPROJECT: 'libpod-218412'
397-
TEST_BUILD_TAGS: ""
398-
clone_script: *get_gosrc
399-
setup_script: *setup
400-
main_script: *main
401-
always:
402-
<<: *runner_stats
403-
swagger_artifacts:
404-
path: ./swagger.yaml
405-
type: text/plain
406-
407-
408383
win_installer_task:
409384
name: "Verify Win Installer Build"
410385
matrix:
@@ -1095,7 +1070,6 @@ success_task:
10951070
depends_on:
10961071
- build_success
10971072
- bindings
1098-
- swagger
10991073
- win_installer
11001074
- docker-py_test
11011075
- unit_test

.github/workflows/swagger.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Publish swagger
2+
3+
# Build the libpod API spec (pkg/api/swagger.yaml) and publish it to the
4+
# public GCS bucket consumed by the API reference docs
5+
# (docs/source/_static/api.html -> https://storage.googleapis.com/libpod-master-releases/swagger-<version>.yaml).
6+
# Pushes to main publish "swagger-latest.yaml"; tags publish "swagger-<tag>.yaml".
7+
on:
8+
push:
9+
branches:
10+
- main
11+
tags:
12+
- "v*"
13+
14+
permissions:
15+
contents: read
16+
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.ref }}
19+
cancel-in-progress: true
20+
21+
jobs:
22+
publish-swagger:
23+
name: Build and publish swagger.yaml
24+
runs-on: cncf-ubuntu-8-32-x86
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
28+
with:
29+
persist-credentials: false
30+
31+
- name: Install build dependencies
32+
run: |
33+
sudo apt-get update
34+
sudo apt-get install -y \
35+
gawk \
36+
libassuan-dev \
37+
libbtrfs-dev \
38+
libgpgme-dev \
39+
libseccomp-dev \
40+
libsystemd-dev \
41+
libclone-perl \
42+
man-db \
43+
podman \
44+
python3-pip
45+
46+
- name: Set up Go
47+
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
48+
with:
49+
go-version-file: go.mod
50+
cache: false
51+
52+
- name: Build swagger.yaml
53+
run: make swagger
54+
55+
- name: Publish swagger.yaml to GCS
56+
env:
57+
GCPJSON: ${{ secrets.GCPJSON }}
58+
GCPNAME: ${{ secrets.GCPNAME }}
59+
GCPPROJECT: libpod-218412
60+
# Pushes to main publish "latest"; tags publish under their tag name.
61+
TO_GCSURI: gs://libpod-master-releases/swagger-${{ github.ref_type == 'tag' && github.ref_name || 'latest' }}.yaml
62+
FROM_FILEPATH: /src/pkg/api/swagger.yaml
63+
# Uploader image tag, copied from .cirrus.yml IMAGE_SUFFIX.
64+
GCSUPLD_FQIN: quay.io/libpod/gcsupld:c20260425t010036z-f43f42d14
65+
run: |
66+
# Pass secrets through podman's environment (-e VAR) rather than an
67+
# env-file so they are never written to disk.
68+
podman run --rm --security-opt label=disable \
69+
-e GCPJSON -e GCPNAME -e GCPPROJECT -e FROM_FILEPATH -e TO_GCSURI \
70+
-v "$GITHUB_WORKSPACE:/src:ro" \
71+
--workdir /src \
72+
"$GCSUPLD_FQIN"

docs/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ The syntax for the formatting of all man pages can be found [here](MANPAGE_SYNTA
3535

3636
The [latest online documentation](http://docs.podman.io/en/latest/_static/api.html) is
3737
automatically generated by two cooperating automation systems based on committed upstream
38-
source code. Firstly, [the Cirrus-CI docs task](../hack/ci/README.md#docs-task) builds
39-
`pkg/api/swagger.yaml` and uploads it to a public-facing location (Google Storage Bucket -
38+
source code. Firstly, the [`Publish swagger` GitHub Actions workflow](../.github/workflows/swagger.yml)
39+
builds `pkg/api/swagger.yaml` and uploads it to a public-facing location (Google Storage Bucket -
4040
an online service for storing unstructured data). Second, [Read The Docs](readthedocs.com)
4141
reacts to the github.com repository change, building the content for the [libpod documentation
4242
site](https://podman.readthedocs.io/). This site includes for the API section,

hack/ci/runner.sh

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -122,64 +122,6 @@ exec_container() {
122122
$CTR_FQIN bash -c "$SCRIPT_BASE/setup_environment.sh && $SCRIPT_BASE/runner.sh"
123123
}
124124

125-
function _run_swagger() {
126-
local upload_filename
127-
local upload_bucket
128-
local download_url
129-
local envvarsfile
130-
req_env_vars GCPJSON GCPNAME GCPPROJECT CTR_FQIN
131-
132-
# The filename and bucket depend on the automation context
133-
#shellcheck disable=SC2154,SC2153
134-
if [[ -n "$CIRRUS_PR" ]]; then
135-
upload_bucket="libpod-pr-releases"
136-
upload_filename="swagger-pr$CIRRUS_PR.yaml"
137-
elif [[ -n "$CIRRUS_TAG" ]]; then
138-
upload_bucket="libpod-master-releases"
139-
upload_filename="swagger-$CIRRUS_TAG.yaml"
140-
elif [[ "$CIRRUS_BRANCH" == "main" ]]; then
141-
upload_bucket="libpod-master-releases"
142-
# readthedocs versioning uses "latest" for "main" (default) branch
143-
upload_filename="swagger-latest.yaml"
144-
elif [[ -n "$CIRRUS_BRANCH" ]]; then
145-
upload_bucket="libpod-master-releases"
146-
upload_filename="swagger-$CIRRUS_BRANCH.yaml"
147-
else
148-
die "Unknown execution context, expected a non-empty value for \$CIRRUS_TAG, \$CIRRUS_BRANCH, or \$CIRRUS_PR"
149-
fi
150-
151-
# Swagger validation takes a significant amount of time
152-
msg "Pulling \$CTR_FQIN '$CTR_FQIN' (background process)"
153-
showrun bin/podman pull --quiet $CTR_FQIN &
154-
155-
cd $GOSRC
156-
showrun make swagger
157-
158-
# Cirrus-CI Artifact instruction expects file here
159-
cp -v $GOSRC/pkg/api/swagger.yaml ./
160-
161-
envvarsfile=$(mktemp -p '' .tmp_$(basename $0)_XXXXXXXX)
162-
trap "rm -f $envvarsfile" EXIT # contains secrets
163-
# Warning: These values must _not_ be quoted, podman will not remove them.
164-
#shellcheck disable=SC2154
165-
cat <<eof >>$envvarsfile
166-
GCPJSON=$GCPJSON
167-
GCPNAME=$GCPNAME
168-
GCPPROJECT=$GCPPROJECT
169-
FROM_FILEPATH=$GOSRC/swagger.yaml
170-
TO_GCSURI=gs://$upload_bucket/$upload_filename
171-
eof
172-
173-
msg "Waiting for backgrounded podman pull to complete..."
174-
wait %%
175-
showrun bin/podman run -it --rm --security-opt label=disable \
176-
--env-file=$envvarsfile \
177-
-v $GOSRC:$GOSRC:ro \
178-
--workdir $GOSRC \
179-
$CTR_FQIN
180-
rm -f $envvarsfile
181-
}
182-
183125
function _run_build() {
184126
# Ensure always start from clean-slate with all vendor modules downloaded
185127
showrun make clean

0 commit comments

Comments
 (0)