From 8c14c4d7bad00174530af57a8e77fec153471bf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Mesnil?= Date: Tue, 28 Jan 2025 12:04:17 +0100 Subject: [PATCH] ci: rework for release from lib --- .circleci/config.yml | 30 ++++++++++++++++++++ .dev-releases/publish.mjs | 5 ++-- .dev-releases/version.mjs | 2 +- README.md | 36 +++++++++++++----------- .release-it.json => lib/.release-it.json | 0 lib/package.json | 1 + package.json | 7 ++--- 7 files changed, 56 insertions(+), 25 deletions(-) rename .release-it.json => lib/.release-it.json (100%) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2d06ab137..9720165bf 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -226,6 +226,23 @@ jobs: name: publish command: yarn release-it --no-increment --no-git --no-github + alpha_release: + executor: nodejs + steps: + - *checkout + - *restore_repo + - attach_workspace: + at: ~/welcome-ui/artifacts + - run: + name: 'copy build artifacts' + command: 'cp -r artifacts/* .' + - run: + name: 'auth to npm registry' + command: echo "//npm.pkg.github.com/:_authToken=$GITHUB_TOKEN_WRITE_PACKAGES" > ~/.npmrc + - run: + name: publish + command: yarn release-it --no-increment --no-git --no-github --preRelease=alpha + dev_release: executor: nodejs steps: @@ -337,6 +354,19 @@ workflows: ignore: /.*/ tags: only: /v\d.(\d\d|\d).(\d\d|\d)/ + - alpha_release: + context: + - welcome-ui + requires: + - lint + - test + - website_build + - release_icon_font + filters: + branches: + ignore: /.*/ + tags: + only: /v\d.(\d\d|\d).(\d\d|\d)-.*/ - dev_release: context: - welcome-ui diff --git a/.dev-releases/publish.mjs b/.dev-releases/publish.mjs index f11a2dee0..6311ee87c 100644 --- a/.dev-releases/publish.mjs +++ b/.dev-releases/publish.mjs @@ -3,7 +3,7 @@ import { readFileSync, writeFileSync } from 'fs' import { dirname, join } from 'path' const __dirname = dirname(new URL(import.meta.url).pathname) -const packageJSONPath = join(dirname(__dirname), 'package.json') +const packageJSONPath = join(dirname(__dirname), 'lib', 'package.json') const packageJSON = JSON.parse(readFileSync(packageJSONPath, { encoding: 'utf-8' })) @@ -20,7 +20,6 @@ writeFileSync(packageJSONPath, JSON.stringify(packageJSON, null, 2)) console.info('Done !') console.info('Publishing ...') -execSync('npm publish --tag dev') +execSync('cd lib && npm publish --tag dev') console.info('Done !') - diff --git a/.dev-releases/version.mjs b/.dev-releases/version.mjs index 879469181..762af4013 100644 --- a/.dev-releases/version.mjs +++ b/.dev-releases/version.mjs @@ -6,7 +6,7 @@ const newVersion = `dev.${date.getTime()}` console.info(`Tag ${newVersion}...`) -execSync(`git tag ${newVersion}`) +execSync(`cd lib && git tag ${newVersion}`) console.info('Done !') console.info('Pushing tags...') diff --git a/README.md b/README.md index cb1c30581..f02a0bc39 100644 --- a/README.md +++ b/README.md @@ -88,39 +88,41 @@ yarn website ## How to release -The release of the packages is automated by the CI, you just need to bump package version and push git tags to initiate the process. +The release of the library is automated by the CI, you just need to bump package version and push git tags to initiate the process. -### Initiating the release process from your environment +### Release process -**The commands listed below will only prompt for packages to bump**. Then they will modify packages versions, commit changes and create the git tag to finally push everything to github. **No further actions are required once you have validated the packages to bump.** +**The commands listed below will only prompt for library to bump**. Then they will modify package version, commit changes and create the git tag to finally push everything to github. **No further actions are required once you have validated the packages to bump.** -#### If you just need to bump one version without switching from a prerelease to stable release, run: +#### How to release + +##### Production + +(ex: **7.1.0**): ```bash yarn release ``` -#### To create a new prerelease, run: +##### Alpha -This is only used for the **first** prerelease. If you already published a v5.0.0-alpha.0 then you just need to run the first command. +(ex: **7.1.0-alpha.0**) + +Generate an alpha release for broader team testing: ```bash -yarn dev:prerelease +yarn release:alpha ``` -NB: you can replace alpha with any other keyword (beta, rc, ...) - -#### Troubleshooting +##### Development -##### How to rollback a release that has been stopped before publish to npm +(ex: **dev.1738060597**) -Revert the last commit (which should be the commit that bumps package versions): +Create a development release based on the current timestamp for quick testing of pre-release features: -`git revert HEAD^` - -Remove the tag on github and locally. - -Then apply your fixes and re-run your release command. +```bash +yarn release:dev +``` ### About the CI diff --git a/.release-it.json b/lib/.release-it.json similarity index 100% rename from .release-it.json rename to lib/.release-it.json diff --git a/lib/package.json b/lib/package.json index 467389991..86e1dd76c 100644 --- a/lib/package.json +++ b/lib/package.json @@ -95,6 +95,7 @@ "jest-environment-jsdom": "^29.7.0", "jest-styled-components": "7.2.0", "react": "^18.0.0", + "release-it": "^18.1.1", "rollup-preserve-directives": "^1.1.3", "styled-components": "^5.3.9", "typescript": "^5.6.3", diff --git a/package.json b/package.json index e52c591c6..f470c1d37 100644 --- a/package.json +++ b/package.json @@ -16,9 +16,9 @@ "lint": "yarn lint:js && yarn lint:css && yarn lint:ts && yarn lint:mdx && yarn lint:website", "migrate": "node ./scripts/update-imports.js", "postinstall": "husky install", - "dev:release": "node .dev-releases/version.mjs", - "dev:prerelease": "yarn release-it --preReleaseId=alpha --no-npm.publish", - "release": "yarn release-it --no-npm.publish", + "release:dev": "node .dev-releases/version.mjs", + "release:alpha": "cd lib && yarn release-it --preReleaseId=alpha --no-npm.publish", + "release": "cd lib && yarn release-it --no-npm.publish", "start": "cd website && yarn dev -p 3020", "export-properties": "node ./scripts/generate-types-doc.js", "test": "cd lib && yarn test" @@ -79,7 +79,6 @@ "react-docgen-typescript": "^2.2.2", "react-dom": "^18.1.0", "react-router-dom": "6.27.0", - "release-it": "^18.1.1", "rimraf": "^4.1.1", "standard-version": "9.5.0", "styled-components": "^5.3.9",