Skip to content

Commit

Permalink
Add release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ddbeck committed Nov 7, 2024
1 parent ab65b20 commit b8a87aa
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 4 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/prepare_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Prepare a web-features release

on:
workflow_dispatch:
inputs:
semverLevel:
description: "Bump to semver level"
required: true
type: choice
default: "minor"
options:
- patch
- minor
- major

jobs:
open_pr:
name: Open PR
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
git config user.name github-actions
git config user.email github-actions@github.com
- uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: npm
- run: npm ci
- name: ./scripts/release.ts init
run: npx tsx ./scripts/release.ts init --target-repo=$REPO --reviewer=$ACTOR $SEMVER_LEVEL
env:
ACTOR: ${{ github.actor }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
SEMVER_LEVEL: ${{ inputs.semverLevel }}
2 changes: 1 addition & 1 deletion scripts/release-pull-description.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
⚠ Caution! Merging this PR triggers a release. Continue reading before merging. ⚠
This is a generated release pull request. Don't merge if you're not ready to carry out the release.
11 changes: 8 additions & 3 deletions scripts/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,18 @@ yargs(process.argv.slice(2))
choices: semverChoices,
default: "patch",
})
.option("reviewers", {
describe: "Comma-separated list of users to request reviews from",
nargs: 1,
})
.demandOption("semverlevel", "You must provide a semver level");
},
handler: init,
}).argv;

function init(args) {
logger.debug(JSON.stringify(args));

preflight({ expectedBranch: "main" });

const diff = diffJson();
Expand Down Expand Up @@ -98,13 +104,13 @@ function init(args) {
// Create PR
const title = [pullTitleBase, newVersion].join("");
logger.info(`Creating PR: ${title}`);
const reviewer = "ddbeck";
const reviewers = args.reviewers.split(",");
const body = makePullBody(diff);

const pullRequestCmd = [
"gh pr create",
`--title="${title}"`,
`--reviewer="${reviewer}"`,
...reviewers.map((r) => `--reviewer=${r}`),
`--body-file=-`,
`--base="main"`,
`--head="${releaseBranch}"`,
Expand Down Expand Up @@ -139,7 +145,6 @@ function makePullBody(diff: string) {
const body = [
readFileSync(bodyFile, { encoding: "utf-8" }),
"```diff",
diff,
"```",
].join("\n");
return body;
Expand Down

0 comments on commit b8a87aa

Please sign in to comment.