Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically build docs on release #2230

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/build_docs_on_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: "Build Docs on Release"

on:
release:
types: [released]

run-name: "Build and Publish Docs for release ${{ github.event.release.tag_name }}"
jobs:
check-inputs:
name: Check inputs
runs-on: ubuntu-latest
outputs:
version: ${{ steps.tag_name.outputs.tag }}
latest: ${{ github.event.release.tag_name == steps.latest_tag.outputs.tag }}

steps:
- name: Get latest released tag
id: latest_tag
uses: oprypin/find-latest-tag@v1
with:
repository: ${{ github.repository }}
regex: ^v\d+\.\d+\.\d+$
sort-tags: true
releases-only: true

- name: Verify release tag
id: tag_name
run: |
TAG_NAME=${{ github.event.release.tag_name }}
if [[ ! $TAG_NAME =~ ^v[0-9]+(\.[0-9]+){2}$ ]]; then
echo "Error: Release tag name is not in the correct format. Expected: vX.Y.Z, Actual: $TAG_NAME"
exit 1
fi
echo "tag=${TAG_NAME#v}" >> $GITHUB_OUTPUT

- name: Checkout repository
uses: actions/checkout@v4
with:
ref: v${{ steps.tag_name.outputs.tag }}

- name: Create docs tag
id: create_docs_tag
run: |
DOCS_TAG_NAME=v${{ steps.tag_name.outputs.tag }}-docs
git tag $DOCS_TAG_NAME
git push origin $DOCS_TAG_NAME
continue-on-error: true

build-docs:
needs: check-inputs
name: "Build docs with version: ${{ needs.check-inputs.outputs.version }}, latest: ${{ needs.check-inputs.outputs.latest }}"
uses: ./.github/workflows/docs_build.yml
with:
version: ${{ needs.check-inputs.outputs.version }}
latest: ${{ needs.check-inputs.outputs.latest }}
deploy: true
6 changes: 5 additions & 1 deletion .github/workflows/docs_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ on:
version: { type: string, required: false, description: "The version to build (used in git and pypi). git-tag='v{version}-docs'. If not specified then use selected branch and wheel from the last successful build."}
latest: { type: boolean, required: false, description: Alias this version as the 'latest' stable docs. This should be set for the latest stable release.}
deploy: { type: boolean, required: false, description: Push the built docs to the docs-pages branch on github.}

workflow_call:
inputs:
version: { type: string, required: true, description: "The version to build (used in git and pypi). git-tag='v{version}-docs'."}
latest: { type: boolean, required: true, description: Alias this version as the 'latest' stable docs. This should be set for the latest stable release.}
deploy: { type: boolean, required: true, description: Push the built docs to the docs-pages branch on github.}
jobs:
docs_build:
runs-on: ubuntu-22.04
Expand Down
Loading