Skip to content

Commit

Permalink
alpha => canary
Browse files Browse the repository at this point in the history
  • Loading branch information
tjenkinson committed Nov 3, 2020
1 parent 90b5013 commit 115ffda
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
14 changes: 7 additions & 7 deletions scripts/publish-npm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ if [[ $(node ./scripts/check-already-published.js) = "not published" ]]; then
# see https://docs.npmjs.com/private-modules/ci-server-config
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> .npmrc
if [[ -z "$TAG" ]]; then
npm publish --tag alpha
echo "Published alpha."
curl https://purge.jsdelivr.net/npm/hls.js@alpha
curl https://purge.jsdelivr.net/npm/hls.js@alpha/dist/hls-demo.js
npm publish --tag canary
echo "Published canary."
curl https://purge.jsdelivr.net/npm/hls.js@canary
curl https://purge.jsdelivr.net/npm/hls.js@canary/dist/hls-demo.js
echo "Cleared jsdelivr cache."
else
tag=$(node ./scripts/get-version-tag.js)
if [ "${tag}" = "alpha" ]; then
# alpha (previously canary) is blocked because this is handled separately on every commit
echo "alpha (previously canary) not supported as explicit tag"
if [ "${tag}" = "canary" ]; then
# canary is blocked because this is handled separately on every commit
echo "canary not supported as explicit tag"
exit 1
fi
echo "Publishing tag: ${tag}"
Expand Down
12 changes: 6 additions & 6 deletions scripts/set-package-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ try {
}
// remove v
newVersion = tag.substring(1);
if (!versionParser.isDefinitelyGreaterThanAlphas(newVersion)) {
// 1.2.3-0.alpha.500
// 1.2.3-0.alpha.501
// 1.2.3-0.aaalpha.custom => bad
// 1.2.3-0.aaalpha.custom.0.alpha.503 => now lower than 1.2.3-0.alpha.501
throw new Error(`It's possible that "${newVersion}" has a lower precedense than an existing alpha version which is not allowed.`);
if (!versionParser.isDefinitelyGreaterThanCanaries(newVersion)) {
// 1.2.3-0.canary.500
// 1.2.3-0.canary.501
// 1.2.3-0.caaanary.custom => bad
// 1.2.3-0.caaanary.custom.0.canary.503 => now lower than 1.2.3-0.canary.501
throw new Error(`It's possible that "${newVersion}" has a lower precedense than an existing canary version which is not allowed.`);
}
} else {
// bump patch in version from latest git tag
Expand Down
8 changes: 4 additions & 4 deletions scripts/version-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ module.exports = {
return semver.gte(newVersion, previousVersion);
},
// returns true if the provided version is definitely greater than any existing
// auto generated alpha versions
isDefinitelyGreaterThanAlphas: (version) => {
// auto generated canary versions
isDefinitelyGreaterThanCanaries: (version) => {
const parsed = semver.parse(version, { loose: false, includePrerelease: true });
if (!parsed) {
throw new Error('Error parsing version.');
}

// anything after a part of `0` must be greater than `alpha`
// anything after a part of `0` must be greater than `canary`
let hadZero = false;
return parsed.prerelease.every((part) => {
if (hadZero && part <= 'alpha') {
if (hadZero && part <= 'canary') {
return false;
} else {
hadZero = false;
Expand Down

0 comments on commit 115ffda

Please sign in to comment.