Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/bump-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ permissions:
jobs:
bump-version:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/dev'

steps:
- name: Checkout
Expand All @@ -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
80 changes: 80 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
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'

- 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<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.version.outputs.tag }}
release_name: Release ${{ steps.version.outputs.tag }}
body: |
## Changes in this release
${{ steps.changelog.outputs.changelog }}
draft: true
prerelease: true
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zenstack-v3",
"version": "3.0.0-alpha.5",
"version": "3.0.0-alpha.6",
"description": "ZenStack",
"packageManager": "[email protected]",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion packages/common-helpers/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion packages/create-zenstack/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config/package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion packages/ide/vscode/package.json
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 1 addition & 1 deletion packages/language/package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion packages/tanstack-query/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/testtools/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion packages/typescript-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenstackhq/typescript-config",
"version": "3.0.0-alpha.5",
"version": "3.0.0-alpha.6",
"private": true,
"license": "MIT"
}
2 changes: 1 addition & 1 deletion packages/zod/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion samples/blog/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sample-blog",
"version": "3.0.0-alpha.5",
"version": "3.0.0-alpha.6",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
32 changes: 27 additions & 5 deletions scripts/bump-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>();

// 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);
}

Expand All @@ -28,16 +35,31 @@ 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) {
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 newVersion = incrementVersion(pkg.version);
// do a string replace from oldVersion to newVersion
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`);
}