Publish to Registries #5
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
| # .github/workflows/publish.yml | |
| # | |
| # SPDX-License-Identifier: CC-BY-4.0 OR GPL-3.0-or-later | |
| # This file is part of Network Pro | |
| name: Publish to Registries | |
| on: | |
| workflow_run: | |
| workflows: ["Build Site and Deploy to GH Pages"] | |
| types: | |
| - completed | |
| # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| # Allow one concurrent deployment | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: true | |
| jobs: | |
| publish-npm: | |
| if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4.2.2 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4.4.0 | |
| with: | |
| node-version: lts/* | |
| registry-url: https://registry.npmjs.org/ | |
| check-latest: true | |
| cache: npm | |
| - name: Cache Node.js modules | |
| uses: actions/cache@v4.2.3 | |
| with: | |
| path: ~/.npm | |
| key: ${{ runner.os }}-node-lts-${{ hashFiles('package-lock.json', 'package.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-node-lts-build- | |
| ${{ runner.os }}-node-lts- | |
| ${{ runner.os }}- | |
| - name: Authenticate with npm | |
| run: | | |
| echo "@networkpro:registry=https://registry.npmjs.org/" > .npmrc | |
| echo "//registry.npmjs.org/:_authToken=${NPM_NETPRO}" >> .npmrc | |
| env: | |
| NPM_NETPRO: ${{ secrets.NPM_NETPRO }} | |
| - name: Install Node.js dependencies | |
| run: npm ci | |
| # MkDocs Integration Begins | |
| - name: Set up Python | |
| uses: actions/setup-python@v5.6.0 | |
| with: | |
| python-version: "3.13" | |
| - name: Install MkDocs and plugins | |
| run: | | |
| pip install mkdocs mkdocs-material mkdocs-material-extensions mkdocs-get-deps mkdocs-rss-plugin | |
| # Strict mode temporarily disabled as workaround for mkdocs-material | |
| - name: Build MkDocs documentation | |
| run: mkdocs build | |
| # MkDocs Integration Ends | |
| - name: Set up Git user | |
| run: | | |
| git config --global user.email "github@sl.neteng.cc" | |
| git config --global user.name "SunDevil311" | |
| - name: Copy package.json to build directory | |
| run: cp package.json build/ | |
| - name: Publish package | |
| working-directory: ./build | |
| run: npm publish --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_NETPRO }} |