Skip to content

Commit

Permalink
chore: ensure shebang, clean stuff (#1342)
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-bompart authored Oct 26, 2023
1 parent 5cf7cfd commit af90f95
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 69 deletions.
Empty file removed .git-lock
Empty file.
6 changes: 4 additions & 2 deletions utils/release/create-github-release.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env node

import {readFileSync} from 'node:fs';
import {Octokit} from 'octokit';
import {createAppAuth} from '@octokit/auth-app';
Expand All @@ -15,7 +17,7 @@ const getCliChangelog = () => {
const lastVersionChanges = changelog.split(versionH1Matcher)[1];
return lastVersionChanges.trim();
};
async () => {
(async () => {
//#region GitHub authentication
const authSecrets = {
appId: process.env.RELEASER_APP_ID,
Expand Down Expand Up @@ -51,4 +53,4 @@ async () => {
body: releaseBody,
});
exportVariable('tag', cliLatestTag);
};
})();
132 changes: 65 additions & 67 deletions utils/release/git-publish-all.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -36,64 +36,63 @@ const REPO_NAME = 'cli';
const GIT_SSH_REMOTE = 'deploy';

// Commit, tag and push
(async () => {
const PATH = '.';

//#region GitHub authentication
const authSecrets = {
appId: process.env.RELEASER_APP_ID,
privateKey: process.env.RELEASER_PRIVATE_KEY,
clientId: process.env.RELEASER_CLIENT_ID,
clientSecret: process.env.RELEASER_CLIENT_SECRET,
installationId: process.env.RELEASER_INSTALLATION_ID,
};

const octokit = new Octokit({
authStrategy: createAppAuth,
auth: authSecrets,
});
//#endregion

// Define release # andversion
const currentVersionTag = getCurrentVersion(PATH);
currentVersionTag.inc('prerelease');
const npmNewVersion = currentVersionTag.format();
// Write release version in the root package.json
await npmBumpVersion(npmNewVersion, PATH);

const releaseNumber = currentVersionTag.prerelease[0];
const gitNewTag = `release-${releaseNumber}`;

// Find all changes since last release and generate the changelog.
const versionPrefix = 'release-';
const lastTag = await getLastTag(versionPrefix);
const commits = await getCommits(PATH, lastTag);
const convention = await angularChangelogConvention;

let changelog = '';
if (commits.length > 0) {
const parsedCommits = parseCommits(commits, convention.parserOpts);
changelog = await generateChangelog(
parsedCommits,
gitNewTag,
{
host: 'https://github.com',
owner: REPO_OWNER,
repository: REPO_NAME,
},
convention.writerOpts
);
await writeChangelog(PATH, changelog);
}
updateRootReadme();
const PATH = '.';

//#region GitHub authentication
const authSecrets = {
appId: process.env.RELEASER_APP_ID,
privateKey: process.env.RELEASER_PRIVATE_KEY,
clientId: process.env.RELEASER_CLIENT_ID,
clientSecret: process.env.RELEASER_CLIENT_SECRET,
installationId: process.env.RELEASER_INSTALLATION_ID,
};

const octokit = new Octokit({
authStrategy: createAppAuth,
auth: authSecrets,
});
//#endregion

// Define release # andversion
const currentVersionTag = getCurrentVersion(PATH);
currentVersionTag.inc('prerelease');
const npmNewVersion = currentVersionTag.format();
// Write release version in the root package.json
await npmBumpVersion(npmNewVersion, PATH);

const releaseNumber = currentVersionTag.prerelease[0];
const gitNewTag = `release-${releaseNumber}`;

// Find all changes since last release and generate the changelog.
const versionPrefix = 'release-';
const lastTag = await getLastTag(versionPrefix);
const commits = await getCommits(PATH, lastTag);
const convention = await angularChangelogConvention;

let changelog = '';
if (commits.length > 0) {
const parsedCommits = parseCommits(commits, convention.parserOpts);
changelog = await generateChangelog(
parsedCommits,
gitNewTag,
{
host: 'https://github.com',
owner: REPO_OWNER,
repository: REPO_NAME,
},
convention.writerOpts
);
await writeChangelog(PATH, changelog);
}
updateRootReadme();

// Find all packages that have been released in this release.
const packagesReleased = readFileSync('.git-message', {
encoding: 'utf-8',
}).trim();
// Find all packages that have been released in this release.
const packagesReleased = readFileSync('.git-message', {
encoding: 'utf-8',
}).trim();

// Compile git commit message
const commitMessage = dedent`
// Compile git commit message
const commitMessage = dedent`
[version bump] chore(release): release ${gitNewTag} [skip ci]
${packagesReleased}
Expand All @@ -108,20 +107,19 @@ const GIT_SSH_REMOTE = 'deploy';
packages/ui/cra-template/template.json
`;

// Craft the commit (complex process, see function)
const commit = await commitChanges(releaseNumber, commitMessage, octokit);
// Craft the commit (complex process, see function)
const commit = await commitChanges(releaseNumber, commitMessage, octokit);

// Add the tags locally...
for (const tag of packagesReleased.split('\n').concat(gitNewTag)) {
await gitTag(tag, commit);
}
// Add the tags locally...
for (const tag of packagesReleased.split('\n').concat(gitNewTag)) {
await gitTag(tag, commit);
}

// And push them
await gitPushTags();
// And push them
await gitPushTags();

// Unlock the main branch
await removeWriteAccessRestrictions();
})();
// Unlock the main branch
await removeWriteAccessRestrictions();

/**
* "Craft" the signed release commit.
Expand Down
2 changes: 2 additions & 0 deletions utils/release/is-cli-release.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env node

import {readFileSync} from 'node:fs';
import {setOutput} from '@actions/core';

Expand Down

0 comments on commit af90f95

Please sign in to comment.