Skip to content

Commit

Permalink
publisher: split docs deployment into a workflow
Browse files Browse the repository at this point in the history
Documentation will now be built using a separated workflow that will be
run whenever publisher finishes. This allows us to use the latest
page deployment code regardless of the commit that triggered publisher.

Some auxilliary changes also come along:

- New deploy-docs workflow can also be run manually.
- "Generated docs" artifacts are now removed. Instead the generated
  documentation will be obtained from the release tarball for Linux.
  This is done since artifacts have a timeout to them, which meddle with
  our ability to run docs deployment at will.
- Implemented basic version segmentation: `/devel` subdirectory will now
  contain the latest devel docs.
  • Loading branch information
alaviss committed Jul 4, 2024
1 parent f5e30a5 commit 7d7c223
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 27 deletions.
9 changes: 0 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -549,15 +549,6 @@ jobs:
echo "archive=$archive" >> $GITHUB_OUTPUT
echo "metadata=$metadata" >> $GITHUB_OUTPUT
- name: Upload docs to artifacts
if: matrix.target.shared_builder
uses: actions/upload-artifact@v4
with:
# If this name is updated, tweak publisher.yml
name: Generated docs
path: doc/html/
if-no-files-found: error

- name: Upload release package to artifacts
uses: actions/upload-artifact@v4
with:
Expand Down
86 changes: 86 additions & 0 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Deploy documentation
on:
# Automatically run after any completed publish
workflow_run:
workflows:
- Publish built artifacts
types:
- completed

# For manual triggers
workflow_dispatch:

# Run every script actions in bash
defaults:
run:
shell: bash

concurrency: doc-publisher

jobs:
deploy:
runs-on: ubuntu-latest

permissions:
id-token: write
pages: write

environment:
name: github-pages
url: ${{ steps.deploy.outputs.page_url }}

env:
# Triplet to obtain docs from
DOC_TARGET: x86_64-linux-gnu

steps:
- uses: actions/checkout@v4

- name: Setup latest compiler
uses: nim-works/setup-nimskull@0.1.2
with:
nimskull-version: "*" # Grab the latest nimskull-version

- name: Compile release_manifest
run: nim c -d:release -o:release_manifest tools/release_manifest.nim

- id: versions
name: Grab latest release version
run: |
# Stolen from asdf-nimskull
sort_versions() {
sed 'h; s/[+-]/./g; s/$/.z/; G; s/\n/ /' |
LC_ALL=C sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4 -k 5,5n | awk '{print $2}'
}
all_tags=$(gh release list --json tagName --jq '.[] | .tagName')
latest=$(sort_versions <<<"$all_tags" | tail -n 1)
echo "Latest devel is: $latest"
echo "devel=$latest" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ github.token }}

- name: Construct devel docs
run: |
tmpdir=$(mktemp -dp "$RUNNER_TEMP" devel.XXXXXXXXXX)
# Get the name of the binary archive for the documentation target
release_archive=$(gh release download "$DEVEL" -p manifest.json -O - | ./release_manifest -f /dev/stdin get "$DOC_TARGET")
# Download the latest release binary
gh release download "$DEVEL" -p "$release_archive" -O "$tmpdir/$release_archive"
# Extract and remove the top-level directory
tar -C "$tmpdir" -xf "$tmpdir/$release_archive" --strip-components=1
mkdir -p built-docs
cp -rT "$tmpdir/doc/html" built-docs/devel
cp -rT "$tmpdir/doc/html" built-docs
env:
GH_TOKEN: ${{ github.token }}
DEVEL: ${{ steps.versions.outputs.devel }}

- uses: actions/upload-pages-artifact@v3
with:
path: built-docs/

- id: deploy
uses: actions/deploy-pages@v4
19 changes: 1 addition & 18 deletions .github/workflows/publisher.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ jobs:
url: ${{ steps.release.outputs.url }}

steps:
# Publish action needs a checkout
- uses: actions/checkout@v4

- name: Obtain latest successful run id
id: finder
run: |
Expand All @@ -48,17 +45,9 @@ jobs:
WORKFLOW: ci.yml
CONCLUSION: success
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}

# Download the latest instance of artifacts from a build done previously
- name: Download generated docs
uses: actions/download-artifact@v4
with:
run-id: ${{ steps.finder.outputs.run_id }}
# Keep up-to-date with ci.yml
name: Generated docs
path: doc/html
github-token: ${{ github.token }}

- name: Download generated source archive
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -87,12 +76,6 @@ jobs:
path: release-staging
github-token: ${{ github.token }}

- name: Publish docs
uses: JamesIves/github-pages-deploy-action@v4.6.1
with:
branch: gh-pages
folder: doc/html

- id: release-files
name: Create release manifest
run: |
Expand Down

0 comments on commit 7d7c223

Please sign in to comment.