Skip to content

Commit

Permalink
fix: make post-versioning script also update tags on github (#3614)
Browse files Browse the repository at this point in the history
* fix: make post-versioning script also update tags on github
The 5.6.1 release failed to push because the `post-versioning` script did not update the tags made by `npx lerna version`
- Added a new `scripts/get-version-tag.js` file that returns the current version tag by reading the version from the `@rjsf/utils` package
- Added new `commit-package-changes` as a separate script to shorten the `post-versioning` script
- Added new `update-version-tags` script that uses the `get-version-tags.js` script to force update the local and remote tags to the current head
- Updated `package*.json` to add `cross-env` so that the setting of the CI variable in `commit-package-changes` works on all environments
- Updated the `CHANGELOG.md` file accordingly

* Apply suggestions from code review
  • Loading branch information
heath-freenome authored Apr 18, 2023
1 parent f44cf32 commit 5256392
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ should change the heading of the (upcoming) version to include a major version b
-->

# 5.6.2

## Dev / docs / playground

- Fixed issues with `post-versioning` that caused the 5.6.1 branch to not be publishable

# 5.6.1

## Dev / docs / playground
Expand Down
28 changes: 28 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
"bump-packages": "npm update --save --lockfile-version 2",
"bump-peer-deps": "node scripts/bump-peer-deps.js",
"refresh-node-modules": "rimraf packages/*/node_modules && rimraf node_modules && npm install",
"post-versioning": "echo 'This will take a while...' && npm run bump-peer-deps && npm run refresh-node-modules && git add package-lock.json packages/*/package*.json && CI=skipPrecommit git commit -m 'updated package*.json after versioning' && git push"
"commit-package-changes": "git add package-lock.json packages/*/package*.json && cross-env CI=skipPrecommit git commit -m 'updated package*.json after versioning' && git push",
"post-versioning": "echo 'This will take a while...' && npm run bump-peer-deps && npm run refresh-node-modules && npm run commit-package-changes && npm run update-version-tags",
"update-version-tags": "git tag -f $(node scripts/get-version-tag.js) && git push -f origin $(node scripts/get-version-tag.js)"
},
"license": "Apache-2.0",
"homepage": "https://github.com/rjsf-team/react-jsonschema-form",
Expand All @@ -38,6 +40,7 @@
"@types/react-dom": "^17.0.19",
"@typescript-eslint/eslint-plugin": "^5.58.0",
"@typescript-eslint/parser": "^5.58.0",
"cross-env": "^7.0.3",
"dts-cli": "^1.6.3",
"eslint": "^8.38.0",
"eslint-plugin-import": "^2.27.5",
Expand Down
2 changes: 1 addition & 1 deletion scripts/bump-peer-deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const MAJOR_MINOR_REGEX = /^\^(\d+.\d+).\d+$/;

// Since this file is in the `scripts` directory, the root dir of the repo is up one level
const rootDir = path.resolve(__dirname, '../');
// Read all of the packages directory names
// Read all the packages directory names
const dirs = fs.readdirSync(path.resolve(rootDir, 'packages'));
dirs.forEach((dir) => {
// Get the name of each of the package.json files from the directory
Expand Down
14 changes: 14 additions & 0 deletions scripts/get-version-tag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const fs = require('fs');
const path = require('path');

// Since this file is in the `scripts` directory, the root dir of the repo is up one level
const utilsPackage = path.resolve(__dirname, '../packages/utils/package.json');

// Read the file and parse it into a json object and find the version tag
const packageJson = fs.readFileSync(utilsPackage);
const packageObject = JSON.parse(packageJson);

const { version } = packageObject;

// Write the version, prefixed by the `v` used by lerna to the standard out so it can be used externally
process.stdout.write(`v${version}`);

0 comments on commit 5256392

Please sign in to comment.