Skip to content

Commit

Permalink
Merge branch 'develop' into feature/reduce-forced-reflows
Browse files Browse the repository at this point in the history
  • Loading branch information
felix-hoc authored Nov 19, 2024
2 parents 1a78f8a + 152b3b2 commit 83092d6
Show file tree
Hide file tree
Showing 131 changed files with 3,016 additions and 697 deletions.
11 changes: 11 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
blank_issues_enabled: false
contact_links:
- name: Report a Bug
url: https://dashboard.bitmovin.com/support/tickets
about: Report a Bug you encountered in our Bitmovin Player UI in your Bitmovin Customer Dashboard.
- name: Feature Requests
url: https://community.bitmovin.com/t/how-to-submit-a-feature-request-to-us/1463
about: Learn how to suggest new features for our Player SDKs.
- name: Report a security vulnerability
url: https://bitmovin.atlassian.net/wiki/external/1502085332/YTYwODMwZjQyNjkwNGQ0ODg5MTgwM2NhMDliNjRmODE
about: Report a security vulnerability.
7 changes: 7 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Description
<!-- Add a short description about the changes -->

## Checklist (for PR submitter and reviewers)
<!-- A PR with CHANGELOG entry will be released automatically -->
<!-- This is required and should be added in every case -->
- [ ] `CHANGELOG` entry
29 changes: 29 additions & 0 deletions .github/scripts/defineVersion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const semver = require('semver');

function getPlayerUiVersion(versionInput) {
const playerUiVersion = semver.valid(versionInput);
if (!playerUiVersion) {
console.error(`${versionInput} is not a valid semver`);
process.exit(1);
}

return {
major: semver.major(playerUiVersion),
minor: semver.minor(playerUiVersion),
patch: semver.patch(playerUiVersion),
prereleaseLabels: semver.prerelease(playerUiVersion),
full: playerUiVersion,
};
}

function defineReleaseVersion({ core }, targetReleaseLevel, givenVersion) {
core.info(`Defining new release version for level ${targetReleaseLevel} and version ${givenVersion}`);

const newVersion = semver.inc(givenVersion, targetReleaseLevel);

const parsedPlayerVersion = getPlayerUiVersion(newVersion);
core.info(`Using release version ${parsedPlayerVersion.full}`);
return parsedPlayerVersion;
}

module.exports.defineReleaseVersion = defineReleaseVersion;
79 changes: 79 additions & 0 deletions .github/scripts/notifySlackTeam.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
const fs = require('fs');
const https = require('https');

const jobStatus = process.argv[2];
const changelogPath = process.argv[3];
const slackWebhookUrl = process.argv[4];
const runId = process.argv[5];

const failureSlackChannelId = 'CGRK9DV7H';
const successSlackChannelId = 'C0LJ16JBS';

fs.readFile(changelogPath, 'utf8', (err, fileContent) => {
if (err) {
throw err;
}

const changelogContent = parseChangelogEntry(fileContent);
const releaseVersion = parseReleaseVersion(fileContent);
sendSlackMessage(releaseVersion, changelogContent);
});

function parseReleaseVersion(fileContent) {
const regex = /##\s\[(\d+\.\d+.\d+)\]/;
const releaseVersion = fileContent.match(regex);

return releaseVersion[1];
}

function parseChangelogEntry(fileContent) {
// The regex looks for the first paragraph starting with "###" until it finds
// a paragraph starting with "##".
// For some reason it also matches 2 chars at the end. With the .slice
// those 2 chars get removed from the string.
const regex = /###(.)*[\s\S]*?(?=\s##\s\[v*?)/;

let changelogContent = fileContent.match(regex);
changelogContent = changelogContent.slice(0, -1);
return changelogContent.toString();
}

function sendSlackMessage(releaseVersion, changelogContent) {
let message;
let slackChannelId;
if (jobStatus === 'success') {
slackChannelId = successSlackChannelId
message = `Changelog v${releaseVersion}\n${changelogContent}`
} else {
slackChannelId = failureSlackChannelId
message = `Release v${releaseVersion} failed.\nPlease check https://github.com/bitmovin/bitmovin-player-ui/actions/runs/${runId}`
}

const sampleData = JSON.stringify({
"channel": slackChannelId,
"message": message
});
const options = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': "application/json",
}
};

var req = https.request(slackWebhookUrl, options, (res) => {
console.log('statusCode:', res.statusCode);
console.log('headers:', res.headers);

res.on('data', (d) => {
process.stdout.write(d);
});
});

req.on('error', (e) => {
console.error(e);
});

req.write(sampleData);
req.end();
}
24 changes: 24 additions & 0 deletions .github/scripts/updateChangelog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Updates the changelog by replacing the changelog header with the correct version
*
* @param {string} changelogString the content of the changelog file
* @param {string} version the player version to be released
* @param {string} releaseDate the release date to be written to the changelog
*/
function updateChangeLog(changelogString, version, releaseDate) {
const optionalBetaOrRc = '(-rc.d+)?(-(b|beta).d+)?';
const changelogVersionRegExp = new RegExp(
`\\[(development|develop|unreleased|${version})${optionalBetaOrRc}.*`,
'gi',
);

const lastReleaseVersion = changelogString.match(/## \[(\d+.\d+.\d+)\] - \d{4}-\d{2}-\d{2}/)[1];
const changelogWithReleaseVersionAndDate = changelogString.replace(changelogVersionRegExp, `[${version}] - ${releaseDate}`);

return changelogWithReleaseVersionAndDate.replace(
'## 1.0.0 (2017-02-03)\n- First release\n\n',
`## 1.0.0 (2017-02-03)\n- First release\n\n[${version}]: https://github.com/bitmovin/bitmovin-player-ui/compare/v${lastReleaseVersion}...v${version}\n`
);
}

module.exports.updateChangeLog = updateChangeLog;
52 changes: 51 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,20 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: develop

- name: Install dependencies
run: npm ci

- name: Read package.json version
uses: actions/github-script@v6
id: extract-version
with:
script: |
const { version } = require('./package.json')
core.setOutput('packageJsonVersion', version)
- uses: actions/download-artifact@v3
with:
Expand All @@ -32,3 +45,40 @@ jobs:
env:
NPM_DRY_RUN: false
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

- name: Build documentation
run: npx typedoc
shell: bash

- name: Authenticate
uses: 'google-github-actions/auth@v2'
with:
credentials_json: ${{ secrets.GCS_CREDENTIALS }}

- name: Upload docs
uses: 'google-github-actions/upload-cloud-storage@v2'
with:
path: './docs/'
destination: "${{ secrets.GCS_BUCKET }}/player/ui/${{ steps.extract-version.outputs.packageJsonVersion }}"

- name: Upload docs for major version
uses: 'google-github-actions/upload-cloud-storage@v2'
with:
path: './docs/'
destination: "${{ secrets.GCS_BUCKET }}/player/ui/3"

- name: Notify team
run: node .github/scripts/notifySlackTeam.js 'success' 'CHANGELOG.md' ${{ secrets.RELEASE_SUCCESS_SLACK_WEBHOOK }}

handle_failure:
runs-on: ubuntu-latest
needs: [test_and_build, download_and_publish]
if: ${{ always() && (needs.download_and_publish.result == 'failure' || needs.test_and_build.result == 'failure') }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: develop

- name: Notify team
run: node .github/scripts/notifySlackTeam.js 'failure' 'CHANGELOG.md' ${{ secrets.RELEASE_FAILURE_SLACK_WEBHOOK }} ${{ github.run_id }}
74 changes: 74 additions & 0 deletions .github/workflows/tag-release-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Trigger release on merge
run-name: Starting release for ${{ github.actor }} PR merge
on:
pull_request_target:
types:
- closed
branches:
- develop

jobs:
trigger-ui-release:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.RELEASE_DEPLOY_KEY }}
ref: develop

- name: Install dependencies
run: npm ci

- name: Read package.json version
uses: actions/github-script@v6
id: define-package-json-version
with:
script: |
const { version } = require('./package.json')
core.info(`performing a minor release for existing version ${version}`)
core.setOutput('packageJsonVersion', version)
- name: Define release version
uses: actions/github-script@v6
id: define-release-version
with:
script: |
const { defineReleaseVersion } = require('./.github/scripts/defineVersion.js')
return defineReleaseVersion({core}, 'minor', "${{ steps.define-package-json-version.outputs.packageJsonVersion }}" )
- name: Bump package.json version
run: |
git config --global user.name 'Automated Release'
git config --global user.email '[email protected]'
npm version "${{ fromJson(steps.define-release-version.outputs.result).full }}"
- name: Update Changelog
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
const { updateChangeLog } = require('./.github/scripts/updateChangelog.js')
const stableVersion = '${{ fromJson(steps.define-release-version.outputs.result).full }}'.split('-')[0]
const releaseDate = new Date().toISOString().split('T')[0]
const data = fs.readFileSync('./CHANGELOG.md',{encoding:'utf8', flag:'r'});
core.info(`Updating ${stableVersion} with date ${releaseDate} in Changelog`);
const changelogFileContents = updateChangeLog(data, stableVersion, releaseDate);
fs.writeFileSync('./CHANGELOG.md', changelogFileContents, 'utf-8');
- name: Push changes
run: |
git add .
git commit -m "Add release date to changelog"
git push origin develop
git push origin --tags
- name: Notify failure
if: ${{ failure() }}
run: node .github/scripts/notifySlackTeam.js 'failure' 'CHANGELOG.md' ${{ secrets.RELEASE_FAILURE_SLACK_WEBHOOK }} ${{ github.run_id }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -416,3 +416,4 @@ jspm_packages

# Yarn Integrity file
.yarn-integrity
docs
Loading

0 comments on commit 83092d6

Please sign in to comment.