Publish to Registries #20
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: "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 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: lts/* | |
check-latest: true | |
cache: npm | |
cache-dependency-path: package-lock.json | |
- name: Install Node.js dependencies | |
run: npm ci | |
# Ensure MkDocs builds successfully | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
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 disabled as workaround for mkdocs-material | |
- 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: ./repo | |
- name: Set up Node.js for npmjs | |
uses: actions/setup-node@v4 | |
with: | |
node-version: lts/* | |
check-latest: true | |
registry-url: https://registry.npmjs.org/ | |
- name: Set up Git user | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "SunDevil311" | |
- name: Publish package to npmjs | |
run: npm publish --access public | |
working-directory: ./repo | |
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: ./repo | |
- name: Set up Node.js for GPR | |
uses: actions/setup-node@v4 | |
with: | |
node-version: lts/* | |
check-latest: true | |
registry-url: https://npm.pkg.github.com/ | |
- name: Set up Git user | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "SunDevil311" | |
- name: Update package name for GPR | |
run: | | |
sed -i 's/"name": ".*"/"name": "@netwk-pro\/blog"/' package.json | |
working-directory: ./repo | |
- name: Publish package to GPR | |
run: npm publish | |
working-directory: ./repo | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.GH_PAT }} |