Skip to content

Commit c994176

Browse files
committed
feat(ci): Attach the command reference to each release
The website only ever documents the newest release, so anyone staying on an older version has nothing to read. Attach the generated markdown to the release itself, which is also the copy to reach for offline. Packaged in the docs workflow rather than by goreleaser: docgen already runs there, and goreleaser's before hooks cannot write into dist, which it requires to be empty when it starts. The trade-off is that the archive is not in checksums.txt and so not covered by the release attestation. Only tag_name and files are passed to action-gh-release, which leaves the body, draft and prerelease fields of an existing release alone — release-please owns the notes.
1 parent b95e35e commit c994176

1 file changed

Lines changed: 28 additions & 10 deletions

File tree

.github/workflows/docs.yml

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
name: Docs
22

3-
# The published reference must describe a version people can install, so it is
4-
# built from release tags rather than from main. workflow_dispatch is here for
5-
# fixing the site itself (theme, landing page) without cutting a release.
63
on:
74
push:
85
tags: ["v*"]
@@ -11,7 +8,7 @@ on:
118
permissions:
129
contents: read
1310

14-
# One deployment at a time: GitHub Pages rejects concurrent deploys.
11+
# GitHub Pages rejects concurrent deploys.
1512
concurrency:
1613
group: pages
1714
cancel-in-progress: false
@@ -21,10 +18,7 @@ jobs:
2118
runs-on: ubuntu-latest
2219
permissions:
2320
contents: read
24-
# configure-pages reads the site's base URL from the Pages API. It never
25-
# creates the site: enablement defaults to false, so Pages has to be set
26-
# to build from Actions by hand, and read is all this job needs.
27-
pages: read
21+
pages: read # read the site's base URL from the Pages API
2822
steps:
2923
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
3024
with:
@@ -43,8 +37,6 @@ jobs:
4337
run: go run ./cmd/docgen -out website/content
4438
- name: Build site
4539
working-directory: website
46-
# configure-pages reports the correct base URL, which differs between a
47-
# project site (/flagsmith-cli/) and a custom domain.
4840
run: hugo --minify --baseURL "${{ steps.pages.outputs.base_url }}/"
4941
- uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
5042
with:
@@ -62,3 +54,29 @@ jobs:
6254
steps:
6355
- uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # v5.0.0
6456
id: deployment
57+
58+
# The site only ever documents the newest release, so attach a copy to the
59+
# release itself for anyone staying on an older version.
60+
archive:
61+
if: github.ref_type == 'tag'
62+
runs-on: ubuntu-latest
63+
permissions:
64+
contents: write # upload a release asset
65+
steps:
66+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
67+
with:
68+
persist-credentials: false
69+
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
70+
with:
71+
go-version-file: go.mod
72+
- name: Package the reference
73+
run: |
74+
go run ./cmd/docgen -out "$RUNNER_TEMP/reference"
75+
tar -czf "$RUNNER_TEMP/flagsmith_${GITHUB_REF_NAME}_reference.tar.gz" -C "$RUNNER_TEMP" reference
76+
# Only tag_name and files are set: release-please owns the notes, and this
77+
# action leaves body, draft and prerelease alone when they are not passed.
78+
- uses: softprops/action-gh-release@3d0d9888cb7fd7b750713d6e236d1fcb99157228 # v3.0.2
79+
with:
80+
tag_name: ${{ github.ref_name }}
81+
files: ${{ runner.temp }}/flagsmith_*_reference.tar.gz
82+
fail_on_unmatched_files: true

0 commit comments

Comments
 (0)