From 837fb21c5291eef6285c2e168eef0620b99a5394 Mon Sep 17 00:00:00 2001 From: moloch-- <875022+moloch--@users.noreply.github.com> Date: Mon, 2 Mar 2026 16:18:20 -0800 Subject: [PATCH] Add publish workflow --- .github/workflows/publish.yml | 46 +++++++++++++++++++++++++++++++++++ README.md | 3 ++- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..ba9ba6a --- /dev/null +++ b/.github/workflows/publish.yml @@ -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 }} diff --git a/README.md b/README.md index 6c09db1..3751ab2 100644 --- a/README.md +++ b/README.md @@ -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