Skip to content

Commit

Permalink
ci: rework for release from lib (#2663)
Browse files Browse the repository at this point in the history
  • Loading branch information
theo-mesnil authored Jan 28, 2025
1 parent 216a372 commit 1ae53b7
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 25 deletions.
30 changes: 30 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions .dev-releases/publish.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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' }))

Expand All @@ -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 !')

2 changes: 1 addition & 1 deletion .dev-releases/version.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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...')
Expand Down
36 changes: 19 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 1ae53b7

Please sign in to comment.