fix(ospo): release 1.2.2 #39
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: publish mkdocs | |
| on: | |
| pull_request: | |
| types: [closed] | |
| branches: | |
| - develop | |
| - main | |
| workflow_dispatch: | |
| jobs: | |
| versioning: | |
| if: ${{ github.event.pull_request.merged == true && (github.event.pull_request.base.ref == 'develop' || github.event.pull_request.base.ref == 'main') }} | |
| name: Extract Release Version | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.extract_version.outputs.version }} | |
| is_release: ${{ steps.extract_version.outputs.is_release }} | |
| steps: | |
| - name: Extract Version from Source/Target Branch | |
| id: extract_version | |
| run: | | |
| SOURCE_BRANCH="${GITHUB_HEAD_REF:-$GITHUB_REF_NAME}" | |
| TARGET_BRANCH="${GITHUB_BASE_REF}" | |
| if [[ "$TARGET_BRANCH" == "develop" ]]; then | |
| # When targeting develop, version should be the target branch name itself | |
| VERSION="$TARGET_BRANCH" | |
| else | |
| # Target is main (per job condition). Keep existing behavior based on the source branch | |
| # If branch contains a slash, take the second segment; otherwise use the whole branch name | |
| if [[ "$SOURCE_BRANCH" == *"/"* ]]; then | |
| VERSION="$(echo "$SOURCE_BRANCH" | cut -d'/' -f2)" | |
| else | |
| VERSION="$SOURCE_BRANCH" | |
| fi | |
| # If this is a release branch, trim to major.minor (e.g., 1.2.3 -> 1.2) | |
| if [[ "$SOURCE_BRANCH" == release/* ]]; then | |
| IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION" | |
| if [[ -n "$MAJOR" && -n "$MINOR" ]]; then | |
| VERSION="${MAJOR}.${MINOR}.x" | |
| fi | |
| fi | |
| fi | |
| if [ -z "$VERSION" ]; then | |
| echo "Error: No semantic release version found. Source: $SOURCE_BRANCH, Target: $TARGET_BRANCH" | |
| exit 1 | |
| fi | |
| # Determine if this is a release branch (source starts with release/) | |
| IS_RELEASE="false" | |
| if [[ "$SOURCE_BRANCH" == release/* ]]; then | |
| IS_RELEASE="true" | |
| fi | |
| # Expose outputs for downstream steps/jobs | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| echo "is_release=$IS_RELEASE" >> "$GITHUB_OUTPUT" | |
| - name: Print Tag Version | |
| run: | | |
| echo "Identified release semantic version: ${{ steps.extract_version.outputs.version }}" | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: [ versioning ] | |
| permissions: | |
| contents: write | |
| pages: write | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ github.event.pull_request.merge_commit_sha }} | |
| - name: Set up Python | |
| uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # 6.0.0 | |
| with: | |
| python-version: 3.x | |
| - name: Configure Git user for mike | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV | |
| - uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # 5.0.3 | |
| with: | |
| key: mkdocs-material-${{ env.cache_id }} | |
| path: ~/.cache | |
| restore-keys: | | |
| mkdocs-material- | |
| - run: pip install mkdocs-material | |
| - run: pip install mkdocs-git-revision-date-localized-plugin | |
| - run: pip install mkdocs-git-committers-plugin-2 | |
| - run: pip install Pygments | |
| - run: pip install mkdocs-include-markdown-plugin | |
| - run: pip install pymdown-extensions | |
| - run: pip install mike | |
| - run: pip install mkdocs-open-in-new-tab==1.0.8 | |
| - name: Deploy docs without latest alias | |
| if: ${{ needs.versioning.outputs.is_release != 'true' }} | |
| run: mike deploy ${{ needs.versioning.outputs.version }} --push | |
| - name: Deploy docs with latest alias | |
| if: ${{ needs.versioning.outputs.is_release == 'true' }} | |
| run: mike deploy ${{ needs.versioning.outputs.version }} latest --push --update-aliases | |
| - name: Set default latest | |
| if: ${{ needs.versioning.outputs.is_release == 'true' }} | |
| run: mike set-default --push latest | |