Add publish workflow

This commit is contained in:
moloch--
2026-03-02 16:18:20 -08:00
parent ec47644788
commit 837fb21c52
2 changed files with 48 additions and 1 deletions
+46
View File
@@ -0,0 +1,46 @@
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 }}
+2 -1
View File
@@ -4,7 +4,8 @@ Sliver-script is a TypeScript/JavaScript client library for Sliver, it can be us
This library targets modern Sliver protobuf/gRPC APIs and provides a strongly-typed TypeScript-first client.
[![NPM Publish](https://github.com/moloch--/sliver-script/actions/workflows/publish.yml/badge.svg)](https://github.com/moloch--/sliver-script/actions/workflows/publish.yml)
[![Publish](https://github.com/moloch--/sliver-script/actions/workflows/publish.yml/badge.svg)](https://github.com/moloch--/sliver-script/actions/workflows/publish.yml)
[![npm version](https://img.shields.io/npm/v/sliver-script.svg)](https://www.npmjs.com/package/sliver-script)
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
### Install