Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 7c536d0

Browse files
Deploy a documentation version for each new Synapse release (#10198)
This PR will run a new "Deploy release-specific documentation" job whenever a push to a branch name matching `release-v*` occurs. Doing so will create/add to a folder named `vX.Y` on the `gh-pages` branch. Doing so will allow us to build up `major.minor` releases of the docs as we release Synapse. This is especially useful for having a mechanism for keeping around documentation of old/removed features (for those running older versions of Synapse), without needing to clutter the latest copy of the docs. After a [discussion](https://matrix.to/#/!XaqDhxuTIlvldquJaV:matrix.org/$rKmkBmQle8OwTlGcoyu0BkcWXdnHW3_oap8BMgclwIY?via=matrix.org&via=vector.modular.im&via=envs.net) in #synapse-dev, we wanted to use tags to trigger the documentation deployments, which I agreed with. However, I soon realised that the bash-foo required to turn a tag of `v1.2.3rc1` into `1.2` was a lot more complex than the branch's `release-v1.2`. So, I've gone with the latter for simplicity. In the future we'll have some UI on the website to switch between versions, but for now you can simply just change 'develop' to 'v1.2' in the URL.
1 parent 0bd9689 commit 7c536d0

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

.github/workflows/docs.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ name: Deploy the documentation
33
on:
44
push:
55
branches:
6+
# For bleeding-edge documentation
67
- develop
8+
# For documentation specific to a release
9+
- 'release-v*'
710

811
workflow_dispatch:
912

@@ -22,10 +25,40 @@ jobs:
2225
- name: Build the documentation
2326
run: mdbook build
2427

28+
# Deploy to the latest documentation directories
2529
- name: Deploy latest documentation
2630
uses: peaceiris/actions-gh-pages@068dc23d9710f1ba62e86896f84735d869951305 # v3.8.0
2731
with:
2832
github_token: ${{ secrets.GITHUB_TOKEN }}
2933
keep_files: true
3034
publish_dir: ./book
3135
destination_dir: ./develop
36+
37+
- name: Get the current Synapse version
38+
id: vars
39+
# The $GITHUB_REF value for a branch looks like `refs/heads/release-v1.2`. We do some
40+
# shell magic to remove the "refs/heads/release-v" bit from this, to end up with "1.2",
41+
# our major/minor version number, and set this to a var called `branch-version`.
42+
#
43+
# We then use some python to get Synapse's full version string, which may look
44+
# like "1.2.3rc4". We set this to a var called `synapse-version`. We use this
45+
# to determine if this release is still an RC, and if so block deployment.
46+
run: |
47+
echo ::set-output name=branch-version::${GITHUB_REF#refs/heads/release-v}
48+
echo ::set-output name=synapse-version::`python3 -c 'import synapse; print(synapse.__version__)'`
49+
50+
# Deploy to the version-specific directory
51+
- name: Deploy release-specific documentation
52+
# We only carry out this step if we're running on a release branch,
53+
# and the current Synapse version does not have "rc" in the name.
54+
#
55+
# The result is that only full releases are deployed, but can be
56+
# updated if the release branch gets retroactive fixes.
57+
if: ${{ startsWith( github.ref, 'refs/heads/release-v' ) && !contains( steps.vars.outputs.synapse-version, 'rc') }}
58+
uses: peaceiris/actions-gh-pages@v3
59+
with:
60+
github_token: ${{ secrets.GITHUB_TOKEN }}
61+
keep_files: true
62+
publish_dir: ./book
63+
# The resulting documentation will end up in a directory named `vX.Y`.
64+
destination_dir: ./v${{ steps.vars.outputs.branch-version }}

changelog.d/10198.doc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Deploy a snapshot of the documentation website upon each new Synapse release.

0 commit comments

Comments
 (0)