mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-07-14 15:24:07 +00:00
The CF pages artifact has no extensions in generated links to avoid the automatic redirects CF does.
137 lines
5.1 KiB
YAML
137 lines
5.1 KiB
YAML
name: Generate Documentation
|
|
|
|
on:
|
|
push:
|
|
paths-ignore:
|
|
- "cmake/**"
|
|
branches: ['*']
|
|
tags: ['*']
|
|
pull_request:
|
|
paths:
|
|
- "docs/sphinx/**"
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
docs:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
commitHash: ${{ steps.setup.outputs.commitHash }}
|
|
commitBranch: ${{ steps.setup.outputs.commitBranch }}
|
|
fullCommitHash: ${{ steps.setup.outputs.fullCommitHash }}
|
|
env:
|
|
BUILD_CF_ARTIFACT: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Setup Environment
|
|
id: setup
|
|
run: |
|
|
BRANCH=$(git describe --exact-match --tags 2> /dev/null || git branch --show-current)
|
|
# Remove patch version from tag
|
|
BRANCH=$(echo ${BRANCH} | sed -e 's/\.[0-9]*$//')
|
|
echo "commitBranch=${BRANCH}" >> $GITHUB_OUTPUT
|
|
echo "commitHash=$(git describe --exact-match --tags 2> /dev/null || git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
|
echo "fullCommitHash=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
|
|
|
|
- name: Bump Version Number
|
|
shell: bash
|
|
if: github.event_name != 'pull_request'
|
|
run: |
|
|
VERTEST="\#define\sLIBOBS_API_\w+_VER\s([0-9]{1,2})"
|
|
VER=""
|
|
MAJOR=""
|
|
while IFS= read -r l
|
|
do
|
|
if [[ $l =~ $VERTEST ]]; then
|
|
if [[ $VER = '' ]]; then MAJOR="${BASH_REMATCH[1]}"; else VER+="."; fi
|
|
VER+="${BASH_REMATCH[1]}"
|
|
fi
|
|
done < "libobs/obs-config.h"
|
|
|
|
SVER="version = '([0-9\.]+)'"
|
|
RVER="version = '$VER'"
|
|
SREL="release = '([0-9\.]+)'"
|
|
RREL="release = '$VER'"
|
|
SCOPY="copyright = '([A-Za-z0-9, ]+)'"
|
|
RCOPY="copyright = '2017-$(date +"%Y"), Hugh Bailey'"
|
|
sed -i -E -e "s/${SVER}/${RVER}/g" -e "s/${SREL}/${RREL}/g" -e "s/${SCOPY}/${RCOPY}/g" docs/sphinx/conf.py
|
|
|
|
- uses: totaldebug/sphinx-publish-action@1.2.0
|
|
with:
|
|
sphinx_src: 'docs/sphinx'
|
|
build_only: True
|
|
target_branch: 'master'
|
|
target_path: '../home/_build'
|
|
pre_build_commands: 'pip install -Iv sphinx==5.1.1'
|
|
|
|
- name: Disable link extensions
|
|
shell: bash
|
|
if: ${{ env.BUILD_CF_ARTIFACT == 'true' }}
|
|
run: |
|
|
SOPT="html_link_suffix = None"
|
|
ROPT="html_link_suffix = ''"
|
|
sed -i -e "s/${SOPT}/${ROPT}/g" docs/sphinx/conf.py
|
|
|
|
- uses: totaldebug/sphinx-publish-action@1.2.0
|
|
if: ${{ env.BUILD_CF_ARTIFACT == 'true' }}
|
|
with:
|
|
sphinx_src: 'docs/sphinx'
|
|
build_only: True
|
|
target_branch: 'master'
|
|
target_path: '../home/_build_cf'
|
|
pre_build_commands: 'pip install -Iv sphinx==5.1.1'
|
|
|
|
- uses: actions/upload-artifact@v3
|
|
with:
|
|
name: 'OBS Studio Docs ${{ steps.setup.outputs.commitHash }}'
|
|
path: |
|
|
${{ runner.temp }}/_github_home/_build
|
|
!${{ runner.temp }}/_github_home/_build/.doctrees
|
|
|
|
- uses: actions/upload-artifact@v3
|
|
if: ${{ env.BUILD_CF_ARTIFACT == 'true' }}
|
|
with:
|
|
name: 'CF Pages ${{ steps.setup.outputs.commitHash }}'
|
|
path: |
|
|
${{ runner.temp }}/_github_home/_build_cf
|
|
!${{ runner.temp }}/_github_home/_build_cf/.doctrees
|
|
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
needs: docs
|
|
if: ${{ github.event_name == 'workflow_dispatch' || (github.repository_owner == 'obsproject' && startsWith(github.ref, 'refs/tags/') && github.event_name != 'pull_request') }}
|
|
environment:
|
|
name: cf-pages-deploy
|
|
concurrency:
|
|
group: "cf-pages-deployment"
|
|
cancel-in-progress: true
|
|
steps:
|
|
- uses: actions/download-artifact@v3
|
|
with:
|
|
name: 'CF Pages ${{ needs.docs.outputs.commitHash }}'
|
|
path: docs
|
|
|
|
- name: Setup redirects
|
|
run: |
|
|
echo "/previous/27.2 https://obsproject.com/docs/27.2 302" >> docs/_redirects
|
|
echo "/previous/:major.:minor https://:major-:minor.${{ vars.CF_PAGES_PROJECT }}.pages.dev 302" >> docs/_redirects
|
|
|
|
- name: Publish to live page
|
|
if: ${{ !contains(needs.docs.outputs.commitBranch, 'beta') && !contains(needs.docs.outputs.commitBranch, 'rc') }}
|
|
uses: cloudflare/wrangler-action@4c10c1822abba527d820b29e6333e7f5dac2cabd
|
|
with:
|
|
workingDirectory: docs
|
|
apiToken: ${{ secrets.CF_API_TOKEN }}
|
|
accountId: ${{ secrets.CF_ACCOUNT_ID }}
|
|
command: pages publish . --project-name=${{ vars.CF_PAGES_PROJECT }} --commit-hash='${{ needs.docs.outputs.fullCommitHash }}'
|
|
|
|
- name: Publish to tag alias
|
|
if: ${{ startsWith(github.ref, 'refs/tags/') }}
|
|
uses: cloudflare/wrangler-action@4c10c1822abba527d820b29e6333e7f5dac2cabd
|
|
with:
|
|
workingDirectory: docs
|
|
apiToken: ${{ secrets.CF_API_TOKEN }}
|
|
accountId: ${{ secrets.CF_ACCOUNT_ID }}
|
|
command: pages publish . --project-name=${{ vars.CF_PAGES_PROJECT }} --commit-hash='${{ needs.docs.outputs.fullCommitHash }}' --branch='${{ needs.docs.outputs.commitBranch }}'
|