diff --git a/.github/workflows/bump-version.yml b/.github/workflows/bump-version.yml index 9decd064..f28e6b4e 100644 --- a/.github/workflows/bump-version.yml +++ b/.github/workflows/bump-version.yml @@ -10,6 +10,7 @@ permissions: jobs: bump-version: runs-on: ubuntu-latest + if: github.ref == 'refs/heads/dev' steps: - name: Checkout @@ -32,13 +33,14 @@ jobs: run: pnpm install --frozen-lockfile - name: Bump version + id: bump run: pnpm run bump-version - name: Create PR uses: peter-evans/create-pull-request@v7 with: - commit-message: 'chore: bump version' - title: '[CI] Bump version' + commit-message: 'chore: bump version ${{ steps.bump.outputs.new_version }}' + title: '[CI] Bump version ${{ steps.bump.outputs.new_version }}' body: Automated changes for bumping version branch: chore/ci-bump-version branch-suffix: timestamp diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml new file mode 100644 index 00000000..0f10a888 --- /dev/null +++ b/.github/workflows/publish-release.yml @@ -0,0 +1,81 @@ +name: Publish and Release + +on: + workflow_dispatch: + push: + branches: + - main + +permissions: + contents: write + +jobs: + publish-and-release: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install pnpm + uses: pnpm/action-setup@v2 + with: + version: 10.12.1 + + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: 20.x + cache: 'pnpm' + registry-url: 'https://registry.npmjs.org' + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Build + run: pnpm run build + + - name: Get version from package.json + id: version + run: | + VERSION=$(node -p "require('./package.json').version") + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "tag=v$VERSION" >> $GITHUB_OUTPUT + + - name: Publish packages + run: pnpm run publish-all + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Generate changelog + id: changelog + run: | + PREVIOUS_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") + + if [ -z "$PREVIOUS_TAG" ]; then + CHANGELOG=$(git log --oneline --no-merges --format="* %s" HEAD) + else + CHANGELOG=$(git log --oneline --no-merges --format="* %s" ${PREVIOUS_TAG}..HEAD) + fi + + if [ -z "$CHANGELOG" ]; then + CHANGELOG="* Automated release" + fi + + echo "changelog<> $GITHUB_OUTPUT + echo "$CHANGELOG" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.version.outputs.tag }} + name: ZenStack Release ${{ steps.version.outputs.tag }} + body: | + ## Changes in this release + + ${{ steps.changelog.outputs.changelog }} + draft: true + prerelease: true diff --git a/package.json b/package.json index f516e39e..7e108667 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "zenstack-v3", - "version": "3.0.0-alpha.5", + "version": "3.0.0-alpha.6", "description": "ZenStack", "packageManager": "pnpm@10.12.1", "scripts": { diff --git a/packages/cli/package.json b/packages/cli/package.json index bc60529e..1f095ebc 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -3,7 +3,7 @@ "publisher": "zenstack", "displayName": "ZenStack CLI", "description": "FullStack database toolkit with built-in access control and automatic API generation.", - "version": "3.0.0-alpha.5", + "version": "3.0.0-alpha.6", "type": "module", "author": { "name": "ZenStack Team" diff --git a/packages/common-helpers/package.json b/packages/common-helpers/package.json index 028e6e6e..da866f6a 100644 --- a/packages/common-helpers/package.json +++ b/packages/common-helpers/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/common-helpers", - "version": "3.0.0-alpha.5", + "version": "3.0.0-alpha.6", "description": "ZenStack Common Helpers", "type": "module", "scripts": { diff --git a/packages/create-zenstack/package.json b/packages/create-zenstack/package.json index 97e262b0..ea1b6143 100644 --- a/packages/create-zenstack/package.json +++ b/packages/create-zenstack/package.json @@ -1,6 +1,6 @@ { "name": "create-zenstack", - "version": "3.0.0-alpha.5", + "version": "3.0.0-alpha.6", "description": "Create a new ZenStack project", "type": "module", "scripts": { diff --git a/packages/eslint-config/package.json b/packages/eslint-config/package.json index b0e1785a..555a07bf 100644 --- a/packages/eslint-config/package.json +++ b/packages/eslint-config/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/eslint-config", - "version": "3.0.0-alpha.5", + "version": "3.0.0-alpha.6", "type": "module", "private": true, "license": "MIT" diff --git a/packages/ide/vscode/package.json b/packages/ide/vscode/package.json index 39d36e80..935a600b 100644 --- a/packages/ide/vscode/package.json +++ b/packages/ide/vscode/package.json @@ -1,7 +1,7 @@ { "name": "zenstack", "publisher": "zenstack", - "version": "3.0.2", + "version": "3.0.3", "displayName": "ZenStack Language Tools", "description": "VSCode extension for ZenStack ZModel language", "private": true, diff --git a/packages/language/package.json b/packages/language/package.json index e8b5f356..d1ef4ed9 100644 --- a/packages/language/package.json +++ b/packages/language/package.json @@ -1,7 +1,7 @@ { "name": "@zenstackhq/language", "description": "ZenStack ZModel language specification", - "version": "3.0.0-alpha.5", + "version": "3.0.0-alpha.6", "license": "MIT", "author": "ZenStack Team", "files": [ diff --git a/packages/runtime/package.json b/packages/runtime/package.json index 3a64c3c7..c9a1d459 100644 --- a/packages/runtime/package.json +++ b/packages/runtime/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/runtime", - "version": "3.0.0-alpha.5", + "version": "3.0.0-alpha.6", "description": "ZenStack Runtime", "type": "module", "scripts": { diff --git a/packages/sdk/package.json b/packages/sdk/package.json index ff2a5d78..869294d6 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/sdk", - "version": "3.0.0-alpha.5", + "version": "3.0.0-alpha.6", "description": "ZenStack SDK", "type": "module", "scripts": { diff --git a/packages/tanstack-query/package.json b/packages/tanstack-query/package.json index 0671cb13..d093511e 100644 --- a/packages/tanstack-query/package.json +++ b/packages/tanstack-query/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/tanstack-query", - "version": "3.0.0-alpha.5", + "version": "3.0.0-alpha.6", "description": "", "main": "index.js", "type": "module", diff --git a/packages/testtools/package.json b/packages/testtools/package.json index b3fd12ce..7918e2fe 100644 --- a/packages/testtools/package.json +++ b/packages/testtools/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/testtools", - "version": "3.0.0-alpha.5", + "version": "3.0.0-alpha.6", "description": "ZenStack Test Tools", "type": "module", "scripts": { diff --git a/packages/typescript-config/package.json b/packages/typescript-config/package.json index 8e04c3bb..07f149b0 100644 --- a/packages/typescript-config/package.json +++ b/packages/typescript-config/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/typescript-config", - "version": "3.0.0-alpha.5", + "version": "3.0.0-alpha.6", "private": true, "license": "MIT" } diff --git a/packages/zod/package.json b/packages/zod/package.json index 98852b06..0ab2e3d1 100644 --- a/packages/zod/package.json +++ b/packages/zod/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/zod", - "version": "3.0.0-alpha.5", + "version": "3.0.0-alpha.6", "description": "", "type": "module", "main": "index.js", diff --git a/samples/blog/package.json b/samples/blog/package.json index 41fe38f6..a840303f 100644 --- a/samples/blog/package.json +++ b/samples/blog/package.json @@ -1,6 +1,6 @@ { "name": "sample-blog", - "version": "3.0.0-alpha.5", + "version": "3.0.0-alpha.6", "description": "", "main": "index.js", "scripts": { diff --git a/scripts/bump-version.ts b/scripts/bump-version.ts index 717072e9..ff4d353f 100644 --- a/scripts/bump-version.ts +++ b/scripts/bump-version.ts @@ -7,15 +7,22 @@ function getWorkspacePackageJsonFiles(workspaceFile: string): string[] { const workspaceYaml = fs.readFileSync(workspaceFile, 'utf8'); const workspace = yaml.parse(workspaceYaml) as { packages?: string[] }; if (!workspace.packages) throw new Error('No "packages" key found in pnpm-workspace.yaml'); - const rootDir = path.dirname(workspaceFile); + const files = new Set(); + + // include all package.json files in the workspace + const rootDir = path.dirname(workspaceFile); for (const pattern of workspace.packages) { const matches = glob.sync(path.join(pattern, 'package.json'), { cwd: rootDir, absolute: true, }); - matches.forEach((f) => files.add(f)); + matches.filter((f) => !f.includes('node_modules')).forEach((f) => files.add(f)); } + + // include root package.json + files.add(path.resolve(__dirname, '../package.json')); + return Array.from(files); } @@ -28,16 +35,30 @@ function incrementVersion(version: string): string { return parts.join('.'); } +// find all package.json files in the workspace const workspaceFile = path.resolve(__dirname, '../pnpm-workspace.yaml'); const packageFiles = getWorkspacePackageJsonFiles(workspaceFile); +// get version from root package.json +const rootPackageJson = path.resolve(__dirname, '../package.json'); +const rootPkg = JSON.parse(fs.readFileSync(rootPackageJson, 'utf8')) as { version?: string }; +if (!rootPkg.version) throw new Error('No "version" key found in package.json'); +const rootVersion = rootPkg.version; +const newVersion = incrementVersion(rootVersion); + for (const file of packageFiles) { const content = fs.readFileSync(file, 'utf8'); const pkg = JSON.parse(content) as { version?: string }; if (pkg.version) { + // do a string replace from oldVersion to newVersion const oldVersion = pkg.version; - pkg.version = incrementVersion(pkg.version); - fs.writeFileSync(file, JSON.stringify(pkg, null, 2) + '\n'); - console.log(`Updated ${file}: ${oldVersion} -> ${pkg.version}`); + const newContent = content.replace(`"version": "${oldVersion}"`, `"version": "${newVersion}"`); + fs.writeFileSync(file, newContent); + console.log(`Updated ${file}: ${oldVersion} -> ${newVersion}`); } } + +if (process.env.GITHUB_OUTPUT) { + // CI output + fs.appendFileSync(process.env.GITHUB_OUTPUT, `new_version=${newVersion}\n`); +}