chore: update gh action #2
Workflow file for this run
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 and Release to npm | |
on: | |
push: | |
branches: | |
- 'deploy-test' | |
# Cancel any previous run (see: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency) | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
release-job: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: ".nvmrc" | |
cache: "npm" | |
- name: Install Dependencies and Release | |
id: main | |
run: | | |
npm ci | |
npm run release | |
env: | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Generate documentation | |
run: npm run typedoc | |
- name: Upload dist artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: dist | |
path: dist/ | |
- name: Upload docs artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: typedoc-docs | |
path: docs/ | |
deploy-job: | |
needs: release-job | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Download dist artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: dist | |
path: dist/ | |
- name: Download typedoc docs artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: typedoc-docs | |
path: docs/ | |
- name: Prepare examples directory | |
run: | | |
# Remove the alias to dist (if it exists) | |
find examples -name "* alias" -delete | |
find examples -name "dist" -type l -delete | |
rm -rf examples/dist | |
# Copy the actual dist content to examples/dist | |
cp -r dist examples/dist | |
- name: Prepare docs directory | |
run: | | |
# Copy examples to docs directory | |
cp -r examples docs/ | |
# Delete any remaining symbolic links and macOS aliases under the docs directory | |
find docs -type l -delete | |
find docs -name "* alias" -delete | |
find docs -type l -delete | |
- name: Setup Pages | |
uses: actions/configure-pages@v5 | |
- name: Upload to GitHub Pages | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
name: github-pages | |
path: ./docs | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 |