Skip to content
Merged
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
6 changes: 6 additions & 0 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
151 changes: 146 additions & 5 deletions .github/workflows/publish_npm_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
25 changes: 19 additions & 6 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/'
}
]
}
},

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ jsDelivr. Prefer pinning an explicit package version in production:
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js"></script>

<!-- @crestapps/bootstrap-select from jsDelivr -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@crestapps/bootstrap-select@1.0.1/dist/css/bootstrap-select.min.css">
<script src="https://cdn.jsdelivr.net/npm/@crestapps/bootstrap-select@1.0.1/dist/js/bootstrap-select.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@crestapps/bootstrap-select@1.1.0/dist/css/bootstrap-select.min.css">
<script src="https://cdn.jsdelivr.net/npm/@crestapps/bootstrap-select@1.1.0/dist/js/bootstrap-select.min.js"></script>
```

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.

Expand Down
Loading