Skip to content

Commit

Permalink
github: generate documentation version matrix dynamically
Browse files Browse the repository at this point in the history
Updating the release tag in docs.yml is tedious. Generate the action
matrix dynamically.
  • Loading branch information
jnikula committed Aug 22, 2023
1 parent fb155fa commit 996daf6
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 6 deletions.
23 changes: 23 additions & 0 deletions .github/config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
# Copyright (c) 2023, Jani Nikula <jani@nikula.org>
# Licensed under the terms of BSD 2-Clause, see LICENSE for details.

# Output a json matrix for building multiple versions of documentation

# Can't use git describe unless full history has been fetched!
release=$(git tag --list --sort=version:refname | tail -1)

jq -c . <<EOF
{
"include": [
{
"ref": "master",
"name": "dev"
},
{
"ref": "$release",
"name": "stable"
}
]
}
EOF
21 changes: 15 additions & 6 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,25 @@ on:
- 'master'

jobs:
configure:
name: Configure Versions
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.version-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v3
- name: Fetch tags
run: git fetch --tags origin
- name: Set version matrix
id: version-matrix
run: echo "matrix=$(./.github/config.sh)" | tee $GITHUB_OUTPUT

build-docs:
name: Build Documentation
runs-on: ubuntu-latest
needs: configure
strategy:
matrix:
include:
- ref: master
name: dev
- ref: v0.15.0
name: stable
matrix: ${{ fromJson(needs.configure.outputs.matrix) }}
steps:
- uses: actions/checkout@v3
with:
Expand Down

0 comments on commit 996daf6

Please sign in to comment.