Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add release-it #2655

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 39 additions & 18 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ checkout: &checkout
checkout:
path: /home/circleci/welcome-ui

restore_repo: &restore_repo
restore_cache:
keys:
- << pipeline.parameters.cache_version >>-source-{{ .Branch }}-{{ .Revision }}

restore_node_modules: &restore_node_modules
restore_cache:
keys:
Expand All @@ -39,10 +44,11 @@ jobs:
executor: nodejs
steps:
- *checkout
- *restore_repo
- *restore_node_modules
- run:
name: Run yarn install and save node modules
command: yarn install
- *restore_node_modules
- save_cache:
key: << pipeline.parameters.cache_version >>-yarn-{{ checksum "/home/circleci/welcome-ui/yarn.lock" }}
paths:
Expand All @@ -57,6 +63,7 @@ jobs:
resource_class: small
steps:
- *checkout
- *restore_repo
- *restore_node_modules
- attach_workspace:
at: ~/welcome-ui
Expand All @@ -70,6 +77,7 @@ jobs:
resource_class: medium
steps:
- *checkout
- *restore_repo
- *restore_node_modules
- run: yarn build
- persist_to_workspace:
Expand All @@ -82,6 +90,7 @@ jobs:
executor: nodejs
steps:
- *checkout
- *restore_repo
- *restore_node_modules
- attach_workspace:
at: ~/welcome-ui
Expand All @@ -93,6 +102,7 @@ jobs:
parallelism: 4
steps:
- *checkout
- *restore_repo
- *restore_node_modules
- attach_workspace:
at: ~/welcome-ui
Expand All @@ -103,6 +113,7 @@ jobs:
executor: nodejs
steps:
- *checkout
- *restore_repo
- *restore_node_modules
- attach_workspace:
at: ~/welcome-ui
Expand Down Expand Up @@ -132,6 +143,7 @@ jobs:
executor: nodejs
steps:
- *checkout
- *restore_repo
- *restore_node_modules
- attach_workspace:
at: ~/welcome-ui
Expand All @@ -147,6 +159,7 @@ jobs:
executor: nodejs
steps:
- *checkout
- *restore_repo
- *restore_node_modules
- attach_workspace:
at: ~/welcome-ui
Expand All @@ -168,6 +181,7 @@ jobs:
executor: nodejs
steps:
- *checkout
- *restore_repo
- *restore_node_modules
- attach_workspace:
at: ~/welcome-ui
Expand All @@ -187,6 +201,7 @@ jobs:
executor: nodejs
steps:
- *checkout
- *restore_repo
- *restore_node_modules
- attach_workspace:
at: ~/welcome-ui
Expand All @@ -204,34 +219,40 @@ jobs:
--metadata GitCommit=$CIRCLE_SHA1 --delete

release:
<<: *default
executor: nodejs
steps:
- *checkout
- *restore_repo
- *restore_node_modules
- attach_workspace:
at: ~/welcome-ui
at: ~/welcome-ui/artifacts
- run:
name: 'copy build artifacts'
command: 'cp -r artifacts/* .'
- run:
name: Login to registry
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc
name: 'auth to npm registry'
command: echo "//npm.pkg.github.com/:_authToken=$GITHUB_TOKEN_WRITE_PACKAGES" > ~/.npmrc
- run:
name: Release to npm
command: yarn lerna publish from-git --yes --no-verify-access
name: publish
command: yarn release-it --no-increment --no-git --no-github

prerelease:
<<: *default
dev_release:
executor: nodejs
steps:
- *checkout
- *restore_repo
- *restore_node_modules
- attach_workspace:
at: ~/welcome-ui
at: ~/welcome-ui/artifacts
- run:
name: 'copy build artifacts'
command: 'cp -r artifacts/* .'
- run:
name: Login to registry
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc
name: 'auth to npm registry'
command: echo "//npm.pkg.github.com/:_authToken=$GITHUB_TOKEN_WRITE_PACKAGES" > ~/.npmrc
- run:
name: Release to npm
command: yarn lerna publish from-git --yes --no-verify-access --dist-tag next
name: publish
command: node .dev-releases/publish.mjs

workflows:
btd:
Expand Down Expand Up @@ -292,7 +313,7 @@ workflows:
branches:
ignore: /.*/
tags:
only: /v6.(\d\d|\d).(\d\d|\d)/
only: /v7.(\d\d|\d).(\d\d|\d)/
context:
- aws
- welcome-ui
Expand All @@ -305,7 +326,7 @@ workflows:
filters:
# should add branches here to keep previous doc version of future majors
branches:
only: /v3|v4|v5/
only: /v3|v4|v5|v6/
context:
- aws
- welcome-ui
Expand All @@ -327,7 +348,7 @@ workflows:
ignore: /.*/
tags:
only: /v\d.(\d\d|\d).(\d\d|\d)/
- prerelease:
- dev_release:
context:
- welcome-ui
requires:
Expand All @@ -339,4 +360,4 @@ workflows:
branches:
ignore: /.*/
tags:
only: /v\d.(\d\d|\d).(\d\d|\d)-.*/
only: /dev..*/
26 changes: 26 additions & 0 deletions .dev-releases/publish.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { execSync } from 'child_process'
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 packageJSON = JSON.parse(readFileSync(packageJSONPath, { encoding: 'utf-8' }))

const versionToPublish = process.env.CIRCLE_TAG

console.info(`Found latest tag ${versionToPublish}`)

packageJSON.version = versionToPublish.trim()

console.info('Writing version to package.json...')

writeFileSync(packageJSONPath, JSON.stringify(packageJSON, null, 2))

console.info('Done !')
console.info('Publishing ...')

execSync('npm publish --tag dev')

console.info('Done !')

19 changes: 19 additions & 0 deletions .dev-releases/version.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { execSync } from 'child_process'

const date = new Date()

const newVersion = `dev.${date.getTime()}`

console.info(`Tag ${newVersion}...`)

execSync(`git tag ${newVersion}`)

console.info('Done !')
console.info('Pushing tags...')

execSync(`git push origin ${newVersion}`)

console.info('Done !')
console.info(
'Visit https://app.circleci.com/pipelines/github/WTTJ/welcome-ui to see your release progress'
)
8 changes: 8 additions & 0 deletions .release-it.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"git": {
"commitMessage": "chore: release v${version}"
},
"github": {
"release": true
}
}
2 changes: 1 addition & 1 deletion lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "welcome-ui",
"version": "1.0.0-beta.9",
"version": "7.0.0",
"description": "Customizable design system with react • styled-components • styled-system and ariakit.",
"files": [
"dist"
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +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:prerelease": "todo",
"release": "todo",
"dev:release": "node .dev-releases/version.mjs",
"dev:prerelease": "yarn release-it --preReleaseId=alpha --no-npm.publish",
"release": "yarn release-it --no-npm.publish",
"start": "cd lib && yarn start",
"test": "cd lib && yarn test",
"website": "cd website && yarn dev -p 3020"
Expand Down Expand Up @@ -78,6 +79,7 @@
"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
Loading
Loading