Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions .github/example/draft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: "Draft Release"
on:
workflow_dispatch:
push:
branches: ["master"]
branches: [main, master]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -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
uses: cssnr/draft-release-action@notes
with:
semver: patch
prerelease: false
prefix: v
previous_tag_name: ${{ steps.tag.outputs.name }}
notes_prefix: "${{ github.ref_name }}-" # TODO: prefix - release.yaml

- name: "Process Release Draft URL"
run: |
Expand Down
19 changes: 19 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -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 |
27 changes: 14 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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.

<details><summary>👀 View Example Job Summary</summary>

Expand Down
7 changes: 5 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -30,9 +31,11 @@ inputs:
default: ${{ github.token }}
previous_tag_name:
description: "Previous Tag or SHA for Comparison"
notes_prefix:
description: "Prefix for Release Notes Tag"
notes_strip_prefix:
description: "Strip Prefix from Release Notes Tag"
default: "false"
description: "Does Nothing - Backwards Compatibility Only"
deprecationMessage: "Removed! Use - notes_prefix"

outputs:
release:
Expand Down
10 changes: 7 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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() {
Expand All @@ -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'),
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 ."
},
Expand Down
10 changes: 7 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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() {
Expand All @@ -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'),
}
}