mirror of
https://github.com/moloch--/sliver-script
synced 2026-06-08 16:08:26 +00:00
47 lines
1.3 KiB
YAML
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 }}
|