Skip to content

Commit

Permalink
Release tools: mark v43.0.0 as latest on GitHub after publishing a ne…
Browse files Browse the repository at this point in the history
…w release.
  • Loading branch information
pomek committed Oct 22, 2024
1 parent 2526d91 commit a954a55
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 12 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@ckeditor/ckeditor5-dev-bump-year": "^44.2.1",
"@inquirer/prompts": "^6.0.0",
"@listr2/prompt-adapter-inquirer": "^2.0.16",
"@octokit/rest": "^21.0.0",
"eslint": "^8.21.0",
"eslint-config-ckeditor5": "^8.0.0",
"fs-extra": "^11.0.0",
Expand Down
43 changes: 31 additions & 12 deletions scripts/publishpackages.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import { Listr } from 'listr2';
import { ListrInquirerPromptAdapter } from '@listr2/prompt-adapter-inquirer';
import { confirm } from '@inquirer/prompts';
import { Octokit } from '@octokit/rest';
import * as releaseTools from '@ckeditor/ckeditor5-dev-release-tools';
import parseArguments from './utils/parsearguments.js';
import getListrOptions from './utils/getlistroptions.js';
Expand All @@ -19,7 +20,7 @@ const cliArguments = parseArguments( process.argv.slice( 2 ) );
const latestVersion = releaseTools.getLastFromChangelog();
const versionChangelog = releaseTools.getChangesForVersion( latestVersion );

let githubToken;
const githubToken = await getGitHubToken();

if ( !cliArguments.npmTag ) {
cliArguments.npmTag = releaseTools.getNpmTagFromVersion( latestVersion );
Expand Down Expand Up @@ -68,21 +69,39 @@ const tasks = new Listr( [
options: {
persistentOutput: true
}
}
], getListrOptions( cliArguments ) );
},
{
title: 'Mark v43.0.0 as "latest" (GitHub)',
task: async () => {
const github = new Octokit( {
version: '3.0.0',
auth: `token ${ githubToken }`
} );

( async () => {
try {
if ( process.env.CKE5_RELEASE_TOKEN ) {
githubToken = process.env.CKE5_RELEASE_TOKEN;
} else {
githubToken = await releaseTools.provideToken();
return github.request( 'PATCH /repos/{owner}/{repo}/releases/{release_id}', {
owner: 'ckeditor',
repo: 'ckeditor5-dev',
release_id: 174058828, // v43.0.0
make_latest: true
} );
}
}
], getListrOptions( cliArguments ) );

await tasks.run();
} catch ( err ) {
tasks.run()
.catch( err => {
process.exitCode = 1;

console.error( err );
} );

/**
* @returns {Promise.<string>}
*/
async function getGitHubToken() {
if ( process.env.CKE5_RELEASE_TOKEN ) {
return process.env.CKE5_RELEASE_TOKEN;
}
} )();

return releaseTools.provideToken();
}

0 comments on commit a954a55

Please sign in to comment.