Add create beta/stable release branch actions (#1394)
* Add script to generate changelog without bump * Add create branch script for beta and stable * Add stable to release validation * Adjust strings to action title
This commit is contained in:
Родитель
20d85e4add
Коммит
8115e294c8
|
@ -0,0 +1,109 @@
|
|||
# Bump package version numbers and create a release branch
|
||||
name: Beta release branch - Create
|
||||
|
||||
on:
|
||||
# Allows you to run this workflow manually from the Actions tab
|
||||
workflow_dispatch:
|
||||
branch:
|
||||
description: 'Branch or tag to create release from'
|
||||
required: true
|
||||
default: 'main'
|
||||
|
||||
jobs:
|
||||
create_beta_release:
|
||||
name: Bump versions and create changelog PR
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
# Check-out repo
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
# Use a machine account when checking out. This is to workaround the issue were GitHub
|
||||
# actions, when using the default account, cannot trigger other actions. And we want this
|
||||
# action to trigger the regular CI pipeline on the created branch.
|
||||
# This machine account is only for this PAT, pwd was created and thrown away
|
||||
# If any update needed, create a new account, add access to the repo and generate a new PAT
|
||||
token: ${{ secrets.MACHINE_ACCOUNT_PAT }}
|
||||
|
||||
# Setup bot information for creating pull request
|
||||
# Here we use the id from the github actions bot: https://api.github.com/users/better-informatics%5Bbot%5D
|
||||
- name: Setup bot git information
|
||||
run: |
|
||||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||
git config user.name "github-actions[bot]"
|
||||
|
||||
# Check out onto desired branch or tag to create release from
|
||||
- name: Checkout tag/branch
|
||||
run: git checkout ${{ github.event.inputs.branch }}
|
||||
|
||||
# Ensure node version is great enough
|
||||
- name: Use Node.js v14.x
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: '14.x'
|
||||
|
||||
# Try get node_modules from cache
|
||||
- name: Restore node_modules from cache
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: common/temp/pnpm-store
|
||||
key: ${{ runner.os }}-${{ hashFiles('common/config/rush/pnpm-lock.yaml') }}
|
||||
|
||||
# Install dependencies
|
||||
- name: Install rush
|
||||
run: npm install -g @microsoft/rush@5.47.0
|
||||
- name: Install dependencies
|
||||
run: rush install
|
||||
|
||||
# Bump package versions
|
||||
- name: Bump package versions
|
||||
run: node common/scripts/bump-beta-version.js
|
||||
|
||||
# Choose beta dependency for sdk
|
||||
- name: Choose beta dependency for sdk
|
||||
run: node common/scripts/choose-beta-sdk-deps.js
|
||||
|
||||
# Generate changelog using beachball
|
||||
- name: Generate changelog using beachball
|
||||
run: node common/scripts/beachball-changelog-only.js
|
||||
|
||||
- name: Synchronize package version reported to telemetry
|
||||
run: node common/scripts/sync-telemetry-package-version
|
||||
|
||||
# Important to check version consistency again after bumping versions.
|
||||
- name: Ensure all package versions are consistent
|
||||
run: rush ensure-consistent-versions
|
||||
|
||||
# Retrieve new version to create branch with
|
||||
- name: Retrieve new version from package.json
|
||||
id: version
|
||||
run: |
|
||||
ver=$(jq -r .version packages/communication-react/package.json)
|
||||
echo version: $ver
|
||||
echo "::set-output name=version::$ver"
|
||||
|
||||
# Commit changes
|
||||
- name: Hop into new branch
|
||||
run: git checkout -b release/${{ steps.version.outputs.version }}
|
||||
- name: Commit changes
|
||||
run: |
|
||||
git add .
|
||||
git commit -m "Beta version bump"
|
||||
|
||||
# Create beachball change files
|
||||
- name: Create change files
|
||||
run: node common/config/node_modules/beachball/bin/beachball change --message 'Bump package version to ${{ steps.version.outputs.version }}' --type 'none'
|
||||
|
||||
# Push changes
|
||||
- name: Push branch
|
||||
run: git push --set-upstream origin release/${{ steps.version.outputs.version }}
|
||||
|
||||
# Create a PR from the changes
|
||||
- name: Create PR
|
||||
run: |
|
||||
curl \
|
||||
-X POST \
|
||||
-H 'Accept: application/vnd.github.v3+json' \
|
||||
-H 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
|
||||
https://api.github.com/repos/Azure/communication-ui-library/pulls \
|
||||
-d '{ "title":"${{ steps.version.outputs.version }} release branch", "head":"release/${{ steps.version.outputs.version }}", "base":"main", "body":"Release branch for ${{ steps.version.outputs.version }}. Created by the `Beta release branch - create` GitHub action. Please review." }'
|
|
@ -0,0 +1,113 @@
|
|||
# Bump package version numbers and create a release branch
|
||||
name: Stable release branch - Create
|
||||
|
||||
on:
|
||||
# Allows you to run this workflow manually from the Actions tab
|
||||
workflow_dispatch:
|
||||
branch:
|
||||
description: 'Branch or tag to create release from'
|
||||
required: true
|
||||
default: 'main'
|
||||
bump_type:
|
||||
description: 'Bump type for stable branch [minor/patch]'
|
||||
required: true
|
||||
default: 'minor'
|
||||
|
||||
jobs:
|
||||
create_stable_release:
|
||||
name: Bump versions and create changelog PR
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
# Check-out repo
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
# Use a machine account when checking out. This is to workaround the issue were GitHub
|
||||
# actions, when using the default account, cannot trigger other actions. And we want this
|
||||
# action to trigger the regular CI pipeline on the created branch.
|
||||
# This machine account is only for this PAT, pwd was created and thrown away
|
||||
# If any update needed, create a new account, add access to the repo and generate a new PAT
|
||||
token: ${{ secrets.MACHINE_ACCOUNT_PAT }}
|
||||
|
||||
# Setup bot information for creating pull request
|
||||
# Here we use the id from the github actions bot: https://api.github.com/users/better-informatics%5Bbot%5D
|
||||
- name: Setup bot git information
|
||||
run: |
|
||||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||
git config user.name "github-actions[bot]"
|
||||
|
||||
# Check out onto desired branch or tag to create release from
|
||||
- name: Checkout tag/branch
|
||||
run: git checkout ${{ github.event.inputs.branch }}
|
||||
|
||||
# Ensure node version is great enough
|
||||
- name: Use Node.js v14.x
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: '14.x'
|
||||
|
||||
# Try get node_modules from cache
|
||||
- name: Restore node_modules from cache
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: common/temp/pnpm-store
|
||||
key: ${{ runner.os }}-${{ hashFiles('common/config/rush/pnpm-lock.yaml') }}
|
||||
|
||||
# Install dependencies
|
||||
- name: Install rush
|
||||
run: npm install -g @microsoft/rush@5.47.0
|
||||
- name: Install dependencies
|
||||
run: rush install
|
||||
|
||||
# Bump package versions
|
||||
- name: Bump package versions
|
||||
run: node common/scripts/bump-stable-version.js ${{ github.event.inputs.branch }}
|
||||
|
||||
# Choose stable dependency for sdk
|
||||
- name: Choose stable dependency for sdk
|
||||
run: node common/scripts/choose-stable-sdk-deps.js
|
||||
|
||||
# Generate changelog using beachball
|
||||
- name: Generate changelog using beachball
|
||||
run: node common/scripts/beachball-changelog-only.js
|
||||
|
||||
- name: Synchronize package version reported to telemetry
|
||||
run: node common/scripts/sync-telemetry-package-version
|
||||
|
||||
# Important to check version consistency again after bumping versions.
|
||||
- name: Ensure all package versions are consistent
|
||||
run: rush ensure-consistent-versions
|
||||
|
||||
# Retrieve new version to create branch with
|
||||
- name: Retrieve new version from package.json
|
||||
id: version
|
||||
run: |
|
||||
ver=$(jq -r .version packages/communication-react/package.json)
|
||||
echo version: $ver
|
||||
echo "::set-output name=version::$ver"
|
||||
|
||||
# Commit changes
|
||||
- name: Hop into new branch
|
||||
run: git checkout -b release/${{ steps.version.outputs.version }}
|
||||
- name: Commit changes
|
||||
run: |
|
||||
git add .
|
||||
git commit -m "Stable version bump"
|
||||
|
||||
# Create beachball change files
|
||||
- name: Create change files
|
||||
run: node common/config/node_modules/beachball/bin/beachball change --message 'Bump package version to ${{ steps.version.outputs.version }}' --type 'none'
|
||||
|
||||
# Push changes
|
||||
- name: Push branch
|
||||
run: git push --set-upstream origin release/${{ steps.version.outputs.version }}
|
||||
|
||||
# Create a PR from the changes
|
||||
- name: Create PR
|
||||
run: |
|
||||
curl \
|
||||
-X POST \
|
||||
-H 'Accept: application/vnd.github.v3+json' \
|
||||
-H 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
|
||||
https://api.github.com/repos/Azure/communication-ui-library/pulls \
|
||||
-d '{ "title":"${{ steps.version.outputs.version }} release branch", "head":"release/${{ steps.version.outputs.version }}", "base":"main", "body":"Release branch for ${{ steps.version.outputs.version }}. Created by the `Stable release branch - create` GitHub action. Please review." }'
|
|
@ -1,4 +1,4 @@
|
|||
name: Deploy beta validation samples
|
||||
name: Deploy release validation samples
|
||||
|
||||
on:
|
||||
push:
|
||||
|
@ -33,6 +33,11 @@ jobs:
|
|||
- name: Install Dependencies
|
||||
run: rush install
|
||||
|
||||
# Switch flavor to stable when it is release branch
|
||||
- name: Switch flavor for stable build
|
||||
if: ${{ !contains(github.ref, 'beta') }}
|
||||
run: rush switch-flavor:stable
|
||||
|
||||
- name: Build Projects
|
||||
run: rush build -v
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
"@octokit/rest": "~18.0.6",
|
||||
"@rollup/plugin-commonjs": "~17.1.0",
|
||||
"@types/node": "^14.14.10",
|
||||
"beachball": "~2.20.0",
|
||||
"beachball": "2.20.0",
|
||||
"rollup": "~2.42.4",
|
||||
"rollup-plugin-sourcemaps": "~0.6.3",
|
||||
"rollup-plugin-svg": "~2.0.0",
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
// This is a workaround for generating changelog without bumping
|
||||
// The issue is that beachball doesn't expose changelog command as documented
|
||||
// Will use the cli command when the issue gets resolved
|
||||
// Issue: https://github.com/microsoft/beachball/issues/634
|
||||
|
||||
const { getPackageInfos } = require('../config/node_modules/beachball/lib/monorepo/getPackageInfos');
|
||||
const { gatherBumpInfo } = require('../config/node_modules/beachball/lib/bump/gatherBumpInfo');
|
||||
const { performBump } = require('../config/node_modules/beachball/lib/bump/performBump');
|
||||
const { getOptions } = require("../config/node_modules/beachball/lib/options/getOptions");
|
||||
|
||||
const options = getOptions(process.argv);
|
||||
const preservedPackages = {};
|
||||
|
||||
const packageInfos = getPackageInfos(options.path);
|
||||
|
||||
// Preserve(deep clone) the current packageInfo before bump, we don't change version number using beachball
|
||||
for (const name in packageInfos) {
|
||||
preservedPackages[name] = JSON.parse(JSON.stringify(packageInfos[name]));
|
||||
}
|
||||
const bumpInfo = gatherBumpInfo(options, packageInfos);
|
||||
|
||||
// Restore packageInfo so no bump to versions by beachball
|
||||
for (const name in bumpInfo.packageInfos) {
|
||||
bumpInfo.packageInfos[name] = preservedPackages[name];
|
||||
}
|
||||
performBump(bumpInfo, options);
|
|
@ -0,0 +1,23 @@
|
|||
const path = require('path');
|
||||
const { updateAllVersions, findAllPackageJSON, getAllNames, updateAllDepVersions } = require('./package-utils');
|
||||
|
||||
const PACKAGES_DIR = path.join(__dirname, '..', '..', 'packages');
|
||||
|
||||
const main = () => {
|
||||
const packagePaths = findAllPackageJSON(PACKAGES_DIR);
|
||||
const depNames = getAllNames(packagePaths);
|
||||
updateAllVersions(bumpBetaVersion);
|
||||
// Need to update all internal project dependencies using the same rule
|
||||
updateAllDepVersions(bumpBetaVersion, depNames);
|
||||
}
|
||||
|
||||
const bumpBetaVersion = (currentVersion) => {
|
||||
const versionStrs = currentVersion.split('-beta.');
|
||||
const currentBeta = versionStrs[1] ? Number.parseInt(versionStrs[1]) : 0;
|
||||
const [major, minor, patch] = versionStrs[0].split('.');
|
||||
|
||||
// We will bump the patch version when create a beta on top of a stable one
|
||||
return [[major, minor, currentBeta === 0? Number.parseInt(patch) + 1 : patch].join('.'), `${currentBeta + 1}`].join('-beta.');
|
||||
}
|
||||
|
||||
main();
|
|
@ -0,0 +1,35 @@
|
|||
const path = require('path');
|
||||
const { updateAllVersions, findAllPackageJSON, getAllNames, updateAllDepVersions } = require('./package-utils');
|
||||
|
||||
const PACKAGES_DIR = path.join(__dirname, '..', '..', 'packages');
|
||||
|
||||
const bumpType = process.argv[2];
|
||||
|
||||
const main = () => {
|
||||
const packagePaths = findAllPackageJSON(PACKAGES_DIR);
|
||||
const depNames = getAllNames(packagePaths);
|
||||
if (!['minor', 'patch'].includes(bumpType)) {
|
||||
throw '\nplease add either minor/patch as parameter!\n\n Syntax:\n node bump-stable-version.js minor\n'
|
||||
}
|
||||
updateAllVersions(bumpVersion);
|
||||
// Need to update all internal project dependencies using the same rule
|
||||
updateAllDepVersions(bumpVersion, depNames);
|
||||
}
|
||||
|
||||
const bumpVersion = (currentVersion) => {
|
||||
// Remove beta suffix if there is one
|
||||
const nonBetaVersion = removeBetaSuffix(currentVersion);
|
||||
const [major, minor, patch] = nonBetaVersion.split('.');
|
||||
const newMinor = bumpType === 'minor' ? Number.parseInt(minor) + 1 : minor;
|
||||
const newPatch = bumpType === 'minor' ?
|
||||
0
|
||||
: bumpType === 'patch' ? Number.parseInt(patch) + 1 : patch;
|
||||
|
||||
return [major, newMinor, newPatch].join('.');
|
||||
}
|
||||
|
||||
const removeBetaSuffix = (currentVersion) => {
|
||||
return currentVersion.split('-beta')[0];
|
||||
}
|
||||
|
||||
main();
|
|
@ -0,0 +1,10 @@
|
|||
const condtion = process.argv.slice(2)[0];
|
||||
if(!condtion || !condtion.includes('=')) {
|
||||
console.error('Please provide a condition to check!');
|
||||
}
|
||||
const envVar = condtion.split('=')[0];
|
||||
const value = condtion.split('=')[1];
|
||||
|
||||
if (process.env[envVar] !== value) {
|
||||
process.exit(1)
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
const { updateAllDepVersions } = require('./package-utils');
|
||||
const sdkDeps = ["@azure/communication-calling", "@azure/communication-chat"]
|
||||
const main = () => {
|
||||
updateAllDepVersions(chooseBetaVersion, sdkDeps);
|
||||
}
|
||||
|
||||
const chooseBetaVersion = (semver) => {
|
||||
const versions = semver.split('||').map(version => version.trim());
|
||||
if(versions.length === 1) {
|
||||
return semver;
|
||||
}
|
||||
for(const version of versions) {
|
||||
if(version.includes('beta')) return version;
|
||||
}
|
||||
throw 'can\'t find the right version for beta!';
|
||||
}
|
||||
|
||||
main();
|
|
@ -0,0 +1,18 @@
|
|||
const { updateAllDepVersions } = require('./package-utils');
|
||||
const sdkDeps = ["@azure/communication-calling", "@azure/communication-chat"]
|
||||
const main = () => {
|
||||
updateAllDepVersions(chooseStableVersion, sdkDeps);
|
||||
}
|
||||
|
||||
const chooseStableVersion = (semver) => {
|
||||
const versions = semver.split('||').map(version => version.trim());
|
||||
if(versions.length === 1) {
|
||||
return semver;
|
||||
}
|
||||
for(const version of versions) {
|
||||
if(!version.includes('beta') && !version.includes('alpha')) return version;
|
||||
}
|
||||
throw 'can\'t find the right version for stable!';
|
||||
}
|
||||
|
||||
main();
|
|
@ -0,0 +1,78 @@
|
|||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const PACKAGES_DIR = path.join(__dirname, '..', '..', 'packages');
|
||||
const SAMPLES_DIR = path.join(__dirname, '..', '..', 'samples');
|
||||
const TOOLS_DIR = path.join(__dirname, '..', '..', 'tools');
|
||||
|
||||
function findAllPackageJSON(root) {
|
||||
return fs.readdirSync(root).map(
|
||||
(pkg) => {
|
||||
const packageJSON = path.join(root, pkg, 'package.json');
|
||||
const stat = fs.lstatSync(packageJSON);
|
||||
if (!stat.isFile()) {
|
||||
throw new Error(packageJSON + ' does not exist!');
|
||||
}
|
||||
return packageJSON;
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
function parsePackage(packagePath) {
|
||||
return JSON.parse(fs.readFileSync(packagePath));
|
||||
}
|
||||
|
||||
function overrideAllPackages(packagePaths, packageProcessFunc) {
|
||||
for (const path of packagePaths) {
|
||||
const packageJson = parsePackage(path);
|
||||
newPackageJson = packageProcessFunc(packageJson);
|
||||
require('fs').writeFileSync(path, JSON.stringify(newPackageJson, null, 2));
|
||||
}
|
||||
}
|
||||
|
||||
const updateAllVersions = (versionUpdater) => {
|
||||
const packagePaths = findAllPackageJSON(PACKAGES_DIR);
|
||||
|
||||
const packageProcessFunc = (packageJson) => {
|
||||
const result = {
|
||||
...packageJson,
|
||||
version: versionUpdater(packageJson.version)
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
overrideAllPackages(packagePaths, packageProcessFunc);
|
||||
}
|
||||
|
||||
const updateAllDepVersions = (versionUpdater, deps/* dependency names to update version*/) => {
|
||||
const packagePaths = [...findAllPackageJSON(PACKAGES_DIR), ...findAllPackageJSON(SAMPLES_DIR), ...findAllPackageJSON(TOOLS_DIR)];
|
||||
|
||||
const packageProcessFunc = (packageJson) => {
|
||||
const result = { ...packageJson };
|
||||
updateDependencies(result.dependencies);
|
||||
updateDependencies(result.devDependencies);
|
||||
updateDependencies(result.peerDependencies);
|
||||
return result;
|
||||
}
|
||||
|
||||
const updateDependencies = (dependencies) => {
|
||||
for (const depName in dependencies) {
|
||||
if (deps.includes(depName)) {
|
||||
dependencies[depName] = versionUpdater(dependencies[depName]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
overrideAllPackages(packagePaths, packageProcessFunc);
|
||||
}
|
||||
|
||||
function getAllNames(packagePaths) {
|
||||
return packagePaths.map(path => parsePackage(path).name);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
updateAllVersions,
|
||||
updateAllDepVersions,
|
||||
findAllPackageJSON,
|
||||
getAllNames
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
const path = require('path');
|
||||
const { updateAllVersions, findAllPackageJSON, getAllNames, updateAllDepVersions } = require('./package-utils');
|
||||
|
||||
const PACKAGES_DIR = path.join(__dirname, '..', '..', 'packages');
|
||||
|
||||
const main = () => {
|
||||
const packagePaths = findAllPackageJSON(PACKAGES_DIR);
|
||||
const depNames = getAllNames(packagePaths);
|
||||
updateAllVersions(removeBetaSuffix);
|
||||
// Need to update all internal project dependencies using the same rule
|
||||
updateAllDepVersions(removeBetaSuffix, depNames);
|
||||
}
|
||||
|
||||
const removeBetaSuffix = (currentVersion) => {
|
||||
return currentVersion.split('-beta')[0];
|
||||
}
|
||||
|
||||
main();
|
Загрузка…
Ссылка в новой задаче