-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: set up GitHub Actions to publish NPM package and API docs (#2)
* ci: set up GitHub Actions to publish NPM package and API docs * fix: missing 'then' in the prepare_tag step
- Loading branch information
1 parent
95fa641
commit 98ebd08
Showing
3 changed files
with
87 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# This workflow will publish API docs to GitHub Pages when a new release tag is added to the main branch | ||
|
||
name: Publish API docs to GitHub Pages | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- 'v*.*.*' | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-22.04 | ||
permissions: | ||
contents: write | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
steps: | ||
- name: Checkout the repository | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.ref }} | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
|
||
- name: Install | ||
run: npm ci | ||
|
||
- name: Build docs | ||
run: npm run docs | ||
|
||
- name: Prepare tag | ||
id: prepare_tag | ||
if: startsWith(github.ref, 'refs/tags/v') | ||
run: | | ||
LATEST_TAG=$(git tag -l --sort=-v:refname | head -n 1) | ||
echo "Latest tag is $LATEST_TAG" | ||
echo "Current tag is $GITHUB_REF_NAME" | ||
if [ "${GITHUB_REF_NAME}" != "${LATEST_TAG}" ]; then | ||
echo "Not the latest tag, skipping deploy." | ||
exit 0 | ||
else | ||
echo "This is the latest tag, proceeding with deploy." | ||
fi | ||
echo "DEPLOY_TAG_NAME=deploy-${GITHUB_REF_NAME}" >> "${GITHUB_OUTPUT}" | ||
- name: Deploy | ||
uses: peaceiris/actions-gh-pages@v4 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: ./docs | ||
tag_name: ${{ steps.prepare_tag.outputs.DEPLOY_TAG_NAME }} | ||
tag_message: 'Deployment ${{ github.ref_name }}' |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# This workflow will publish a package to NPM registry when a release is published | ||
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages | ||
|
||
name: Publish to NPM on release | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout the repository at the release tag | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.release.tag_name }} | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
registry-url: https://registry.npmjs.org/ | ||
|
||
- name: Publish the package to NPM | ||
run: npm run publish:dist | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }} |
This file contains 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