pgserve 1.1.10 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,198 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Release Script for pgserve
5
- *
6
- * Usage:
7
- * node scripts/release.cjs --action bump-rc|promote [--dry-run]
8
- *
9
- * Actions:
10
- * bump-rc - Bump RC version (1.0.8 -> 1.0.9-rc.1, or 1.0.9-rc.1 -> 1.0.9-rc.2)
11
- * promote - Promote RC to stable (1.0.9-rc.2 -> 1.0.9)
12
- *
13
- * Outputs (for GitHub Actions):
14
- * version - New version number
15
- * tag - Git tag (v1.0.9-rc.1)
16
- * npm_tag - npm dist-tag (next or latest)
17
- * is_promote - true if this is a promotion (skip build)
18
- */
19
-
20
- const { execSync } = require('child_process');
21
- const fs = require('fs');
22
- const path = require('path');
23
-
24
- const ROOT = path.join(__dirname, '..');
25
- const PACKAGE_JSON = path.join(ROOT, 'package.json');
26
-
27
- // Parse arguments
28
- function parseArgs(args) {
29
- const opts = {};
30
- for (let i = 0; i < args.length; i++) {
31
- const arg = args[i];
32
- if (arg.startsWith('--')) {
33
- const key = arg.replace(/^--/, '');
34
- const nextArg = args[i + 1];
35
- if (nextArg && !nextArg.startsWith('--')) {
36
- opts[key] = nextArg;
37
- i++;
38
- } else {
39
- opts[key] = true;
40
- }
41
- }
42
- }
43
- return opts;
44
- }
45
-
46
- const opts = parseArgs(process.argv.slice(2));
47
- const dryRun = opts['dry-run'] || false;
48
-
49
- function log(msg) {
50
- console.log(`[release] ${msg}`);
51
- }
52
-
53
- function exec(cmd, options = {}) {
54
- if (dryRun && !options.readOnly) {
55
- log(`[dry-run] Would execute: ${cmd}`);
56
- return '';
57
- }
58
- return execSync(cmd, { encoding: 'utf8', cwd: ROOT, ...options }).trim();
59
- }
60
-
61
- function getCurrentVersion() {
62
- const pkg = JSON.parse(fs.readFileSync(PACKAGE_JSON, 'utf8'));
63
- return pkg.version;
64
- }
65
-
66
- function updateVersion(newVersion) {
67
- const pkg = JSON.parse(fs.readFileSync(PACKAGE_JSON, 'utf8'));
68
- pkg.version = newVersion;
69
- if (!dryRun) {
70
- fs.writeFileSync(PACKAGE_JSON, JSON.stringify(pkg, null, 2) + '\n');
71
- }
72
- log(`Updated package.json version: ${newVersion}`);
73
- }
74
-
75
- function bumpRcVersion(currentVersion) {
76
- // Check if already an RC: 1.0.9-rc.1 -> 1.0.9-rc.2
77
- const rcMatch = currentVersion.match(/^(\d+\.\d+\.\d+)-rc\.(\d+)$/);
78
- if (rcMatch) {
79
- const [, base, rcNum] = rcMatch;
80
- return `${base}-rc.${parseInt(rcNum) + 1}`;
81
- }
82
-
83
- // Not an RC, bump patch and start at rc.1: 1.0.8 -> 1.0.9-rc.1
84
- const match = currentVersion.match(/^(\d+)\.(\d+)\.(\d+)/);
85
- if (!match) throw new Error(`Invalid version format: ${currentVersion}`);
86
-
87
- const [, major, minor, patch] = match;
88
- return `${major}.${minor}.${parseInt(patch) + 1}-rc.1`;
89
- }
90
-
91
- function promoteToStable(currentVersion) {
92
- // If RC version: 1.0.9-rc.2 -> 1.0.9
93
- const rcMatch = currentVersion.match(/^(\d+\.\d+\.\d+)-rc\.\d+$/);
94
- if (rcMatch) {
95
- return rcMatch[1];
96
- }
97
-
98
- // If already stable: 1.1.1 -> 1.1.2 (bump patch for new stable release)
99
- const stableMatch = currentVersion.match(/^(\d+)\.(\d+)\.(\d+)$/);
100
- if (stableMatch) {
101
- const [, major, minor, patch] = stableMatch;
102
- return `${major}.${minor}.${parseInt(patch) + 1}`;
103
- }
104
-
105
- throw new Error(`Invalid version format: ${currentVersion}`);
106
- }
107
-
108
- function createTag(version) {
109
- const tag = `v${version}`;
110
- const commitMsg = `chore: release ${tag}`;
111
-
112
- if (dryRun) {
113
- log(`[dry-run] Would commit: "${commitMsg}"`);
114
- log(`[dry-run] Would create tag: ${tag}`);
115
- return tag;
116
- }
117
-
118
- // Stage and commit
119
- exec('git add package.json');
120
- try {
121
- exec(`git commit -m "${commitMsg}"`);
122
- } catch (e) {
123
- log('Nothing to commit (version already matches)');
124
- }
125
-
126
- // Create annotated tag
127
- exec(`git tag -a ${tag} -m "Release ${tag}"`);
128
- log(`Created tag: ${tag}`);
129
-
130
- return tag;
131
- }
132
-
133
- function outputForGitHubActions(version, tag, isPromote) {
134
- const output = process.env.GITHUB_OUTPUT;
135
- if (output) {
136
- const npmTag = version.includes('-rc.') ? 'next' : 'latest';
137
- fs.appendFileSync(output, `version=${version}\n`);
138
- fs.appendFileSync(output, `tag=${tag}\n`);
139
- fs.appendFileSync(output, `npm_tag=${npmTag}\n`);
140
- fs.appendFileSync(output, `is_promote=${isPromote}\n`);
141
- log(`GitHub Actions outputs set: version=${version}, tag=${tag}, npm_tag=${npmTag}, is_promote=${isPromote}`);
142
- }
143
- }
144
-
145
- async function main() {
146
- const action = opts['action'];
147
-
148
- if (!action) {
149
- console.error('Usage: node scripts/release.cjs --action bump-rc|promote [--dry-run]');
150
- console.error('');
151
- console.error('Actions:');
152
- console.error(' bump-rc - Create new RC version');
153
- console.error(' promote - Promote current RC to stable');
154
- process.exit(1);
155
- }
156
-
157
- const currentVersion = getCurrentVersion();
158
- log(`Current version: ${currentVersion}`);
159
-
160
- let newVersion;
161
- let isPromote = false;
162
-
163
- switch (action) {
164
- case 'bump-rc':
165
- newVersion = bumpRcVersion(currentVersion);
166
- break;
167
- case 'promote':
168
- newVersion = promoteToStable(currentVersion);
169
- isPromote = true;
170
- break;
171
- default:
172
- console.error(`Unknown action: ${action}`);
173
- console.error('Valid actions: bump-rc, promote');
174
- process.exit(1);
175
- }
176
-
177
- log(`New version: ${newVersion}`);
178
-
179
- // Update package.json
180
- updateVersion(newVersion);
181
-
182
- // Create git tag
183
- const tag = createTag(newVersion);
184
-
185
- // Output for GitHub Actions
186
- // Note: Release notes are auto-generated by GitHub via .github/release.yml
187
- outputForGitHubActions(newVersion, tag, isPromote);
188
-
189
- log(`Release ${tag} prepared!`);
190
- if (!dryRun) {
191
- log('Push with: git push && git push --tags');
192
- }
193
- }
194
-
195
- main().catch(e => {
196
- console.error(`[release] Error: ${e.message}`);
197
- process.exit(1);
198
- });