Publish to Registries #8
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 | |
# | |
# Copyright © 2025 Network Pro Strategies (Network Pro™) | |
# 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: 'build-and-publish' | |
cancel-in-progress: true | |
jobs: | |
build: | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 24 | |
cache: npm | |
cache-dependency-path: package-lock.json | |
- name: Upgrade npm | |
run: | | |
corepack enable | |
npm install -g npm@11.4.2 | |
- name: Install Node.js dependencies | |
run: npm ci | |
# MkDocs Integration | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.13' | |
- name: Install Python dependencies | |
run: pip install -r requirements.txt | |
- name: Build MkDocs documentation | |
run: mkdocs build | |
# Remove build artifacts to avoid publishing them | |
- name: Clean build directory | |
run: rm -rf build/ | |
# Upload clean source code | |
- name: Upload repository artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: repo-artifacts | |
path: ./ | |
publish-npm: | |
needs: build | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: Download repository artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: repo-artifacts | |
path: ./ | |
- name: Set up Node.js for npmjs | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 24 | |
registry-url: https://registry.npmjs.org/ | |
cache: npm | |
- name: Upgrade npm | |
run: | | |
corepack enable | |
npm install -g npm@11.4.2 | |
- name: Set up Git user | |
run: | | |
git config --global user.email "github@sl.neteng.cc" | |
git config --global user.name "SunDevil311" | |
- name: Publish package to npmjs | |
run: npm publish --access public | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_NETPRO }} | |
publish-gpr: | |
needs: build | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: Download repository artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: repo-artifacts | |
path: ./ | |
- name: Set up Node.js for GPR | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 24 | |
registry-url: https://npm.pkg.github.com/ | |
cache: npm | |
- name: Upgrade npm | |
run: | | |
corepack enable | |
npm install -g npm@11.4.2 | |
- name: Set up Git user | |
run: | | |
git config --global user.email "github@sl.neteng.cc" | |
git config --global user.name "SunDevil311" | |
- name: Update package name for GPR | |
run: | | |
sed -i 's/"name": ".*"/"name": "@netwk-pro\/docs"/' package.json | |
- name: Publish package to GPR | |
run: npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NWPRO_GPR }} |