diff --git a/CHANGELOG.md b/CHANGELOG.md index 39ab74be3..20e9c57d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +#### 1.0.0 + +##### Migrating from v0 + +The migration guide can be found [here](https://github.com/remoteoss/json-schema-form/blob/main/MIGRATING.md) + +##### Bug Fixes + +* Improve release scripts [#214](https://github.com/remoteoss/json-schema-form/pull/214)) + #### 1.0.0-beta.12 (2025-07-16) ##### Chores diff --git a/package.json b/package.json index 2e7d60db8..8d9573e92 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@remoteoss/json-schema-form", "type": "module", - "version": "1.0.0-beta.12", + "version": "1.0.0", "packageManager": "pnpm@9.15.2", "description": "WIP V2 – Headless UI form powered by JSON Schemas", "author": "Remote.com (https://remote.com/)", diff --git a/scripts/release.js b/scripts/release.js index 82ee8a987..36dccbfe4 100644 --- a/scripts/release.js +++ b/scripts/release.js @@ -18,6 +18,9 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url)); const packageJsonPath = path.resolve(__dirname, '../package.json'); const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8')); +const releaseTypes = ['dev', 'beta', 'official']; +const bumpTypes = ['patch', 'minor', 'major']; + async function checkGitBranchAndStatus() { const releaseType = process.argv[2]; console.log(`Checking your branch for ${releaseType} release...`); @@ -59,13 +62,15 @@ async function checkGitBranchAndStatus() { async function getNewVersion() { async function getVersionsFromGitTags() { const result = await runExec(`git tag --list --sort=-version:refname`, { silent: true }); - const tags = result.stdout.toString().trim().split('\n').filter(tag => tag.startsWith(tagPrefix)); + const tags = result.stdout.toString().trim().split('\n').filter(tag => tag.startsWith('v')); return tags } const releaseType = process.argv[2]; - if (!['dev', 'beta', 'official'].includes(releaseType)) { - console.error('🟠 Invalid release type. Use dev, beta or official'); + const bumpType = process.argv[3]; + + if (!releaseTypes.includes(releaseType)) { + console.error(`🟠 Invalid release type. Use ${releaseTypes.join(', ')}`); process.exit(1); } @@ -93,12 +98,18 @@ async function getNewVersion() { } if (releaseType === 'official') { + if (!bumpTypes.includes(bumpType)) { + console.error(`🟠 Invalid bump type. Use ${bumpTypes.join(', ')}\ne.g. pnpm run release patch`); + process.exit(1); + } + // get latest official version from git tags const tags = await getVersionsFromGitTags(); const latestOfficialTag = tags.find(tag => !tag.includes('-beta.') && !tag.includes('-dev.')); // If no official version found, use v1.0.0 as the starting point - const latestOfficialVersion = latestOfficialTag ? latestOfficialTag.replace('v', '') : '1.0.0'; - return semver.inc(latestOfficialVersion, 'prerelease', 'beta'); + const latestOfficialVersion = latestOfficialTag ? latestOfficialTag.replace('v', '') : '0.0.0'; + + return semver.inc(latestOfficialVersion, bumpType); } } @@ -121,12 +132,11 @@ async function updateChangelog() { async function gitCommit({ newVersion, releaseType }) { console.log('Committing published version...'); - const prefix = `v1-${releaseType}`; let cmd; - if (releaseType === 'beta') { - // For beta, we commit package.json changes and changelog - cmd = `git add package.json CHANGELOG.md && git commit -m "Release ${prefix} ${newVersion}" && git tag ${prefix}-${newVersion} && git push && git push origin --tags`; + if (releaseType === 'beta' || releaseType === 'official') { + // For beta and official releases, we commit package.json changes and changelog + cmd = `git add package.json CHANGELOG.md && git commit -m "Release ${newVersion}" && git tag ${newVersion} && git push && git push origin --tags`; } else { // For dev, we only create a tag cmd = `git tag ${prefix}-${newVersion} && git push origin --tags`; @@ -155,6 +165,10 @@ async function publish({ newVersion, releaseType, otp }) { if (releaseType === 'beta') { console.log(`✍️ REMINDER: Please publish the release on Github too as "pre-release".`); } + + if (releaseType === 'official') { + console.log(`✍️ REMINDER: Please publish the release on Github too.`); + } console.log(`Install with: npm i @remoteoss/json-schema-form@${npmTag}`); } catch { console.log('🚨 Publish failed! Perhaps the OTP is wrong.');