Skip to content

chore: upgrade to 0.0.2 #6

chore: upgrade to 0.0.2

chore: upgrade to 0.0.2 #6

Workflow file for this run

name: Publish to npm
on:
push:
branches:
- main # Run when a push is made to the main branch
jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
registry-url: "https://registry.npmjs.org/"
scope: "@bytebase"
- name: Install pnpm
uses: pnpm/action-setup@v3
with:
version: latest
- name: Install dependencies
run: pnpm install
- name: Build
run: pnpm run build
- name: Update package.json for npm publishing
run: |
# Get the current version from package.json
CURRENT_VERSION=$(jq -r '.version' package.json)
# Generate a version with just the date suffix
DATE_VERSION=$(date +'%Y%m%d')
VERSION="${CURRENT_VERSION}-${DATE_VERSION}"
# Store the version and package name in environment variables for later steps
echo "PACKAGE_VERSION=${VERSION}" >> $GITHUB_ENV
echo "PACKAGE_NAME=@bytebase/dbhub" >> $GITHUB_ENV
# Update package.json to use @bytebase scope and set version
jq --arg version "$VERSION" '.name = "@bytebase/dbhub" | .version = $version' package.json > package.json.tmp
mv package.json.tmp package.json
# Set files to include in the package
jq '.files = ["dist/**/*", "LICENSE", "README.md"]' package.json > package.json.tmp
mv package.json.tmp package.json
# Add bin entry for CLI usage
jq '.bin = {"dbhub": "dist/index.js"}' package.json > package.json.tmp
mv package.json.tmp package.json
- name: Try to unpublish existing daily version
run: |
# Try to unpublish any existing package with the same version from today
# The || true ensures the workflow continues even if the package doesn't exist
npm unpublish ${{ env.PACKAGE_NAME }}@${{ env.PACKAGE_VERSION }} || true
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish to npm
run: pnpm publish --no-git-checks --access public --tag dev
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}