Skip to content

Commit

Permalink
Tag canaries as alpha releases and append alpha revision to latest ve…
Browse files Browse the repository at this point in the history
…rsion in ci builds
  • Loading branch information
Rob Walch committed Jun 22, 2020
1 parent 5517830 commit 82fbefd
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
21 changes: 14 additions & 7 deletions demo/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,7 @@ $(document).ready(function () {
$('#levelCapping').val(levelCapping);

const version = Hls.version;
const release = (version ? version.replace(/\+.*$/, '') : '').replace(/^(.+[^\d])(\d+?-0)$/,
function (version, majorMinor, ciPatch) {
if (ciPatch) {
return majorMinor + (parseInt(ciPatch, 10) - 1);
}
return version;
});
const release = getReleaseVersion(version || '');
const versionLabel = version ? 'v' + version : 'releases';
$('h2').append('&nbsp;<a target=_blank href="https://github.com/video-dev/hls.js/releases/' +
(release ? 'tag/v' + release : '') + '">' + versionLabel + '</a>');
Expand All @@ -136,6 +130,19 @@ $(document).ready(function () {
loadSelectedStream();
});

function getReleaseVersion (version) {
const ciBuildRegEx = /[-.](?:alpha|pr|branch)\..+$/
if (ciBuildRegEx.test(version)) {
return version.replace(ciBuildRegEx, '').replace(/^(\d+\.\d+\.)(\d+)$/, function (version, majorMinor, ciPatch) {
if (ciPatch) {
return majorMinor + (parseInt(ciPatch, 10) - 1);
}
return version;
});
}
return version;
}

function setupGlobals () {
window.events = events = {
url: url,
Expand Down
8 changes: 4 additions & 4 deletions scripts/set-package-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ try {
}
}

const preReleaseMeta = preRelease ? '+' : '-0+';
const preReleaseDelimiter = preRelease ? '.' : '-';
if (TRAVIS_MODE === 'netlifyPr') {
newVersion += `${preReleaseMeta}pr.${getCommitHash().substr(0, 8)}`;
newVersion += `${preReleaseDelimiter}pr.${getCommitHash().substr(0, 8)}`;
} else if (TRAVIS_MODE === 'netlifyBranch') {
newVersion += `${preReleaseMeta}branch.${process.env.BRANCH/* set by netlify */.replace(/[^a-zA-Z0-9]/g, '-')}.${getCommitHash().substr(0, 8)}`;
newVersion += `${preReleaseDelimiter}branch.${process.env.BRANCH/* set by netlify */.replace(/[^a-zA-Z0-9]/g, '_')}.${getCommitHash().substr(0, 8)}`;
} else {
newVersion += `${preReleaseMeta}canary.${getCommitNum()}`;
newVersion += `${preReleaseDelimiter}alpha.${getCommitNum()}`;
}
} else {
throw new Error('Unsupported travis mode: ' + TRAVIS_MODE);
Expand Down
6 changes: 3 additions & 3 deletions scripts/travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ elif [ "${TRAVIS_MODE}" = "release" ] || [ "${TRAVIS_MODE}" = "releaseCanary" ]
echo "Cleared jsdelivr cache."
elif [ "${TRAVIS_MODE}" = "release" ]; then
tag=$(node ./scripts/get-version-tag.js)
if [ "${tag}" = "canary" ]; then
# canary is blacklisted because this is handled separately on every commit
echo "canary not supported as explicit tag"
if [ "${tag}" = "alpha" ]; then
# alpha (previously canary) is blacklisted because this is handled separately on every commit
echo "alpha (previously canary) not supported as explicit tag"
exit 1
fi
echo "Publishing tag: ${tag}"
Expand Down
4 changes: 4 additions & 0 deletions scripts/version-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@ module.exports = {
// e.g
// v1.2.3-beta => beta
// v1.2.3-beta.1 => beta
// v1.2.3-beta.1.alpha.53 => alpha
// v1.2.3 => latest
getVersionTag: function (version) {
const match = VALID_VERSION_REGEX.exec(version);
if (!match) {
throw new Error('Invalid version.');
}
if (match[3] === 'alpha') {
return match[3];
}
return match[1] || 'latest';
}
};

0 comments on commit 82fbefd

Please sign in to comment.