👷(ci) add changeset to handle package releases and changelog

We needed a tool to automate the handling of monorepo's changelogs and
packages publishing. We want to make the CI responsible to automatically
publish bumped packages and create associated tags.
This commit is contained in:
Nathan Vasse
2023-01-26 17:52:34 +01:00
committed by NathanVss
parent 1529a5b5e7
commit e2204a1234
8 changed files with 695 additions and 71 deletions

8
.changeset/README.md Normal file
View File

@@ -0,0 +1,8 @@
# Changesets
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)

11
.changeset/config.json Normal file
View File

@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/config@2.3.0/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "restricted",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}

View File

@@ -32,33 +32,6 @@ jobs:
command: |
~/.local/bin/gitlint --commits origin/main..HEAD
# Check that the CHANGELOG has been updated in the current branch
check-changelog:
docker:
- image: cimg/base:2022.11
working_directory: ~/cunningham
steps:
- checkout:
path: ~/cunningham
- run:
name: Check that the CHANGELOG has been modified in the current branch
command: |
git whatchanged --name-only --pretty="" origin..HEAD | grep CHANGELOG
# Check that the CHANGELOG max line length does not exceed 80 characters
lint-changelog:
docker:
- image: debian:stretch
working_directory: ~/cunningham
steps:
- checkout:
path: ~/cunningham
- run:
name: Check CHANGELOG max line length
command: |
# Get the longuest line width (ignoring release links)
test $(cat CHANGELOG.md | grep -Ev "^\[.*\]: https://github.com/openfun" | wc -L) -le 80
# Check that renovate configuration file is valid
check-renovate-configuration:
docker:
@@ -148,7 +121,35 @@ jobs:
git config user.email "funmoocbot@users.noreply.github.com"
git config user.name "FUN MOOC bot"
yarn deploy-storybook
publish-packages:
docker:
- image: cimg/node:16.15
auth:
username: $DOCKER_USER
password: $DOCKER_PASS
working_directory: ~/cunningham
steps:
- add_ssh_keys:
fingerprints:
- "5e:86:38:27:26:f2:1b:7f:4b:36:99:38:63:d9:2b:75"
- *checkout_cunningham
- *restore_node_modules
- attach_workspace:
at: ~/cunningham
- run:
name: Authenticate with registry
command: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/cunningham/.npmrc
- run:
name: Init Git identity in order to allow changeset to create tags
command: |
git config user.email "funmoocbot@users.noreply.github.com"
git config user.name "FUN MOOC bot"
- run:
name: Publish package as public if package version are bumped
command: yarn changeset publish
- run:
name: Push release tags if some were created
command: git push --follow-tags origin HEAD
workflows:
version: 2.1
@@ -161,19 +162,6 @@ workflows:
filters:
tags:
only: /.*/
# Check CHANGELOG update
- check-changelog:
filters:
branches:
ignore: main
tags:
only: /(?!^v).*/
- lint-changelog:
filters:
branches:
ignore: main
tags:
only: /.*/
# Check Renovate
- check-renovate-configuration:
filters:
@@ -203,4 +191,13 @@ workflows:
only:
- main
requires:
- test
- publish-packages:
filters:
branches:
only:
- main
requires:
- build
- lint
- test

View File

@@ -21,6 +21,9 @@
"engines": {
"node": ">=16.0.0"
},
"dependencies": {},
"dependencies": {
"@changesets/cli": "2.26.0"
},
"packageManager": "yarn@1.22.19"
}
}

View File

@@ -19,8 +19,5 @@
"eslint-plugin-prettier": "4.2.1",
"eslint-plugin-react": "7.31.11",
"eslint-plugin-react-hooks": "4.6.0"
},
"publishConfig": {
"access": "public"
}
}

View File

@@ -2,6 +2,9 @@
"name": "@openfun/cunningham-react",
"private": false,
"version": "0.0.0",
"publishConfig": {
"access": "public"
},
"type": "module",
"license": "MIT",
"module": "./dist/index.js",

View File

@@ -3,6 +3,9 @@
"private": false,
"version": "0.0.0",
"license": "MIT",
"publishConfig": {
"access": "public"
},
"bin": {
"cunningham": "./dist/bin/Main.js"
},

652
yarn.lock

File diff suppressed because it is too large Load Diff