Publish to Registries #45
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 | |
permissions: | |
actions: read | |
contents: read | |
# Allow one concurrent deployment | |
concurrency: | |
group: 'publish' | |
cancel-in-progress: true | |
# cspell:ignore userconfig | |
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 [email protected] | |
- 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 Python dependencies | |
run: pip install -r requirements.txt | |
# Strict mode disabled for mkdocs-material | |
- name: Build MkDocs documentation | |
run: mkdocs build | |
# Remove build artifacts | |
#- name: Clean build directory | |
# run: rm -rf build/ | |
# Create Git archive of version-controlled files | |
- name: Create clean source archive | |
run: git archive --format=tar.gz --output=clean-source.tar.gz HEAD | |
- name: Upload source archive | |
uses: actions/upload-artifact@v4 | |
with: | |
name: clean-source | |
path: clean-source.tar.gz | |
publish-npm: | |
needs: build | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: Download clean source archive | |
uses: actions/download-artifact@v4 | |
with: | |
name: clean-source | |
path: ./ | |
- name: Extract source archive | |
run: tar -xzf clean-source.tar.gz | |
- name: Remove extracted source archive | |
run: rm clean-source.tar.gz | |
- name: Set up Node.js for npmjs | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 24 | |
registry-url: https://registry.npmjs.org/ | |
cache: npm | |
cache-dependency-path: package-lock.json | |
- name: Upgrade npm | |
run: | | |
corepack enable | |
npm install -g [email protected] | |
- name: Install Node.js dependencies | |
run: npm ci | |
- name: Set up Git user | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "SunDevil311" | |
- name: Print npm config and registry info | |
run: | | |
echo "🔍 NPM registry (from config):" | |
npm config get registry | |
echo "🔍 NPM user config location:" | |
echo "$NPM_CONFIG_USERCONFIG" | |
echo "🔍 .npmrc contents:" | |
cat "$NPM_CONFIG_USERCONFIG" || echo "❌ No .npmrc found" | |
echo "🔐 Token prefix:" | |
echo "${NODE_AUTH_TOKEN:0:4}********" | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_NETPRO }} | |
- name: Verify npm authentication | |
run: npm whoami | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_NETPRO }} | |
- 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 clean source archive | |
uses: actions/download-artifact@v4 | |
with: | |
name: clean-source | |
path: ./ | |
- name: Extract source archive | |
run: tar -xzf clean-source.tar.gz | |
- name: Remove extracted source archive | |
run: rm clean-source.tar.gz | |
- 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 | |
cache-dependency-path: package-lock.json | |
- name: Upgrade npm | |
run: | | |
corepack enable | |
npm install -g [email protected] | |
- name: Install Node.js dependencies | |
run: npm ci | |
- 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 | |
- name: Print npm config and registry info | |
run: | | |
echo "🔍 NPM registry (from config):" | |
npm config get registry | |
echo "🔍 NPM user config location:" | |
echo "$NPM_CONFIG_USERCONFIG" | |
echo "🔍 .npmrc contents:" | |
cat "$NPM_CONFIG_USERCONFIG" || echo "❌ No .npmrc found" | |
echo "🔐 Token prefix:" | |
echo "${NODE_AUTH_TOKEN:0:4}********" | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NWPRO_GPR }} | |
- name: Verify npm authentication | |
run: npm whoami --registry=https://npm.pkg.github.com/ | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NWPRO_GPR }} | |
- name: Publish package to GPR | |
run: npm publish --registry=https://npm.pkg.github.com/ | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NWPRO_GPR }} |