diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml index f682eea1..bd891d15 100644 --- a/.github/workflows/deploy-docs.yml +++ b/.github/workflows/deploy-docs.yml @@ -6,6 +6,12 @@ on: - main paths: - 'docs/**' + - 'js/**' + - 'less/**' + - 'sass/**' + - 'Gruntfile.js' + - 'package.json' + - 'package-lock.json' - '.github/workflows/deploy-docs.yml' workflow_dispatch: diff --git a/.github/workflows/publish_npm_release.yml b/.github/workflows/publish_npm_release.yml index 502cd3bf..23ad88e1 100644 --- a/.github/workflows/publish_npm_release.yml +++ b/.github/workflows/publish_npm_release.yml @@ -6,21 +6,42 @@ on: - 'v*.*.*' permissions: - contents: read + contents: write + pages: write + id-token: write jobs: publish: runs-on: ubuntu-latest name: Publish crestapps-bootstrap-select + outputs: + version: ${{ steps.release_meta.outputs.version }} + docs_version: ${{ steps.release_meta.outputs.docs_version }} + should_snapshot_docs: ${{ steps.release_meta.outputs.should_snapshot_docs }} steps: - - name: Get the version - id: get_version + - name: Parse release metadata + id: release_meta run: | VERSION="${GITHUB_REF_NAME#v}" - echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT + IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION" + if [[ -z "$MAJOR" || -z "$MINOR" || -z "$PATCH" ]]; then + echo "::error title=Invalid version tag::Expected a semantic version tag like v1.2.3, received '$GITHUB_REF_NAME'." + exit 1 + fi + + echo "version=${VERSION}" >> "$GITHUB_OUTPUT" + echo "docs_version=${MAJOR}.${MINOR}" >> "$GITHUB_OUTPUT" + + if [[ "$PATCH" == "0" ]]; then + echo "should_snapshot_docs=true" >> "$GITHUB_OUTPUT" + else + echo "should_snapshot_docs=false" >> "$GITHUB_OUTPUT" + fi shell: bash - uses: actions/checkout@v6 + with: + fetch-depth: 0 - uses: actions/setup-node@v6 with: @@ -50,5 +71,125 @@ jobs: env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} run: | - npm version "${{ steps.get_version.outputs.VERSION }}" --no-git-tag-version --allow-same-version + npm version "${{ steps.release_meta.outputs.version }}" --no-git-tag-version --allow-same-version npm publish --access public --tag latest + + snapshot_docs: + runs-on: ubuntu-latest + name: Snapshot release docs + needs: publish + if: needs.publish.outputs.should_snapshot_docs == 'true' + permissions: + contents: write + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + ref: ${{ github.sha }} + + - name: Setup node + uses: actions/setup-node@v6 + with: + node-version: '20.19' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Skip existing docs snapshot + id: snapshot_state + env: + DOCS_VERSION: ${{ needs.publish.outputs.docs_version }} + run: | + git fetch origin main --depth=1 + + if git cat-file -e "origin/main:docs/versioned_sidebars/version-${DOCS_VERSION}-sidebars.json" 2>/dev/null; then + echo "should_commit=false" >> "$GITHUB_OUTPUT" + exit 0 + fi + + echo "should_commit=true" >> "$GITHUB_OUTPUT" + + - name: Create docs snapshot + if: steps.snapshot_state.outputs.should_commit == 'true' + env: + DOCS_VERSION: ${{ needs.publish.outputs.docs_version }} + run: | + pushd docs + npx docusaurus docs:version "$DOCS_VERSION" + popd + + - name: Push docs snapshot to main + if: steps.snapshot_state.outputs.should_commit == 'true' + env: + DOCS_VERSION: ${{ needs.publish.outputs.docs_version }} + run: | + if git diff --quiet -- docs/versions.json docs/versioned_docs docs/versioned_sidebars; then + echo "No docs snapshot changes to commit." + exit 0 + fi + + SNAPSHOT_DIR="$RUNNER_TEMP/docs-version-$DOCS_VERSION" + mkdir -p "$SNAPSHOT_DIR" + cp docs/versions.json "$SNAPSHOT_DIR/versions.json" + cp -R docs/versioned_docs "$SNAPSHOT_DIR/versioned_docs" + cp -R docs/versioned_sidebars "$SNAPSHOT_DIR/versioned_sidebars" + + git switch -C docs-version-sync origin/main + rm -rf docs/versioned_docs docs/versioned_sidebars + mkdir -p docs/versioned_docs docs/versioned_sidebars + cp "$SNAPSHOT_DIR/versions.json" docs/versions.json + cp -R "$SNAPSHOT_DIR/versioned_docs/." docs/versioned_docs/ + cp -R "$SNAPSHOT_DIR/versioned_sidebars/." docs/versioned_sidebars/ + + if git diff --quiet -- docs/versions.json docs/versioned_docs docs/versioned_sidebars; then + echo "Main already contains the ${DOCS_VERSION} docs snapshot." + exit 0 + fi + + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git add docs/versions.json docs/versioned_docs docs/versioned_sidebars + git commit -m "docs: snapshot ${DOCS_VERSION} release docs" + git push origin HEAD:main + + build_docs: + runs-on: ubuntu-latest + name: Build release docs + needs: + - publish + - snapshot_docs + if: always() && needs.publish.result == 'success' && (needs.snapshot_docs.result == 'success' || needs.snapshot_docs.result == 'skipped') + steps: + - uses: actions/checkout@v6 + with: + ref: main + + - name: Setup node + uses: actions/setup-node@v6 + with: + node-version: '20.19' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Build docs site + run: npm run docs:build + + - name: Upload Pages artifact + uses: actions/upload-pages-artifact@v3 + with: + path: docs/build + + deploy_docs: + runs-on: ubuntu-latest + name: Deploy release docs + needs: build_docs + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d5b38e2..e0f0b3cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +# v1.1.0 (CrestApps fork) + +### Highlights + +- Added release-time docs versioning for `major.minor` releases so published docs + snapshots remain selectable after future updates. +- Fixed Font Awesome loading in the Docusaurus site by bundling the CSS and + webfonts with the docs build. +- Expanded the docs examples page with a dedicated list-style selected-items + example. + # v1.0.1 (CrestApps fork) This is the first release of the CrestApps fork of diff --git a/Gruntfile.js b/Gruntfile.js index 5990a37e..4977b95c 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -140,12 +140,25 @@ module.exports = function (grunt) { copy: { docs: { - expand: true, - cwd: 'dist/', - src: [ - '**/*' - ], - dest: 'docs/static/dist/' + files: [ + { + expand: true, + cwd: 'dist/', + src: [ + '**/*' + ], + dest: 'docs/static/dist/' + }, + { + expand: true, + cwd: 'node_modules/@fortawesome/fontawesome-free/', + src: [ + 'css/all.min.css', + 'webfonts/*' + ], + dest: 'docs/static/vendor/fontawesome/' + } + ] } }, diff --git a/README.md b/README.md index c239f91b..d8689f67 100644 --- a/README.md +++ b/README.md @@ -74,11 +74,11 @@ jsDelivr. Prefer pinning an explicit package version in production: - - + + ``` -You can replace `@1.0.0` with the version you want to consume. During +You can replace `@1.1.0` with the version you want to consume. During development, `@latest` also works, but a fixed version is safer for production deployments. diff --git a/docs/docs/examples.mdx b/docs/docs/examples.mdx index 2a6a0ea2..ec093668 100644 --- a/docs/docs/examples.mdx +++ b/docs/docs/examples.mdx @@ -12,42 +12,30 @@ import LiveExample from '@site/src/components/LiveExample'; The examples use the vanilla JavaScript / Bootstrap 5+ API: `new Selectpicker(el)` or the `selectpicker` class, which auto-initializes. jQuery is not required. ::: -
Native select:
- + +Become this:
+Enhanced with bootstrap-select:
- `} + +