Skip to content

Commit e63e54d

Browse files
committed
chore: change to manual publish npm
1 parent a0cf493 commit e63e54d

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

.github/workflows/npm-publish.yml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
name: Publish to npm
22

33
on:
4-
push:
5-
branches:
6-
- main # Run when a push is made to the main branch
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: "Version to publish (e.g., 0.1.0, 0.2.0-beta)"
8+
required: false
9+
default: ""
10+
tag:
11+
description: "NPM tag (e.g., latest, dev)"
12+
required: false
13+
default: "dev"
714

815
jobs:
916
build-and-publish:
@@ -34,15 +41,16 @@ jobs:
3441
run: |
3542
# Get the current version from package.json
3643
CURRENT_VERSION=$(jq -r '.version' package.json)
37-
38-
# Generate a version with just the date suffix
39-
DATE_VERSION=$(date +'%Y%m%d')
40-
VERSION="${CURRENT_VERSION}-${DATE_VERSION}"
41-
42-
# Store the version and package name in environment variables for later steps
43-
echo "PACKAGE_VERSION=${VERSION}" >> $GITHUB_ENV
44-
echo "PACKAGE_NAME=@bytebase/dbhub" >> $GITHUB_ENV
45-
44+
45+
# Use input version if provided, otherwise use current version
46+
if [ -n "${{ inputs.version }}" ]; then
47+
VERSION="${{ inputs.version }}"
48+
else
49+
VERSION="${CURRENT_VERSION}"
50+
fi
51+
52+
echo "Publishing version: ${VERSION} with tag: ${{ inputs.tag }}"
53+
4654
# Update package.json to use @bytebase scope and set version
4755
jq --arg version "$VERSION" '.name = "@bytebase/dbhub" | .version = $version' package.json > package.json.tmp
4856
mv package.json.tmp package.json
@@ -55,15 +63,7 @@ jobs:
5563
jq '.bin = {"dbhub": "dist/index.js"}' package.json > package.json.tmp
5664
mv package.json.tmp package.json
5765
58-
- name: Try to unpublish existing daily version
59-
run: |
60-
# Try to unpublish any existing package with the same version from today
61-
# The || true ensures the workflow continues even if the package doesn't exist
62-
npm unpublish ${{ env.PACKAGE_NAME }}@${{ env.PACKAGE_VERSION }} || true
63-
env:
64-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
65-
6666
- name: Publish to npm
67-
run: pnpm publish --no-git-checks --access public --tag dev
67+
run: pnpm publish --no-git-checks --access public --tag ${{ inputs.tag }}
6868
env:
6969
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)