diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a27591..8273b2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +## [v1.2.0] - 2024-02-23 + +### Added + +* Added the ability to define the format of the release title and tag. + ## [v1.1.1] - 2024-02-23 ### Fixed diff --git a/README.md b/README.md index 5d6cd9a..d65e03f 100644 --- a/README.md +++ b/README.md @@ -29,17 +29,53 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Release a Changelog - uses: rasmus-saks/release-a-changelog-action@v1.1.0 + uses: rasmus-saks/release-a-changelog-action@v1.2.0 with: github-token: '${{ secrets.GITHUB_TOKEN }}' # Optional - path to your changelog file. Defaults to 'CHANGELOG.md' path: 'path/to/my/CHANGELOG.md' + # Optional - format of the release title. Defaults to '{version}' + title-template: 'My Project {version}' + # Optional - format of the release tag. Defaults to '{version}' + tag-template: 'my-project-{version}' ``` > :warning: Make sure you have a `checkout` action before `release-a-changelog`, otherwise it won't be able to read your `CHANGELOG.md` file +## Multi-project setup + +Use the `title-template` and `tag-template` inputs to define the format of the release title and tag for each separate project in your repository. +Use `{version}` as a placeholder for the version number. + +> :warning: Make sure the `tag-template` is unique for each project in the repository, otherwise releases may clash with each other. + +```yaml +name: Release a Changelog + +on: + push: + branches: + - master + +jobs: + release_a_changelog: + name: Release a Changelog + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Release a Changelog + uses: rasmus-saks/release-a-changelog-action@v1.2.0 + with: + github-token: '${{ secrets.GITHUB_TOKEN }}' + path: 'my-sub-project/CHANGELOG.md' + title-template: 'My Sub Project {version}' + tag-template: 'my-sub-project-{version}' +``` + + # Usage 1. Add a new version to `CHANGELOG.md` according to [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) 2. Push/merge to master diff --git a/action.yml b/action.yml index 64ab6cf..731f184 100644 --- a/action.yml +++ b/action.yml @@ -17,3 +17,11 @@ inputs: description: "Path to the changelog file" required: false default: "CHANGELOG.md" + title-template: + description: "Template for the release title. {version} is replaced with the version from the changelog" + required: false + default: "{version}" + tag-template: + description: "Template for the release tag. {version} is replaced with the version from the changelog" + required: false + default: "{version}" diff --git a/index.js b/index.js index 9935fba..cacb6e5 100644 --- a/index.js +++ b/index.js @@ -8,6 +8,8 @@ async function run() { const octokit = github.getOctokit(core.getInput("github-token", { required: true })); const changelogFile = core.getInput("path") const entry = getLatestChangelogEntry(changelogFile) + const releaseTitle = core.getInput("title-template").replaceAll("{version}", entry.version) + const releaseTag = core.getInput("tag-template").replaceAll("{version}", entry.version) if (!entry) { console.log(`Could not find the latest release from ${changelogFile}`) return @@ -16,15 +18,15 @@ async function run() { try { await octokit.rest.repos.getReleaseByTag({ ...github.context.repo, - tag: entry.version + tag: releaseTag }) - console.log(`A release already exists for ${entry.version}, skipping`) + console.log(`A release already exists for ${releaseTag}, skipping`) } catch (error) { - console.log(`Could not find a GitHub release for ${entry.version}, creating one`) + console.log(`Could not find a GitHub release for ${releaseTag}, creating one`) octokit.rest.repos.createRelease({ ...github.context.repo, - tag_name: entry.version, - name: entry.version, + tag_name: releaseTag, + name: releaseTitle, target_commitish: github.context.sha, body: entry.changelog, draft: false, diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json index c3d80e5..2df7f44 100644 --- a/node_modules/.package-lock.json +++ b/node_modules/.package-lock.json @@ -1,6 +1,6 @@ { "name": "release-a-changelog-action", - "version": "1.1.0", + "version": "1.2.0", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/package-lock.json b/package-lock.json index d98893e..b20f522 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "release-a-changelog-action", - "version": "1.1.0", + "version": "1.2.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "release-a-changelog-action", - "version": "1.1.0", + "version": "1.2.0", "license": "ISC", "dependencies": { "@actions/core": "^1.10.1", diff --git a/package.json b/package.json index 1997dd1..d135372 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "release-a-changelog-action", - "version": "1.1.0", + "version": "1.2.0", "description": "", "main": "index.js", "scripts": {