Skip to content

Commit 801eb95

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. The build job already generates those pages, so it hands them to the archive job as an artifact and nothing is built or checked out twice. Archiving happens on the far side of that handover because an artifact is not a release asset and its zip needs a token to fetch, so the tarball has to be made somewhere; doing it there also avoids wrapping a tarball inside the artifact's own zip. It stays a separate job because uploading needs a write token, and the build job runs the Hugo theme — third-party template code should not share a job with a token that can push to the repository. 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 939b5b9 commit 801eb95

2 files changed

Lines changed: 31 additions & 11 deletions

File tree

‎.github/workflows/docs.yml‎

Lines changed: 30 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,12 +37,18 @@ 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:
5143
path: website/public
44+
# The pages the site was just built from, for the archive job to attach.
45+
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
46+
if: github.ref_type == 'tag'
47+
with:
48+
name: reference
49+
path: website/content
50+
if-no-files-found: error
51+
retention-days: 1
5252

5353
deploy:
5454
needs: build
@@ -62,3 +62,23 @@ jobs:
6262
steps:
6363
- uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # v5.0.0
6464
id: deployment
65+
66+
# The site only ever documents the newest release, so attach a copy to the
67+
# release itself for anyone staying on an older version.
68+
archive:
69+
needs: build
70+
if: github.ref_type == 'tag'
71+
runs-on: ubuntu-latest
72+
permissions:
73+
contents: write # upload a release asset
74+
steps:
75+
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
76+
with:
77+
name: reference
78+
path: reference
79+
- run: tar -czf "flagsmith_${GITHUB_REF_NAME}_reference.tar.gz" reference
80+
- uses: softprops/action-gh-release@3d0d9888cb7fd7b750713d6e236d1fcb99157228 # v3.0.2
81+
with:
82+
tag_name: ${{ github.ref_name }}
83+
files: flagsmith_*_reference.tar.gz
84+
fail_on_unmatched_files: true

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ flagsmith flag list # list the flags in the current environment
6868

6969
Full reference for every command and flag: <https://flagsmith.github.io/flagsmith-cli/>.
7070

71-
Reading works against any Flagsmith instance. Changing flags — `flag update`, `flag enable`/`disable`, `flag reorder`, `flag delete` — needs Flagsmith 2.263.0 or newer, self-hosted or SaaS.
71+
Reading works against any Flagsmith instance. Changing flags — `flag update`, `flag enable`/`disable`, `flag reorder`, `flag delete` — needs Flagsmith 2.263.0 or newer.
7272

7373
- `flagsmith init` — bind the current directory to a project (writes `flagsmith.json`).
7474
- `flagsmith flag list` — list feature flags in the current environment.

0 commit comments

Comments
 (0)