Skip to content

Publish to npm

Publish to npm #32

Workflow file for this run

# Publishes @mlvscan/wasm-core.
# Requires NPM_TOKEN secret in repo Settings → Secrets.
# Create token at npmjs.com → Access Tokens → "Automation" or "Publish", then add as NPM_TOKEN.
name: Publish to npm
on:
release:
types: [published]
workflow_run:
workflows: ["Auto Release on Version Change"]
types:
- completed
workflow_dispatch:
jobs:
publish:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'release' || (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') }}
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Extract version
id: get_version
run: |
if [ "${{ github.event_name }}" == "release" ]; then
VERSION="${{ github.event.release.tag_name }}"
VERSION=${VERSION#v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
elif [[ "${{ github.ref }}" == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
else
VERSION=$(grep -oP '<Version>\K[^<]+' Directory.Build.props)
echo "version=$VERSION" >> $GITHUB_OUTPUT
fi
shell: bash
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: '8.0.x'
- name: Install WASM workload
run: dotnet workload install wasm-tools-net8 --skip-manifest-update
- name: Generate schema artifacts
run: dotnet run --project Tools/MLVScan.SchemaGen/MLVScan.SchemaGen.csproj
- name: Publish WASM
run: dotnet publish MLVScan.WASM/MLVScan.WASM.csproj -c Release
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
registry-url: 'https://registry.npmjs.org'
cache: 'npm'
cache-dependency-path: MLVScan.WASM/npm/package-lock.json
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Install npm dependencies
working-directory: MLVScan.WASM/npm
run: npm ci
- name: Copy Blazor framework to dist
working-directory: MLVScan.WASM/npm
run: npm run copy:framework
- name: Build TypeScript
working-directory: MLVScan.WASM/npm
run: npm run build
- name: Set package version
working-directory: MLVScan.WASM/npm
run: npm version ${{ steps.get_version.outputs.version }} --no-git-tag-version --allow-same-version
- name: Publish to npm
working-directory: MLVScan.WASM/npm
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Summary
run: |
echo "### ✅ npm package published" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Package:** \`@mlvscan/wasm-core\`" >> $GITHUB_STEP_SUMMARY
echo "**Version:** ${{ steps.get_version.outputs.version }}" >> $GITHUB_STEP_SUMMARY