Skip to content

Commit 14d9de9

Browse files
authored
Merge pull request #1524 from canalplus/misc/new-release-script
Add make-official-release script
2 parents 0cb7751 + af9f5e8 commit 14d9de9

File tree

6 files changed

+1045
-90
lines changed

6 files changed

+1045
-90
lines changed

doc/contributing/releases.md

Lines changed: 7 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -106,75 +106,13 @@ The RxPlayer has several types of releases:
106106

107107
When published on `npm`, they have the `canal` tag.
108108

109-
## Workflow for an official release
109+
## To publish an official release
110110

111-
Before each official releases, a list of steps are performed by its maintainers:
111+
Before publishing an official RxPlayer releases, a list of steps should be performed by
112+
its maintainers.
112113

113-
1. Checkout the branch that will be the base of the next release: generally it is either
114-
`stable` (for patch releases) or `dev` (for minor versions).
114+
First, checkout the branch that will be the base of the next release: generally it is
115+
either `stable` (for patch releases) or `dev` (for minor and major versions).
115116

116-
2. Rebase that branch on the `stable` branch if it is a different branch (e.g.:
117-
`git rebase stable --rebase-merges`).
118-
119-
3. From there, create a branch named `release/vXX.XX.XX`, where XX.XX.XX is the semver of
120-
the wanted new version.
121-
122-
4. Update `CHANGELOG.md` file to add this new version's changelog and commit it.
123-
124-
5. Call the npm script `update-version` for that release
125-
(`npm run update-version XX.XX.XX`, where XX.XX.XX is the wanted new version SEMVER).
126-
127-
6. Check that the modifications it did make sense and create a signed commit (`-S` option
128-
when commiting with git) updating the staged built files in step `8`.
129-
130-
7. Open a Pull Request on Github, named after the branch, putting the release's changelog
131-
in the Pull Request's comment, and optional additional comments.
132-
133-
8. Check that sonarcloud validated that branch. Resolve every bug and code smells it
134-
finds.
135-
136-
9. Ensure that the CI doesn't detect any issue and fix them if that's the case.
137-
138-
10. Run sanity checks on myCanal's repository, by using this new version instead as a
139-
dependency.
140-
141-
11. If and only if no problem was seen perform a signed merge without fast-forward of the
142-
release branch into master
143-
144-
12. Launch script to update the gh-pages demo (`./scripts/update_gh-pages_demo`)
145-
146-
13. Launch script to update the gh-pages doc (`./scripts/update_gh-pages_doc`)
147-
148-
14. Check that both of those worked, perform manual updates and update the concerned
149-
scripts in other cases.
150-
151-
15. Check that the new demo and the new doc work as expected
152-
153-
16. If all seems good, push to origin/stable your local stable branch.
154-
155-
17. run `npm publish` to publish the new version on npm's registry.
156-
157-
18. Test that importing this new version doesn't cause bundling issues (you may do so
158-
through a ad-hoc package, or just myCanal for example).
159-
160-
19. Create the new release through github's interface - don't forget to include the built
161-
files on it.
162-
163-
If any of the testing steps failed (after step `3`), run the following steps:
164-
165-
1. Fix the problem (!)
166-
167-
2. Create a commit for the fix with a meaningful message.
168-
169-
3. If (and only if) it make sense, update the changelog and create a commit for it.
170-
171-
4. Call the npm script `update-version` for that release
172-
(`npm run update-version XX.XX.XX`, where XX.XX.XX is the wanted new version SEMVER).
173-
174-
5. Check that the modifications of that last step made sense and create a signed commit
175-
(`-S` option when commiting with git) updating the staged built files.
176-
177-
6. Depending on the nature of the fix, either create a new branch and add a Pull Request
178-
to merge it in the release branch or push it to the release branch directly.
179-
180-
7. Go back to step `8` (sonarcloud + CI) of the previous workflow
117+
Then, the following steps are mostly automatized by the `releases:official` script, which
118+
may be run by calling `npm run releases:official`.

package.json

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,11 @@
180180
"lint:tests": "eslint tests/**/*.js --ignore-pattern '/tests/performance/bundle*'",
181181
"list": "node scripts/list-npm-scripts.mjs",
182182
"prepublishOnly": "npm run build:all",
183+
"releases:changelog": "./scripts/update_changelog.mjs",
184+
"releases:demo": "./scripts/update_gh-pages_demo",
183185
"releases:dev": "./scripts/make-dev-releases",
186+
"releases:doc": "./scripts/update_gh-pages_doc",
187+
"releases:official": "./scripts/make-official-release.sh",
184188
"start": "node ./scripts/start_demo_web_server.mjs",
185189
"start:wasm": "node ./scripts/start_demo_web_server.mjs --include-wasm",
186190
"test:integration": "npm run test:integration:chrome && npm run test:integration:firefox",
@@ -239,7 +243,8 @@
239243
"check:demo": "Check the validity of the demo directory by running the type checker and linter on it",
240244
"check:demo:types": "Check TypeScript types in demo files",
241245
"lint:demo": "Run linter on demo files",
242-
"certificate": "Generate a certificate to be able to use HTTPS locally for the demo pages (`npm run start` will then listen to HTTPS requests through a communicated port)"
246+
"certificate": "Generate a certificate to be able to use HTTPS locally for the demo pages (`npm run start` will then listen to HTTPS requests through a communicated port)",
247+
"releases:demo": "Publish current demo as the GitHub's pages new demo page (\"stable\" branch only)"
243248
},
244249
"Type-check, format, or lint the current code": {
245250
"check": "Check the validity of the src directory by running the type checker and linter on it",
@@ -293,11 +298,13 @@
293298
}
294299
},
295300
"Build the documentation pages": {
296-
"doc": "Generate the HTML documentation in doc/generated/pages"
301+
"doc": "Generate the HTML documentation in doc/generated/pages",
302+
"releases:doc": "Publish current documentation as the GitHub's pages new documentation pages (\"stable\" branch only)"
297303
},
298304
"Make a release": {
299-
"releases:dev": "Produce dev npm releases (which are tagged pre-releases on npm) with the code in the current branch",
300-
"update-version": "Update the version to the string given in argument (example: `npm run update-version 3.8.0`). Will update the codebase and perform every builds."
305+
"releases:dev": "Produce dev npm releases (which are tagged pre-releases on npm) from the current branch.",
306+
"releases:official": "Produce a new official release of the RxPlayer from the current branch.",
307+
"update-version": "Update the version of the RxPlayer. Will update the codebase and perform every builds."
301308
}
302309
}
303310
}

scripts/make-dev-releases

Lines changed: 103 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,25 +34,118 @@
3434

3535
set -e
3636

37+
# Log a line to sterr and exit with error code 1
38+
err() {
39+
echo "ERROR: $1" >&2
40+
exit 1
41+
}
42+
3743
if [ $# -eq 0 ]; then
3844
read -r -p "Please enter the wanted version number (example: 4.12.1): " version
45+
echo ""
3946
if [ -z "${version}" ]; then
40-
echo "Please enter a valid version number"
41-
exit 1
47+
# TODO SEMVER REGEX?
48+
err "Please enter a valid version number next time."
4249
fi
50+
else
51+
version=$1
4352
fi
4453

4554
if [ $# -lt 2 ]; then
4655
read -r -p "Please enter the increment number [by default: 00]: " incr
4756
if [ -z "${incr}" ]; then
4857
incr="00"
4958
fi
59+
else
60+
incr=$2
5061
fi
5162

5263
current_branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')
5364
date=$(date "+%Y%m%d")
54-
dev_branch="release/v${version}-dev.${date}${incr}"
55-
canal_branch="release/v${version}-canal.${date}${incr}"
65+
dev_version="${version}-dev.${date}${incr}"
66+
canal_version="${version}-canal.${date}${incr}"
67+
dev_branch="release/v${dev_version}"
68+
canal_branch="release/v${canal_version}"
69+
70+
if [ -n "$(git status --porcelain)" ]; then
71+
err "There is unstaged changes in your worktree. Please commit your changes or stash them before creating the release."
72+
fi
73+
74+
echo "This script will create the dev versions: $dev_version and $canal_version"
75+
76+
echo "checking that the branches do not already exist locally or remotely..."
77+
if ! [ -z $(git branch --list "$dev_branch") ]; then
78+
err "Branch name \"$dev_branch\" already exists locally. Please delete it first."
79+
fi
80+
if ! [ -z $(git branch --list "$canal_branch") ]; then
81+
err "Branch name \"$canal_branch\" already exists locally. Please delete it first."
82+
fi
83+
if ! [ -z $(git ls-remote --heads [email protected]:canalplus/rx-player.git "refs/heads/$dev_branch") ]; then
84+
err "Branch name \"$dev_branch\" already exists remotely. Please delete it first."
85+
fi
86+
if ! [ -z $(git ls-remote --heads [email protected]:canalplus/rx-player.git "refs/heads/$canal_branch") ]; then
87+
err "Branch name \"$canal_branch\" already exists remotely. Please delete it first."
88+
fi
89+
90+
echo "checking that the versions are not already published on npm..."
91+
if npm view rx-player@$dev_version >/dev/null 2>&1; then
92+
err "Version already published to npm: $version-dev.${date}${incr}"
93+
fi
94+
95+
if npm view rx-player@$canal_version >/dev/null 2>&1; then
96+
err "Version already published to npm: $version-canal.${date}${incr}"
97+
fi
98+
99+
# Make dev Changelog
100+
npm run releases:changelog -- $dev_version -d
101+
102+
$EDITOR CHANGELOG.md
103+
104+
if [ -n "$(git status --porcelain CHANGELOG.md)" ]; then
105+
echo "-- Current CHANGELOG.md Status: --"
106+
echo ""
107+
git status CHANGELOG.md
108+
109+
while :; do
110+
echo ""
111+
echo "We will push this CHANGELOG.md update to ${current_branch}."
112+
read -p "do you want to continue [y/d/s/a/c/t/h] (h for help) ? " -n1 REPLY
113+
echo ""
114+
115+
if [[ $REPLY =~ ^[Hh](elp)?$ ]]; then
116+
echo ""
117+
echo ""
118+
echo "+- help -------------------------------------------------+"
119+
echo "| y: commit and continue |"
120+
echo "| d: see diff |"
121+
echo "| s: see status |"
122+
echo "| a: abort script from here |"
123+
echo "| c: skip CHANGELOG.md update and go to the next step |"
124+
echo "| h: see this help |"
125+
echo "+--------------------------------------------------------+"
126+
elif [[ $REPLY =~ ^[Yy](es)?$ ]]; then
127+
git add CHANGELOG.md
128+
git commit -m "Update CHANGELOG.md for v$dev_version"
129+
git push [email protected]:canalplus/rx-player.git $current_branch
130+
break
131+
elif [[ $REPLY =~ ^[Dd](iff)?$ ]]; then
132+
git diff CHANGELOG.md || true # ignore when return 1
133+
elif [[ $REPLY =~ ^[Ss](tatus)?$ ]]; then
134+
git status CHANGELOG.md
135+
elif [[ $REPLY =~ ^[Aa](bort)?$ ]]; then
136+
echo "exiting"
137+
exit 0
138+
elif [[ $REPLY =~ ^[Cc](heckout)?$ ]]; then
139+
git checkout CHANGELOG.md
140+
else
141+
echo "invalid input"
142+
fi
143+
done
144+
fi
145+
146+
if [ -n "$(git status --porcelain)" ]; then
147+
err "Unexpected diff in \"${current_branch}\""
148+
fi
56149

57150
git checkout -b ${dev_branch}
58151
./scripts/update-version $version-dev.${date}${incr}
@@ -62,9 +155,9 @@ while true; do
62155
read -n1 -p "Do you wish to push and publish the dev build? [y/n] " yn
63156
echo ""
64157
case $yn in
65-
[Yy]* ) break;;
66-
[Nn]* ) exit;;
67-
* ) echo "Please answer y or n.";;
158+
[Yy]*) break ;;
159+
[Nn]*) exit ;;
160+
*) echo "Please answer y or n." ;;
68161
esac
69162
done
70163
git push origin ${dev_branch}
@@ -82,9 +175,9 @@ while true; do
82175
read -n1 -p "Do you wish to push and publish the canal build? [y/n] " yn
83176
echo ""
84177
case $yn in
85-
[Yy]* ) break;;
86-
[Nn]* ) exit;;
87-
* ) echo "Please answer y or n.";;
178+
[Yy]*) break ;;
179+
[Nn]*) exit ;;
180+
*) echo "Please answer y or n." ;;
88181
esac
89182
done
90183
npm publish --tag canal-v4

0 commit comments

Comments
 (0)