Skip to content

Commit 46b31f0

Browse files
committed
ci: remove lerna, leverage basic shell script
1 parent e873017 commit 46b31f0

File tree

14 files changed

+131
-79
lines changed

14 files changed

+131
-79
lines changed

.github/scripts/publish.sh

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/sh
2+
set -e
3+
4+
# List of packages to publish
5+
# CHANGE IT WHEN ADDING A NEW PROJECT TO BE RELEASED.
6+
PACKAGES=(
7+
"ui-icons"
8+
"ui-core"
9+
"ui-speedspacechart"
10+
"ui-spacetimechart"
11+
"ui-manchette"
12+
)
13+
14+
# Get the version from the tag
15+
VERSION=${GITHUB_REF/refs\/tags\//}
16+
17+
# Helper function to update the version and publish the package
18+
# Note : we are in the CI triggered by a release, we do not need to create a tag nor commit
19+
version_and_publish() {
20+
local dir=$1
21+
local version=$2
22+
23+
# Go to the package directory
24+
pushd $dir
25+
26+
# Set version in package.json
27+
npm version $version --no-git-tag-version
28+
29+
# Update dependencies to match the new version
30+
# This jq script will search for dependencies starting with "@osrd-project" and
31+
# update them to the new version
32+
jq \
33+
--arg v "$version" \
34+
'
35+
(.dependencies // {} | with_entries(if .key | startswith("@osrd-project") then .value = $v else . end)) as $d |
36+
(.devDependencies // {} | with_entries(if .key | startswith("@osrd-project") then .value = $v else . end)) as $ddev |
37+
.dependencies = $d | .devDependencies = $ddev
38+
' \
39+
package.json > package.tmp.json
40+
41+
# Overwrite the package.json with the updated version
42+
mv package.tmp.json package.json
43+
44+
# Publish the package
45+
npm publish
46+
47+
# Back to root
48+
popd
49+
}
50+
51+
# Publish each package
52+
for dir in "${PACKAGES[@]}"; do
53+
echo "::group::Publishing $dir"
54+
version_and_publish $dir $VERSION
55+
echo "::endgroup::"
56+
done

.github/workflows/osrd-ui-publish.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,5 @@ jobs:
3232

3333
- name: Publish
3434
run: |
35-
VERSION=${GITHUB_REF/refs\/tags\//}
3635
npm ci
37-
npm run lerna -- publish ${VERSION} --force-publish --yes --no-push --no-git-tag-version
36+
./.github/scripts/publish.sh

README.md

+33-6
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,40 @@
22

33
Icons, fonts, colors, components and all user interface items for OSRD project.
44

5-
## TODO
5+
## Development
66

7-
We should write a README to explain the goal of the `osrd-ui` repository and the design system as
8-
the whole.
7+
Development will leverage preconstruct. **Documentation yet to come**.
98

10-
We should also explain how it is related to the `osrd-design` repository.
9+
## Publishing versions
1110

12-
## Credits
11+
In a nutshell: we consider our version numbers metadata of the project. We use [Semantic Versioning](https://semver.org/).
1312

14-
### ui-icons
13+
### Implications
14+
15+
We do not change the version on local package versions, we keep the file to the version `0.0.1-dev` which is not a real version and can be easily identified as a development version.
16+
17+
The version numbers for our releases are solely managed through git tags. It implies that when we update a single package, we release all the project together : even if there are no changes between two release (let's say we update ui-icons but nothing else, we would make a release that would publish all packages anyway).
18+
19+
It's the tradeoff we make to keep the project simple and easy to manage, and to avoid the complexity of managing multiple compatible versions of the project.
20+
21+
In summary : we conside a version number as being an indivisible release of all the subpackages of the repository.
22+
23+
### Making a release
24+
25+
1. Create a git tag (let's say `0.0.30`) on the `dev` branch and push it. **Note: we do not tag with a V in front of the semver, IT'S 0.0.30 AND NOT v0.0.30**.
26+
2. Create a github release (By convention, we use the same name as the tag with a v in front of it, `v0.0.30`. You can give fancy names to release if you want to : `0.0.30 : Camembert`, it will only appear in the release page of GitHub).
27+
28+
### Adding a new package to the monorepo
29+
30+
1. Create a folder and follow the structure of the other packages (refer to the Development section for more information).
31+
2. In the file `./.github/scripts/publish.sh`, search for the PACKAGES array and add your package in it. See below:
32+
33+
```bash
34+
# List of packages to publish
35+
# CHANGE IT WHEN ADDING A NEW PROJECT TO BE RELEASED.
36+
PACKAGES=(
37+
"ui-icons"
38+
"ui-core"
39+
# <- Add your package here (it's a bash array)
40+
)
41+
```

flake.lock

+15-25
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+7-4
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,36 @@
44
inputs = {
55
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
66
flake-utils.url = "github:numtide/flake-utils";
7-
flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz";
87
alejandra = {
98
url = "github:kamadorueda/alejandra/3.0.0";
109
inputs.nixpkgs.follows = "nixpkgs";
1110
};
1211
};
1312

14-
outputs = { self, nixpkgs, flake-utils, ... }@inputs:
13+
outputs = { self, nixpkgs, flake-utils, alejandra, ... }@inputs:
1514
flake-utils.lib.eachDefaultSystem (system:
1615
let
1716
pkgs = import nixpkgs {
1817
inherit system;
1918
overlays = [];
2019
};
21-
fixedNode = pkgs.nodejs-18_x;
20+
fixedNode = pkgs.nodejs_22;
2221
fixedNodePackages = pkgs.nodePackages.override {
2322
nodejs = fixedNode;
2423
};
2524
in
2625
{
2726
devShell = pkgs.mkShell {
2827
buildInputs = with pkgs; [
28+
# Nix formatter
29+
alejandra.defaultPackage.${system}
30+
31+
# Node version
2932
fixedNode
3033
fixedNodePackages.npm
3134
fixedNodePackages.yarn
3235
];
3336
};
3437
}
3538
);
36-
}
39+
}

lerna.json

-7
This file was deleted.

package.json

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@osrd-project/root",
3-
"version": "0.1.0",
3+
"version": "0.0.1-dev",
44
"homepage": "https://github.com/osrd-project/osrd-ui#readme",
55
"repository": {
66
"type": "git",
@@ -25,11 +25,7 @@
2525
"clean": "npm run clean --workspaces --if-present",
2626
"build": "npm run build --workspaces --if-present",
2727
"test": "npm run test --workspaces --if-present",
28-
"storybook": "npm start --workspace='@osrd-project/storybook'",
29-
"lerna:changed": "lerna changed",
30-
"lerna:diff": "lerna diff",
31-
"lerna": "lerna",
32-
"lerna:publish": "lerna publish from-package --no-private --yes"
28+
"storybook": "npm start --workspace='@osrd-project/storybook'"
3329
},
3430
"type": "module",
3531
"devDependencies": {
@@ -48,12 +44,11 @@
4844
"eslint-plugin-react": "^7.33.2",
4945
"eslint-plugin-react-hooks": "^4.6.0",
5046
"eslint-plugin-storybook": "^0.6.15",
51-
"lerna": "^8.1.2",
5247
"prettier": "^3.2.5",
5348
"react": "^18.2.0",
5449
"react-dom": "^18.2.0",
5550
"rimraf": "^5.0.5",
5651
"rollup": "^4.13.0",
5752
"typescript": "^5.4.2"
5853
}
59-
}
54+
}

shell.nix

-14
This file was deleted.

ui-core/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@osrd-project/ui-core",
3-
"version": "0.0.27",
3+
"version": "0.0.1-dev",
44
"license": "LGPL-3.0-or-later",
55
"bugs": "https://github.com/osrd-project/osrd-ui/issues",
66
"repository": {
@@ -52,4 +52,4 @@
5252
"rollup-plugin-serve": "^1.1.1"
5353
},
5454
"gitHead": "973ad1478be4544e1c97303b844903247d9a9cd7"
55-
}
55+
}

ui-icons/package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
{
22
"name": "@osrd-project/ui-icons",
3-
"version": "0.0.27",
3+
"version": "0.0.1-dev",
44
"license": "LGPL-3.0-or-later",
55
"bugs": "https://github.com/osrd-project/osrd-ui/issues",
66
"repository": {
77
"type": "git",
88
"url": "https://github.com/osrd-project/osrd-ui.git",
99
"directory": "ui-icons"
1010
},
11+
"publishConfig": {
12+
"access": "public"
13+
},
1114
"type": "module",
1215
"module": "./dist/index.esm.js",
1316
"types": "./dist/index.d.ts",
@@ -37,4 +40,4 @@
3740
"svgo": "3.2.0"
3841
},
3942
"gitHead": "973ad1478be4544e1c97303b844903247d9a9cd7"
40-
}
43+
}

ui-manchette/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@osrd-project/ui-manchette",
3-
"version": "0.0.27",
3+
"version": "0.0.1-dev",
44
"license": "LGPL-3.0-or-later",
55
"bugs": "https://github.com/osrd-project/osrd-ui/issues",
66
"repository": {
@@ -34,7 +34,7 @@
3434
"prepublishOnly": "npm run clean && npm run build"
3535
},
3636
"dependencies": {
37-
"@osrd-project/ui-spacetimechart": "^0.0.27",
37+
"@osrd-project/ui-spacetimechart": "0.0.1-dev",
3838
"classnames": "^2.5.1",
3939
"lodash.isequal": "^4.5.0",
4040
"tailwindcss": "^3.4.1"
@@ -53,4 +53,4 @@
5353
"rollup-plugin-serve": "^1.1.1"
5454
},
5555
"gitHead": "973ad1478be4544e1c97303b844903247d9a9cd7"
56-
}
56+
}

ui-spacetimechart/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@osrd-project/ui-spacetimechart",
3-
"version": "0.0.27",
3+
"version": "0.0.1-dev",
44
"license": "LGPL-3.0-or-later",
55
"bugs": "https://github.com/osrd-project/osrd-ui/issues",
66
"repository": {
@@ -43,4 +43,4 @@
4343
"lodash": "^4.17.21",
4444
"vitest": "^1.5.0"
4545
}
46-
}
46+
}

ui-speedspacechart/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@osrd-project/ui-speedspacechart",
3-
"version": "0.0.27",
3+
"version": "0.0.1-dev",
44
"license": "LGPL-3.0-or-later",
55
"bugs": "https://github.com/osrd-project/osrd-ui/issues",
66
"repository": {
@@ -54,4 +54,4 @@
5454
"rollup-plugin-serve": "^1.1.1"
5555
},
5656
"gitHead": "973ad1478be4544e1c97303b844903247d9a9cd7"
57-
}
57+
}

0 commit comments

Comments
 (0)