Files
moloch---sliver-script/.github/workflows/publish.yml
T
2026-03-02 16:18:20 -08:00

47 lines
1.3 KiB
YAML

name: Publish
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
jobs:
publish:
runs-on: ubuntu-latest
environment: publish
permissions:
contents: read
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/setup-node@v4
with:
node-version: 24.x
registry-url: https://registry.npmjs.org
cache: npm
- name: Verify tag matches package version
if: github.event_name == 'push'
run: |
TAG_NAME="${GITHUB_REF_NAME}"
if [[ ! "${TAG_NAME}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error title=Invalid tag format::Tag '${TAG_NAME}' must use 'vMAJOR.MINOR.PATCH' (example: v2.0.0)."
exit 1
fi
TAG_VERSION="${TAG_NAME#v}"
PACKAGE_VERSION="$(node -p "require('./package.json').version")"
if [ "${TAG_VERSION}" != "${PACKAGE_VERSION}" ]; then
echo "::error title=Version mismatch::Tag '${TAG_NAME}' does not match package.json version '${PACKAGE_VERSION}'."
exit 1
fi
echo "Tag version matches package.json (${PACKAGE_VERSION})."
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}