Skip to content

Publish Node.js Package #28

Publish Node.js Package

Publish Node.js Package #28

Workflow file for this run

name: Publish Node.js Package
on:
release:
types: [created]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Installer pnpm avant d'activer cache: pnpm
- uses: pnpm/action-setup@v3
with:
version: 9.12.2
run_install: false
- uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- run: pnpm -v
- run: pnpm install --frozen-lockfile
- run: pnpm build
- run: pnpm test
- name: Type Check
run: pnpm exec tsc --noEmit
publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
with:
version: 9.12.2
run_install: false
- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/
# Auth + conf dans le .npmrc utilisé par setup-node (NPM_CONFIG_USERCONFIG)
- name: Configure npm auth and pnpm publish settings
run: |
# Auth npmjs
echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > "$NPM_CONFIG_USERCONFIG"
# Eviter les vérifs git/branche pendant pnpm publish
echo "git-checks=false" >> "$NPM_CONFIG_USERCONFIG"
echo "publish-branch=V4" >> "$NPM_CONFIG_USERCONFIG"
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
- run: pnpm -v
# Pas d'options inconnues : pnpm ne supporte pas --yes/--no-interactive
- run: pnpm publish --no-git-checks --publish-branch V4 --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
publish-github-packages:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
with:
version: 9.12.2
run_install: false
- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://npm.pkg.github.com
scope: '@baba33mrt' # <-- adapte au scope de ton package (ex: "@org/nom")
# Auth + conf dans le .npmrc du job (NPM_CONFIG_USERCONFIG)
- name: Configure GPR auth and pnpm publish settings
run: |
# Auth GitHub Packages
echo "//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN_GPKG}" > "$NPM_CONFIG_USERCONFIG"
# Eviter les vérifs git/branche pendant pnpm publish
echo "git-checks=false" >> "$NPM_CONFIG_USERCONFIG"
echo "publish-branch=V4" >> "$NPM_CONFIG_USERCONFIG"
env:
NODE_AUTH_TOKEN_GPKG: ${{ secrets.NODE_AUTH_TOKEN_GPKG }}
- run: pnpm -v
- run: pnpm publish --no-git-checks --publish-branch V4
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN_GPKG }}