Merge branch 'docsifyjs:develop' into develop #11
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: Build & Deploy Latest | |
| on: | |
| push: | |
| branches: [develop] # covers your own future commits to develop | |
| workflow_run: | |
| workflows: ['Sync Fork with Upstream'] | |
| types: [completed] # covers commits pulled in by the sync job | |
| workflow_dispatch: | |
| inputs: | |
| release_version: | |
| description: 'Optional: tag this build, e.g. 5.0.0 or 5.4.1-custom.1 (leave blank for a plain untagged build)' | |
| required: false | |
| allow_major_bump: | |
| description: 'Allow publishing a major version other than the pinned one below (e.g. once you have verified v6 compatibility)' | |
| type: boolean | |
| default: false | |
| permissions: | |
| contents: write | |
| env: | |
| # Bump this deliberately, in its own commit, once you've verified compatibility | |
| # with a new major version. Until then this blocks any accidental publish of it. | |
| ALLOWED_MAJOR_VERSION: '5' | |
| jobs: | |
| build-and-deploy: | |
| if: > | |
| github.event_name != 'workflow_run' || | |
| github.event.workflow_run.conclusion == 'success' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v7 | |
| with: | |
| ref: develop | |
| - uses: actions/setup-node@v7 | |
| with: | |
| node-version: 'lts/*' | |
| cache: 'npm' | |
| - name: Guard against unexpected major version bump | |
| run: | | |
| MAJOR=$(node -p "require('./package.json').version.split('.')[0]") | |
| if [ "$MAJOR" != "$ALLOWED_MAJOR_VERSION" ] && [ "${{ github.event.inputs.allow_major_bump }}" != "true" ]; then | |
| echo "::error::package.json is version $MAJOR.x, but this workflow is pinned to major version $ALLOWED_MAJOR_VERSION. Refusing to build/publish β a new major version may break your projects. To proceed anyway, either re-run this workflow manually with 'allow_major_bump' checked, or update ALLOWED_MAJOR_VERSION in this file once you've verified compatibility." | |
| exit 1 | |
| fi | |
| - run: npm ci --ignore-scripts | |
| - run: npm run build | |
| - name: Resolve tag (only set if you typed a release_version above) | |
| id: tag | |
| run: | | |
| VERSION="${{ github.event.inputs.release_version }}" | |
| if [ -n "$VERSION" ]; then | |
| echo "name=v$VERSION" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "name=" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Publish dist/ to the dist branch | |
| uses: peaceiris/actions-gh-pages@v4 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./dist | |
| publish_branch: dist | |
| keep_files: false | |
| # HEADS UP: this creates the version tag (like v5.0.0) on the "dist" | |
| # branch, not on "develop". That's on purpose. "develop" only has the | |
| # source code β the actual docsify.min.js file doesn't exist until | |
| # this workflow builds it and puts it on the "dist" branch. If the | |
| # tag pointed at "develop" instead, the CDN link would 404. | |
| # | |
| # So: don't create version tags yourself using GitHub's "Draft a new | |
| # release" page (it always tags whatever branch you pick, usually | |
| # "develop"). Instead, type the version into the "release_version" | |
| # box when running this workflow manually β that's the only place | |
| # tags should get created. (We hit this exact bug once already β | |
| # see the "Guard against unexpected major version bump" step above | |
| # for a similar safety check, and keep this one in mind too.) | |
| tag_name: ${{ steps.tag.outputs.name }} | |
| tag_message: 'Pinned build assets for ${{ steps.tag.outputs.name }}' |