diff --git a/.github/scripts/defineVersion.js b/.github/scripts/defineVersion.js new file mode 100644 index 00000000..de87dfcb --- /dev/null +++ b/.github/scripts/defineVersion.js @@ -0,0 +1,35 @@ +const parseChangelog = require('changelog-parser'); +const semver = require('semver'); + +async function defineReleaseVersion({ core }, currentVersion, changelogFile) { + return parseChangelog(changelogFile).then((result) => { + const unreleased = result.versions.find((entry) => entry.version === null); + + if (!unreleased.parsed) { + core.error('No unreleased section found', unreleased); + return; + } + + const parsedSections = unreleased.parsed; + + const hasAddedSection = parsedSections.Added && parsedSections.Added.length > 0; + const hasChangedSection = parsedSections.Changed && parsedSections.Changed.length > 0; + const hasRemovedSection = parsedSections.Removed && parsedSections.Removed.length > 0; + + const hasFixedSection = parsedSections.Fixed && parsedSections.Fixed.length > 0; + const hasSecurityEntries = parsedSections.Security && parsedSections.Security.length > 0; + const hasDeprecatedEntries = parsedSections.Deprecated && parsedSections.Deprecated.length > 0; + + if (hasAddedSection || hasChangedSection || hasRemovedSection) { + const version = semver.inc(currentVersion, 'minor'); + core.info(`Increase version from ${currentVersion} to ${version}`); + return version; + } else if (hasFixedSection || hasSecurityEntries || hasDeprecatedEntries) { + const version = semver.inc(currentVersion, 'patch'); + core.info(`Increase version from ${currentVersion} to ${version}`); + return version; + } else { + core.error('No valid entries to release', unreleased); + } + }); +} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..adad6d67 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,71 @@ +name: Release new version + +on: + workflow_dispatch: + +jobs: + release: + runs-on: ubuntu-latest + + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - name: Checkout + uses: actions/checkout@v3 + + # The Yospace private npm registry seems to not support NPM token so we sadly need to use password and email + - name: Log in to Yospace private NPM registry + run: | + cp .npmrc ~/.npmrc + echo "//yospacerepo.jfrog.io/artifactory/api/npm/javascript-sdk/:_password=${{ secrets.NPM_YOSPACE_PASS }}" >> ~/.npmrc + echo "//yospacerepo.jfrog.io/artifactory/api/npm/javascript-sdk/:username=${{ secrets.NPM_YOSPACE_USER }}" >> ~/.npmrc + echo "//yospacerepo.jfrog.io/artifactory/api/npm/javascript-sdk/:email=${{ secrets.NPM_YOSPACE_EMAIL }}" >> ~/.npmrc + + - name: Set up node.js + uses: actions/setup-node@v3.3.0 + with: + node-version-file: .nvmrc + + - name: Install dependencies + run: npm ci + + - name: Lint + run: npm run lint + + - name: Build + run: npm run build + + - name: Read latest release version from package.json + uses: actions/github-script@v6 + id: read-latest-release-version + with: + script: | + const { version } = require('./package.json') + core.info(`Latest release version is ${version}`) + core.setOutput('latestReleaseVersion', version) + + - name: Define next release version based on Changelog entries + uses: actions/github-script@v6 + id: define-release-version + with: + script: | + const { defineReleaseVersion } = require('./.github/scripts/defineVersion.js') + return defineReleaseVersion({core}, "${{ steps.define-package-json-version.outputs.packageJsonVersion }}", './CHANGELOG.md' ) + + - name: Bump package.json and Changelog version and tag commit + run: | + git config --global user.name 'Automated Release' + git config --global user.email 'release-automation@bitmovin.com' + npm version "${{ fromJson(steps.define-release-version.outputs.result) }}" + kacl release + + - name: Push changes + run: | + git add . + git commit -m "Bump version and update changelog" + git push origin develop + git push origin --tags + + - name: build and publish + run: | + echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_AUTH_TOKEN }}" > ~/.npmrc + npm run publish diff --git a/package-lock.json b/package-lock.json index 97fafc0b..4a8c4f0b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,6 @@ "license": "MIT", "dependencies": { "@yospace/admanagement-sdk": "3.6.0", - "bitmovin-player": "^8.157.0", "fast-safe-stringify": "^2.0.7", "process": "^0.11.10", "stream-browserify": "^3.0.0" @@ -20,11 +19,13 @@ "@typescript-eslint/parser": "^5.27.1", "bitmovin-analytics": "^2.27.0", "bitmovin-player-ui": "^3.37.0", + "changelog-parser": "^3.0.1", "eslint": "^8.17.0", "husky": "^8.0.1", "kacl": "^1.1.1", "lint-staged": "^13.0.1", "prettier": "2.6.2", + "semver": "^7.6.0", "ts-loader": "^9.3.0", "typescript": "^3.9.10", "webpack": "^5.73.0", @@ -35,7 +36,7 @@ }, "peerDependencies": { "@yospace/admanagement-sdk": "3.6.0", - "bitmovin-player": "^8.114.0" + "bitmovin-player": "^8.157.0" } }, "node_modules/@discoveryjs/json-ext": { @@ -475,21 +476,6 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, - "node_modules/@typescript-eslint/eslint-plugin/node_modules/semver": { - "version": "7.3.7", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", - "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", - "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/@typescript-eslint/eslint-plugin/node_modules/tsutils": { "version": "3.21.0", "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz", @@ -699,21 +685,6 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, - "node_modules/@typescript-eslint/typescript-estree/node_modules/semver": { - "version": "7.3.7", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", - "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", - "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/@typescript-eslint/typescript-estree/node_modules/tsutils": { "version": "3.21.0", "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz", @@ -1219,7 +1190,8 @@ "node_modules/bitmovin-player": { "version": "8.157.0", "resolved": "https://registry.npmjs.org/bitmovin-player/-/bitmovin-player-8.157.0.tgz", - "integrity": "sha512-+iCw2gJBQDVCcukYXwtBa7u7VMb40POzj1VB6Nq+/wNP91HfL8SwsUuX0KigyScSam/rY1gxvnllIKQlqq80Ag==" + "integrity": "sha512-+iCw2gJBQDVCcukYXwtBa7u7VMb40POzj1VB6Nq+/wNP91HfL8SwsUuX0KigyScSam/rY1gxvnllIKQlqq80Ag==", + "peer": true }, "node_modules/bitmovin-player-ui": { "version": "3.37.0", @@ -1376,6 +1348,22 @@ } ] }, + "node_modules/changelog-parser": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/changelog-parser/-/changelog-parser-3.0.1.tgz", + "integrity": "sha512-1AEVJgnFEO4v5ukfEH/j9cr2Z39Y/GCieNi605azhufAolXF4vQAwZBY8BrUVRkvlI3gwe3i621/PIAW0zmmEQ==", + "dev": true, + "dependencies": { + "line-reader": "^0.2.4", + "remove-markdown": "^0.5.0" + }, + "bin": { + "changelog-parser": "bin/cli.js" + }, + "engines": { + "node": ">=14" + } + }, "node_modules/chokidar": { "version": "3.5.3", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", @@ -3045,6 +3033,12 @@ "node": ">=10" } }, + "node_modules/line-reader": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/line-reader/-/line-reader-0.2.4.tgz", + "integrity": "sha512-342xzyZZS9uTiKwHJcMacopVl/WjrMMCZS1Qg4Uhl/WBknWRrGFdKOIS1Kec6SaiTcZMtmuxWvvIbPXj/+FMjA==", + "dev": true + }, "node_modules/lint-staged": { "version": "13.0.1", "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-13.0.1.tgz", @@ -4114,6 +4108,12 @@ "url": "https://github.com/sponsors/mysticatea" } }, + "node_modules/remove-markdown": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/remove-markdown/-/remove-markdown-0.5.0.tgz", + "integrity": "sha512-x917M80K97K5IN1L8lUvFehsfhR8cYjGQ/yAMRI9E7JIKivtl5Emo5iD13DhMr+VojzMCiYk8V2byNPwT/oapg==", + "dev": true + }, "node_modules/require-from-string": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", @@ -4324,6 +4324,21 @@ "node": ">=10" } }, + "node_modules/semver": { + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", + "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/send": { "version": "0.18.0", "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", @@ -4914,21 +4929,6 @@ "node": ">=8" } }, - "node_modules/ts-loader/node_modules/semver": { - "version": "7.3.7", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", - "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", - "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/ts-loader/node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -5904,15 +5904,6 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, - "semver": { - "version": "7.3.7", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", - "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", - "dev": true, - "requires": { - "lru-cache": "^6.0.0" - } - }, "tsutils": { "version": "3.21.0", "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz", @@ -6036,15 +6027,6 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, - "semver": { - "version": "7.3.7", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", - "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", - "dev": true, - "requires": { - "lru-cache": "^6.0.0" - } - }, "tsutils": { "version": "3.21.0", "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz", @@ -6447,7 +6429,8 @@ "bitmovin-player": { "version": "8.157.0", "resolved": "https://registry.npmjs.org/bitmovin-player/-/bitmovin-player-8.157.0.tgz", - "integrity": "sha512-+iCw2gJBQDVCcukYXwtBa7u7VMb40POzj1VB6Nq+/wNP91HfL8SwsUuX0KigyScSam/rY1gxvnllIKQlqq80Ag==" + "integrity": "sha512-+iCw2gJBQDVCcukYXwtBa7u7VMb40POzj1VB6Nq+/wNP91HfL8SwsUuX0KigyScSam/rY1gxvnllIKQlqq80Ag==", + "peer": true }, "bitmovin-player-ui": { "version": "3.37.0", @@ -6561,6 +6544,16 @@ "integrity": "sha512-q6ibZUO2t88QCIPayP/euuDREq+aMAxFE5S70PkrLh0iTDj/zEhgvJRKC2+CvXY6EWc6oQwUR48lL5vCW6jiXQ==", "dev": true }, + "changelog-parser": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/changelog-parser/-/changelog-parser-3.0.1.tgz", + "integrity": "sha512-1AEVJgnFEO4v5ukfEH/j9cr2Z39Y/GCieNi605azhufAolXF4vQAwZBY8BrUVRkvlI3gwe3i621/PIAW0zmmEQ==", + "dev": true, + "requires": { + "line-reader": "^0.2.4", + "remove-markdown": "^0.5.0" + } + }, "chokidar": { "version": "3.5.3", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", @@ -7821,6 +7814,12 @@ "integrity": "sha512-xaYmXZtTHPAw5m+xLN8ab9C+3a8YmV3asNSPOATITbtwrfbwaLJj8h66H1WMIpALCkqsIzK3h7oQ+PdX+LQ9Eg==", "dev": true }, + "line-reader": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/line-reader/-/line-reader-0.2.4.tgz", + "integrity": "sha512-342xzyZZS9uTiKwHJcMacopVl/WjrMMCZS1Qg4Uhl/WBknWRrGFdKOIS1Kec6SaiTcZMtmuxWvvIbPXj/+FMjA==", + "dev": true + }, "lint-staged": { "version": "13.0.1", "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-13.0.1.tgz", @@ -8573,6 +8572,12 @@ "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", "dev": true }, + "remove-markdown": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/remove-markdown/-/remove-markdown-0.5.0.tgz", + "integrity": "sha512-x917M80K97K5IN1L8lUvFehsfhR8cYjGQ/yAMRI9E7JIKivtl5Emo5iD13DhMr+VojzMCiYk8V2byNPwT/oapg==", + "dev": true + }, "require-from-string": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", @@ -8716,6 +8721,15 @@ "node-forge": "^1" } }, + "semver": { + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", + "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } + }, "send": { "version": "0.18.0", "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", @@ -9155,15 +9169,6 @@ "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true }, - "semver": { - "version": "7.3.7", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", - "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", - "dev": true, - "requires": { - "lru-cache": "^6.0.0" - } - }, "supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", diff --git a/package.json b/package.json index 39e096bb..ff5bda1c 100644 --- a/package.json +++ b/package.json @@ -28,25 +28,26 @@ "license": "MIT", "dependencies": { "@yospace/admanagement-sdk": "3.6.0", - "bitmovin-player": "^8.157.0", "fast-safe-stringify": "^2.0.7", "process": "^0.11.10", "stream-browserify": "^3.0.0" }, "peerDependencies": { "@yospace/admanagement-sdk": "3.6.0", - "bitmovin-player": "^8.114.0" + "bitmovin-player": "^8.157.0" }, "devDependencies": { "@typescript-eslint/eslint-plugin": "^5.27.1", "@typescript-eslint/parser": "^5.27.1", "bitmovin-analytics": "^2.27.0", "bitmovin-player-ui": "^3.37.0", + "changelog-parser": "^3.0.1", "eslint": "^8.17.0", "husky": "^8.0.1", "kacl": "^1.1.1", "lint-staged": "^13.0.1", "prettier": "2.6.2", + "semver": "^7.6.0", "ts-loader": "^9.3.0", "typescript": "^3.9.10", "webpack": "^5.73.0",