Merge pull request #9312 from backstage/rugvip/release-dispatch
scripts/create-release-tag: dispatch release workflows
This commit is contained in:
@@ -205,7 +205,7 @@ jobs:
|
||||
# Grabs the version in the root package.json and creates a tag on GitHub
|
||||
- name: Create a release tag
|
||||
id: create_tag
|
||||
run: node scripts/create-release-tag.js
|
||||
run: node scripts/create-release-tag.js --dispatch-workflows
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GH_SERVICE_ACCOUNT_TOKEN }}
|
||||
|
||||
|
||||
@@ -48,3 +48,31 @@ jobs:
|
||||
git add .
|
||||
git commit -am "${{ github.event.inputs.version }}"
|
||||
git push
|
||||
|
||||
- name: Dispatch update-helper update
|
||||
uses: actions/github-script@v5
|
||||
with:
|
||||
github-token: ${{ secrets.GH_SERVICE_ACCOUNT_TOKEN }}
|
||||
# TODO(Rugvip): Remove the create-app dispatch once we've been on the release version for a while
|
||||
script: |
|
||||
console.log('Dispatching upgrade helper sync - release version');
|
||||
await octokit.actions.createWorkflowDispatch({
|
||||
owner: 'backstage',
|
||||
repo: 'upgrade-helper-diff',
|
||||
workflow_id: 'release.yml',
|
||||
ref: 'master',
|
||||
inputs: {
|
||||
version: require('./package.json').version,
|
||||
},
|
||||
});
|
||||
|
||||
console.log('Dispatching upgrade helper sync - create-app version');
|
||||
await octokit.actions.createWorkflowDispatch({
|
||||
owner: 'backstage',
|
||||
repo: 'upgrade-helper-diff',
|
||||
workflow_id: 'release.yml',
|
||||
ref: 'master',
|
||||
inputs: {
|
||||
version: require('./packages/create-app/package.json').version,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -25,31 +25,17 @@ const baseOptions = {
|
||||
repo: 'backstage',
|
||||
};
|
||||
|
||||
async function main() {
|
||||
const { GITHUB_SHA, GITHUB_TOKEN } = process.env;
|
||||
if (!GITHUB_SHA) {
|
||||
throw new Error('GITHUB_SHA is not set');
|
||||
}
|
||||
if (!GITHUB_TOKEN) {
|
||||
throw new Error('GITHUB_TOKEN is not set');
|
||||
}
|
||||
|
||||
const octokit = new Octokit({ auth: GITHUB_TOKEN });
|
||||
|
||||
const rootPath = path.resolve(__dirname, '..');
|
||||
const { version: currentVersion } = await fs.readJson(
|
||||
path.join(rootPath, 'package.json'),
|
||||
);
|
||||
|
||||
const tagName = `v${currentVersion}`;
|
||||
|
||||
console.log(`Creating release tag ${tagName}`);
|
||||
async function getCurrentReleaseTag() {
|
||||
const rootPath = path.resolve(__dirname, '../package.json');
|
||||
return fs.readJson(rootPath).then(_ => _.version);
|
||||
}
|
||||
|
||||
async function createGitTag(octokit, commitSha, tagName) {
|
||||
const annotatedTag = await octokit.git.createTag({
|
||||
...baseOptions,
|
||||
tag: tagName,
|
||||
message: tagName,
|
||||
object: GITHUB_SHA,
|
||||
object: commitSha,
|
||||
type: 'commit',
|
||||
});
|
||||
|
||||
@@ -69,8 +55,46 @@ async function main() {
|
||||
console.error(`Tag creation for ${tagName} failed`);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
async function dispatchReleaseWorkflows(octokit, releaseVersion) {
|
||||
console.log('Dispatching release manifest sync');
|
||||
await octokit.actions.createWorkflowDispatch({
|
||||
owner: 'backstage',
|
||||
repo: 'backstage',
|
||||
workflow_id: 'sync_release-manifest.yml',
|
||||
ref: 'master',
|
||||
inputs: {
|
||||
version: releaseVersion,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const shouldDispatch = process.argv.includes('--dispatch-workflows');
|
||||
|
||||
if (!process.env.GITHUB_SHA) {
|
||||
throw new Error('GITHUB_SHA is not set');
|
||||
}
|
||||
if (!process.env.GITHUB_TOKEN) {
|
||||
throw new Error('GITHUB_TOKEN is not set');
|
||||
}
|
||||
|
||||
const commitSha = process.env.GITHUB_SHA;
|
||||
const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN });
|
||||
|
||||
const releaseVersion = await getCurrentReleaseTag();
|
||||
const tagName = `v${releaseVersion}`;
|
||||
|
||||
console.log(`Creating release tag ${tagName} at ${commitSha}`);
|
||||
await createGitTag(octokit, commitSha, tagName);
|
||||
|
||||
console.log(`::set-output name=tag_name::${tagName}`);
|
||||
|
||||
if (shouldDispatch) {
|
||||
console.log(`Dispatching release workflows for ${tagName}`);
|
||||
await dispatchReleaseWorkflows(octokit, releaseVersion);
|
||||
}
|
||||
}
|
||||
|
||||
main().catch(error => {
|
||||
|
||||
Reference in New Issue
Block a user