diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml new file mode 100644 index 0000000..980705b --- /dev/null +++ b/.github/workflows/npm-publish.yml @@ -0,0 +1,50 @@ +name: NPM Publish + +on: + release: + types: [published] + workflow_dispatch: + inputs: + tag: + description: 'Tag to publish (vX.Y.Z)' + required: true + type: string + +jobs: + publish: + runs-on: ubuntu-latest + permissions: + contents: read + env: + RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.event.release.tag_name }} + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ env.RELEASE_TAG }} + + - name: Use Node.js 22.x + uses: actions/setup-node@v4 + with: + node-version: 22.x + registry-url: 'https://registry.npmjs.org' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Check Version + run: | + TAG="${RELEASE_TAG#v}" + PKG=$(node -p "require('./package.json').version") + if [ "$PKG" != "$TAG" ]; then + echo "Version mismatch: Tag $TAG vs Package $PKG" >&2 + exit 1 + fi + + - name: Build + run: npm run build + + - name: Publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + run: npm publish --access public diff --git a/package.json b/package.json index 76f63bc..d95bf7e 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,12 @@ "bin": { "cloudsqlctl": "./dist/cli.cjs" }, + "files": [ + "dist", + "README.md", + "LICENSE", + "CHANGELOG.md" + ], "engines": { "node": ">=22.0.0" },