From b5a8eacae91793e7776945097c27283c53ed52a7 Mon Sep 17 00:00:00 2001 From: Shane <6071159+smashedr@users.noreply.github.com> Date: Thu, 11 Jun 2026 20:57:25 -0700 Subject: [PATCH 1/3] Update Notes Prefix --- .github/example/draft.yaml | 18 +++++++++++++++++- AGENTS.md | 19 +++++++++++++++++++ README.md | 27 ++++++++++++++------------- action.yml | 5 ++--- dist/index.js | 10 +++++++--- package.json | 1 + src/index.js | 10 +++++++--- 7 files changed, 67 insertions(+), 23 deletions(-) create mode 100644 AGENTS.md diff --git a/.github/example/draft.yaml b/.github/example/draft.yaml index 3a1b7ba..bd77c51 100644 --- a/.github/example/draft.yaml +++ b/.github/example/draft.yaml @@ -3,7 +3,7 @@ name: "Draft Release" on: workflow_dispatch: push: - branches: ["master"] + branches: [main, master] concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -14,16 +14,32 @@ jobs: name: "Draft Release" runs-on: ubuntu-latest timeout-minutes: 5 + permissions: contents: write steps: - name: "Checkout" uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: "Get Previous Tag" + id: tag + run: | + TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") + echo "TAG: ${TAG}" + echo "name=${TAG}" >> "${GITHUB_OUTPUT}" - name: "Draft Release Action" id: draft uses: cssnr/draft-release-action@master + with: + semver: patch + prerelease: false + prefix: v + previous_tag_name: ${{ steps.tag.outputs.name }} + notes_prefix: "master-" - name: "Process Release Draft URL" run: | diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..cb8455e --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,19 @@ +# Agent Guide + +Before answering any question that involves facts about ANYTHING, you MUST output at least one Read, WebFetch, or WebSearch tool call. +If your first output is text instead of a tool call, you have failed. + +GitHub Action - [action.yml](action.yml) + +- `src/` is the source directory (single `index.ts` file) +- `dist/` is built by rollup, in `.gitignore`, and pushed to the `release` branch on publish + +## Commands + +ALWAYS use the `npm run *` command + +| Command | Purpose | +| ------------------ | --------------------------------------- | +| `npm run build` | Rollup `src/index.ts` → `dist/index.js` | +| `npm run lint` | ESLint on `src/` | +| `npm run prettier` | ALWAYS RUN AFTER EDITING FILES | diff --git a/README.md b/README.md index 3ee83d8..a9cad16 100644 --- a/README.md +++ b/README.md @@ -35,16 +35,16 @@ Want to see more feature? [Request one](https://github.com/cssnr/draft-release-a ## Inputs -| Input | Req. | Default Value | Input Description | -| :----------------- | :--: | :----------------- | :---------------------------------- | -| semver | - | `prerelease` | Semantaic Version to Incriment | -| identifier | - | `beta` | Prerelease Tag to Append | -| prerelease | - | `true` | Set Draft as Prerelease | -| prefix | - | - | Release Tag Prefix | -| previous_tag_name | - | - | Previous Tag or SHA for Comparison | -| notes_strip_prefix | - | - | Strip Prefix from Release Notes Tag | -| summary | - | `true` | Add Job Summary to Workflow | -| token | - | `github.token` | Only for Use with a PAT | +| Input | Req. | Default Value | Input Description | +| :---------------- | :--: | :----------------- | :--------------------------------- | +| semver | - | `prerelease` | Semantaic Version to Incriment | +| identifier | - | `beta` | Prerelease Tag to Append | +| prerelease | - | `true` | Set Draft as Prerelease | +| prefix | - | - | Release Tag Prefix | +| previous_tag_name | - | - | Previous Tag or SHA for Comparison | +| notes_prefix | - | - | Prefix for Release Notes Tag | +| summary | - | `true` | Add Job Summary to Workflow | +| token | - | `github.token` | Only for Use with a PAT | **semver:** This is the string passed to `semver.inc()` to determine which version to increment. For more details, see the [docs](https://github.com/npm/node-semver?tab=readme-ov-file#functions). @@ -54,9 +54,10 @@ This can be a tag name or a commit SHA. Use this if your release tag was moved a (e.g., by a force-push to a release branch) and the auto-detected tag name no longer produces correct release notes. Defaults to the latest release tag name. -**notes_strip_prefix:** Strip the prefix from the tag name when generating release notes. -When enabled, the prefix (e.g. `v`) is removed from the tag name before passing it to -`generateReleaseNotes`, so the notes reference the version number without the prefix. +**notes_prefix:** Override the prefix used for the tag name when generating release notes. +When set, the prefix is prepended to the version number before passing to `generateReleaseNotes`. +For example, if your release tag is `master-1.0.6` and you set `notes_prefix: ''`, the notes will +reference `1.0.6` instead of `master-1.0.6`. If unset, the full release tag name is used.
👀 View Example Job Summary diff --git a/action.yml b/action.yml index a95e1dc..fd7877b 100644 --- a/action.yml +++ b/action.yml @@ -30,9 +30,8 @@ inputs: default: ${{ github.token }} previous_tag_name: description: "Previous Tag or SHA for Comparison" - notes_strip_prefix: - description: "Strip Prefix from Release Notes Tag" - default: "false" + notes_prefix: + description: "Prefix for Release Notes Tag" outputs: release: diff --git a/dist/index.js b/dist/index.js index 68f2c3b..609e2cd 100644 --- a/dist/index.js +++ b/dist/index.js @@ -36405,7 +36405,11 @@ async function processRelease(inputs) { const tag_name = `${inputs.prefix}${new_name}`; console.log('tag_name:', tag_name); - const notes_tag_name = inputs.notes_strip_prefix ? new_name : tag_name; + const notes_tag_name = inputs.notes_prefix + ? `${inputs.notes_prefix}${new_name}` + : tag_name; + console.log('notes_tag_name:', notes_tag_name); + const notes = await octokit.rest.repos.generateReleaseNotes({ ...context.repo, tag_name: notes_tag_name, @@ -36468,7 +36472,7 @@ async function addSummary(inputs, response) { * @property {boolean} summary * @property {string} token * @property {string} previous_tag_name - * @property {boolean} notes_strip_prefix + * @property {string} notes_prefix * @return {Inputs} */ function getInputs() { @@ -36480,6 +36484,6 @@ function getInputs() { summary: getBooleanInput('summary'), token: getInput('token', { required: true }), previous_tag_name: getInput('previous_tag_name'), - notes_strip_prefix: getBooleanInput('notes_strip_prefix'), + notes_prefix: getInput('notes_prefix'), } } diff --git a/package.json b/package.json index e5d9436..9d9727d 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "build:watch": "npm run build -- --watch", "lint": "npx eslint src", "lint:report": "npm run lint -- --output-file eslint_report.json --format json", + "prettier": "npm run prettier:write", "prettier:check": "npx prettier --check .", "prettier:write": "npx prettier --write ." }, diff --git a/src/index.js b/src/index.js index dc335c6..d766ae1 100644 --- a/src/index.js +++ b/src/index.js @@ -107,7 +107,11 @@ async function processRelease(inputs) { const tag_name = `${inputs.prefix}${new_name}` console.log('tag_name:', tag_name) - const notes_tag_name = inputs.notes_strip_prefix ? new_name : tag_name + const notes_tag_name = inputs.notes_prefix + ? `${inputs.notes_prefix}${new_name}` + : tag_name + console.log('notes_tag_name:', notes_tag_name) + const notes = await octokit.rest.repos.generateReleaseNotes({ ...github.context.repo, tag_name: notes_tag_name, @@ -170,7 +174,7 @@ async function addSummary(inputs, response) { * @property {boolean} summary * @property {string} token * @property {string} previous_tag_name - * @property {boolean} notes_strip_prefix + * @property {string} notes_prefix * @return {Inputs} */ function getInputs() { @@ -182,6 +186,6 @@ function getInputs() { summary: core.getBooleanInput('summary'), token: core.getInput('token', { required: true }), previous_tag_name: core.getInput('previous_tag_name'), - notes_strip_prefix: core.getBooleanInput('notes_strip_prefix'), + notes_prefix: core.getInput('notes_prefix'), } } From 5dd11a5531d5e68dcf9a9cc58b5422c357dd50ae Mon Sep 17 00:00:00 2001 From: Shane <6071159+smashedr@users.noreply.github.com> Date: Thu, 11 Jun 2026 21:34:13 -0700 Subject: [PATCH 2/3] Update Notes Prefix --- action.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/action.yml b/action.yml index fd7877b..23c3507 100644 --- a/action.yml +++ b/action.yml @@ -1,3 +1,4 @@ +# https://www.schemastore.org/github-action.json name: "Draft Release Action" description: "Automatically Draft Releases with Semantic Version Tags" author: "Shane" @@ -32,6 +33,9 @@ inputs: description: "Previous Tag or SHA for Comparison" notes_prefix: description: "Prefix for Release Notes Tag" + notes_strip_prefix: + description: "Does Nothing - Backwards Compatibility Only" + deprecationMessage: "Removed! Use - notes_prefix" outputs: release: From b28cd0d8bd4001f9885410eed79f28ef0fcb07fb Mon Sep 17 00:00:00 2001 From: Shane <6071159+smashedr@users.noreply.github.com> Date: Thu, 11 Jun 2026 21:36:14 -0700 Subject: [PATCH 3/3] Update Notes Prefix --- .github/example/draft.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/example/draft.yaml b/.github/example/draft.yaml index bd77c51..3c4a617 100644 --- a/.github/example/draft.yaml +++ b/.github/example/draft.yaml @@ -33,13 +33,13 @@ jobs: - name: "Draft Release Action" id: draft - uses: cssnr/draft-release-action@master + uses: cssnr/draft-release-action@notes with: semver: patch prerelease: false prefix: v previous_tag_name: ${{ steps.tag.outputs.name }} - notes_prefix: "master-" + notes_prefix: "${{ github.ref_name }}-" # TODO: prefix - release.yaml - name: "Process Release Draft URL" run: |