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

Add make-official-release script #1524

Merged
merged 3 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
76 changes: 7 additions & 69 deletions doc/contributing/releases.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,75 +106,13 @@ The RxPlayer has several types of releases:

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

## Workflow for an official release
## To publish an official release

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

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

2. Rebase that branch on the `stable` branch if it is a different branch (e.g.:
`git rebase stable --rebase-merges`).

3. From there, create a branch named `release/vXX.XX.XX`, where XX.XX.XX is the semver of
the wanted new version.

4. Update `CHANGELOG.md` file to add this new version's changelog and commit it.

5. Call the npm script `update-version` for that release
(`npm run update-version XX.XX.XX`, where XX.XX.XX is the wanted new version SEMVER).

6. Check that the modifications it did make sense and create a signed commit (`-S` option
when commiting with git) updating the staged built files in step `8`.

7. Open a Pull Request on Github, named after the branch, putting the release's changelog
in the Pull Request's comment, and optional additional comments.

8. Check that sonarcloud validated that branch. Resolve every bug and code smells it
finds.

9. Ensure that the CI doesn't detect any issue and fix them if that's the case.

10. Run sanity checks on myCanal's repository, by using this new version instead as a
dependency.

11. If and only if no problem was seen perform a signed merge without fast-forward of the
release branch into master

12. Launch script to update the gh-pages demo (`./scripts/update_gh-pages_demo`)

13. Launch script to update the gh-pages doc (`./scripts/update_gh-pages_doc`)

14. Check that both of those worked, perform manual updates and update the concerned
scripts in other cases.

15. Check that the new demo and the new doc work as expected

16. If all seems good, push to origin/stable your local stable branch.

17. run `npm publish` to publish the new version on npm's registry.

18. Test that importing this new version doesn't cause bundling issues (you may do so
through a ad-hoc package, or just myCanal for example).

19. Create the new release through github's interface - don't forget to include the built
files on it.

If any of the testing steps failed (after step `3`), run the following steps:

1. Fix the problem (!)

2. Create a commit for the fix with a meaningful message.

3. If (and only if) it make sense, update the changelog and create a commit for it.

4. Call the npm script `update-version` for that release
(`npm run update-version XX.XX.XX`, where XX.XX.XX is the wanted new version SEMVER).

5. Check that the modifications of that last step made sense and create a signed commit
(`-S` option when commiting with git) updating the staged built files.

6. Depending on the nature of the fix, either create a new branch and add a Pull Request
to merge it in the release branch or push it to the release branch directly.

7. Go back to step `8` (sonarcloud + CI) of the previous workflow
Then, the following steps are mostly automatized by the `releases:official` script, which
may be run by calling `npm run releases:official`.
15 changes: 11 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,11 @@
"lint:tests": "eslint tests/**/*.js --ignore-pattern '/tests/performance/bundle*'",
"list": "node scripts/list-npm-scripts.mjs",
"prepublishOnly": "npm run build:all",
"releases:changelog": "./scripts/update_changelog.mjs",
"releases:demo": "./scripts/update_gh-pages_demo",
"releases:dev": "./scripts/make-dev-releases",
"releases:doc": "./scripts/update_gh-pages_doc",
"releases:official": "./scripts/make-official-release.sh",
"start": "node ./scripts/start_demo_web_server.mjs",
"start:wasm": "node ./scripts/start_demo_web_server.mjs --include-wasm",
"test:integration": "npm run test:integration:chrome && npm run test:integration:firefox",
Expand Down Expand Up @@ -236,7 +240,8 @@
"check:demo": "Check the validity of the demo directory by running the type checker and linter on it",
"check:demo:types": "Check TypeScript types in demo files",
"lint:demo": "Run linter on demo files",
"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)"
"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)",
"releases:demo": "Publish current demo as the GitHub's pages new demo page (\"stable\" branch only)"
},
"Type-check, format, or lint the current code": {
"check": "Check the validity of the src directory by running the type checker and linter on it",
Expand Down Expand Up @@ -288,11 +293,13 @@
}
},
"Build the documentation pages": {
"doc": "Generate the HTML documentation in doc/generated/pages"
"doc": "Generate the HTML documentation in doc/generated/pages",
"releases:doc": "Publish current documentation as the GitHub's pages new documentation pages (\"stable\" branch only)"
},
"Make a release": {
"releases:dev": "Produce dev npm releases (which are tagged pre-releases on npm) with the code in the current branch",
"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."
"releases:dev": "Produce dev npm releases (which are tagged pre-releases on npm) from the current branch.",
"releases:official": "Produce a new official release of the RxPlayer from the current branch.",
"update-version": "Update the version of the RxPlayer. Will update the codebase and perform every builds."
}
}
}
115 changes: 105 additions & 10 deletions scripts/make-dev-releases
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,120 @@

set -e

# Log a line to sterr and exit with error code 1
err() {
echo "ERROR: $1" >&2
exit 1
}

if [ $# -eq 0 ]; then
read -r -p "Please enter the wanted version number (example: 4.12.1): " version
echo ""
if [ -z "${version}" ]; then
echo "Please enter a valid version number"
exit 1
# TODO SEMVER REGEX?
err "Please enter a valid version number next time."
fi
else
version=$1
fi

if [ $# -lt 2 ]; then
read -r -p "Please enter the increment number [by default: 00]: " incr
if [ -z "${incr}" ]; then
incr="00"
fi
else
incr=$2
fi

current_branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')
date=$(date "+%Y%m%d")
dev_branch="release/v${version}-dev.${date}${incr}"
canal_branch="release/v${version}-canal.${date}${incr}"
dev_version="${version}-dev.${date}${incr}"
canal_version="${version}-canal.${date}${incr}"
dev_branch="release/v${dev_version}"
canal_branch="release/v${canal_version}"

if [ -n "$(git status --porcelain doc)" ]; then
echo "ERROR: Please commit your modifications to \"${current_branch}\" first"
Florent-Bouisset marked this conversation as resolved.
Show resolved Hide resolved
exit 1
fi

echo "This script will create the dev versions: $dev_version and $canal_version"

echo "checking that the branches do not already exist locally or remotely..."
if ! [ -z $(git branch --list "$dev_branch") ]; then
err "Branch name "$dev_branch" already exists locally. Please delete it first."
Florent-Bouisset marked this conversation as resolved.
Show resolved Hide resolved
fi
if ! [ -z $(git branch --list "$canal_branch") ]; then
err "Branch name "canal_branch" already exists locally. Please delete it first."
fi
if ! [ -z $(git ls-remote --heads [email protected]:canalplus/rx-player.git "refs/heads/$dev_branch") ]; then
err "Branch name "$dev_branch" already exists remotely. Please delete it first."
fi
if ! [ -z $(git ls-remote --heads [email protected]:canalplus/rx-player.git "refs/heads/$canal_branch") ]; then
err "Branch name "$canal_branch" already exists remotely. Please delete it first."
fi

echo "checking that the versions are not already published on npm..."
if npm view rx-player@$dev_version >/dev/null 2>&1; then
err "Version already published to npm: $version-dev.${date}${incr}"
fi

if npm view rx-player@$canal_version >/dev/null 2>&1; then
err "Version already published to npm: $version-canal.${date}${incr}"
fi

# Make dev Changelog
npm run releases:changelog -- $dev_version -d

$EDITOR CHANGELOG.md

if [ -n "$(git status --porcelain CHANGELOG.md)" ]; then
echo "-- Current CHANGELOG.md Status: --"
echo ""
git status CHANGELOG.md

while :; do
echo ""
echo "We will push this CHANGELOG.md update to ${current_branch}."
read -p "do you want to continue [y/d/s/a/c/t/h] (h for help) ? " -n1 REPLY
echo ""

if [[ $REPLY =~ ^[Hh](elp)?$ ]]; then
echo ""
echo ""
echo "+- help -------------------------------------------------+"
echo "| y: commit and continue |"
echo "| d: see diff |"
echo "| s: see status |"
echo "| a: abort script from here |"
echo "| c: skip CHANGELOG.md update and go to the next step |"
echo "| h: see this help |"
echo "+--------------------------------------------------------+"
elif [[ $REPLY =~ ^[Yy](es)?$ ]]; then
git add CHANGELOG.md
git commit -m "Update CHANGELOG.md for v$dev_version"
git push [email protected]:canalplus/rx-player.git $current_branch
break
elif [[ $REPLY =~ ^[Dd](iff)?$ ]]; then
git diff CHANGELOG.md || true # ignore when return 1
elif [[ $REPLY =~ ^[Ss](tatus)?$ ]]; then
git status CHANGELOG.md
elif [[ $REPLY =~ ^[Aa](bort)?$ ]]; then
echo "exiting"
exit 0
elif [[ $REPLY =~ ^[Cc](heckout)?$ ]]; then
git checkout CHANGELOG.md
else
echo "invalid input"
fi
done
fi

if [ -n "$(git status --porcelain doc)" ]; then
echo "ERROR: Unexpected diff in \"${current_branch}\""
exit 1
fi

git checkout -b ${dev_branch}
./scripts/update-version $version-dev.${date}${incr}
Expand All @@ -62,9 +157,9 @@ while true; do
read -n1 -p "Do you wish to push and publish the dev build? [y/n] " yn
echo ""
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
* ) echo "Please answer y or n.";;
[Yy]*) break ;;
[Nn]*) exit ;;
*) echo "Please answer y or n." ;;
esac
done
git push origin ${dev_branch}
Expand All @@ -82,9 +177,9 @@ while true; do
read -n1 -p "Do you wish to push and publish the canal build? [y/n] " yn
echo ""
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
* ) echo "Please answer y or n.";;
[Yy]*) break ;;
[Nn]*) exit ;;
*) echo "Please answer y or n." ;;
esac
done
npm publish --tag canal-v4
Loading
Loading