@@ -0,0 +1,53 @@
|
||||
# `dist/index.js` is a special file in Actions.
|
||||
# When you reference an action with `uses:` in a workflow,
|
||||
# `index.js` is the code that will run.
|
||||
# For our project, we generate this file through a build process from other source files.
|
||||
# We need to make sure the checked-in `index.js` actually matches what we expect it to be.
|
||||
name: Check dist
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
check-dist:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Set Node.js 16.x
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16.x
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Rebuild the dist/ directory
|
||||
run: |
|
||||
npm run build
|
||||
npm run package
|
||||
|
||||
- name: Compare the expected and actual dist/ directories
|
||||
run: |
|
||||
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
|
||||
echo "Detected uncommitted changes after build. See status below:"
|
||||
git diff
|
||||
exit 1
|
||||
fi
|
||||
id: diff
|
||||
|
||||
# If index.js was different than expected, upload the expected version as an artifact
|
||||
- uses: actions/upload-artifact@v3
|
||||
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
|
||||
with:
|
||||
name: dist
|
||||
path: dist/
|
||||
@@ -11,13 +11,17 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v2
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set Node.js 16.x
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '16'
|
||||
node-version: 16.x
|
||||
|
||||
- name: Install NPM
|
||||
run: |
|
||||
npm install
|
||||
|
||||
- name: Run NPM
|
||||
run: |
|
||||
npm run all
|
||||
|
||||
@@ -43,7 +43,7 @@ jobs:
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
uses: github/codeql-action/init@v2
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
@@ -54,7 +54,7 @@ jobs:
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v1
|
||||
uses: github/codeql-action/autobuild@v2
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
@@ -68,4 +68,4 @@ jobs:
|
||||
# make release
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
||||
uses: github/codeql-action/analyze@v2
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
</p>
|
||||
|
||||
<div align="center">
|
||||
<img src=".github/images/release_changelog_builder_collapsed.png"/>
|
||||
<img src="https://raw.githubusercontent.com/mikepenz/release-changelog-builder-action/develop/.github/images/release_changelog_builder_collapsed.png"/>
|
||||
</div>
|
||||
|
||||
<div align="center">
|
||||
@@ -116,26 +116,22 @@ jobs:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Create Release
|
||||
uses: actions/create-release@v3
|
||||
uses: softprops/action-gh-release@v0.1.14
|
||||
with:
|
||||
tag_name: ${{ github.ref }}
|
||||
release_name: ${{ github.ref }}
|
||||
body: ${{steps.github_release.outputs.changelog}}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
```
|
||||
|
||||
## Customization 🖍️
|
||||
|
||||
### Note
|
||||
|
||||
⚠️ When running this action for non tags trigger the `toTag` will be automatically resolved using the latest tag as retrieved by the git API.
|
||||
> **Warning**: When running this action for non tags trigger the `toTag` will be automatically resolved using the latest tag as retrieved by the git API.
|
||||
|
||||
⚠️ The first release tag is a special case since there is no previous release the action can reference to. For this case, there are 2 options:
|
||||
1. When checking out the source via `git` (E.g.: `actions/checkout`), the action will use the first commit.
|
||||
2. Create a initial tag on the commit you want to begin a changelog from (for example `v0.0.1`).
|
||||
> **Note**: The first release tag is a special case since there is no previous release the action can reference to. For this case, there are 2 options:
|
||||
> 1. When checking out the source via `git` (E.g.: `actions/checkout`), the action will use the first commit.
|
||||
> 2. Create a initial tag on the commit you want to begin a changelog from (for example `v0.0.1`).
|
||||
|
||||
💡 By default not specifying `fromTag` or `toTag` will resolve `toTag` from either the `ref` or alternatively fallback to the latest tag from the git API. `fromTag` is resolved by sorting tags using [semver](https://semver.org/). Check the [configuration](#configuration-specification) for alternatives.
|
||||
> **Note**: By default not specifying `fromTag` or `toTag` will resolve `toTag` from either the `ref` or alternatively fallback to the latest tag from the git API. `fromTag` is resolved by sorting tags using [semver](https://semver.org/). Check the [configuration](#configuration-specification) for alternatives.
|
||||
|
||||
### Configuration
|
||||
|
||||
@@ -150,7 +146,7 @@ The action supports flexible configuration options to modify vast areas of its b
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
```
|
||||
|
||||
⚠️ Please note: It is required to have a `checkout` step prior to the changelog step, to allow the action to discover the configuration file.
|
||||
> **Warning** It is required to have a `checkout` step prior to the changelog step, to allow the action to discover the configuration file.
|
||||
|
||||
This configuration is a `.json` file in the following format.
|
||||
|
||||
@@ -167,13 +163,14 @@ This configuration is a `.json` file in the following format.
|
||||
},
|
||||
{
|
||||
"title": "## 🧪 Tests",
|
||||
"labels": ["test"],
|
||||
"labels": ["test"]
|
||||
},
|
||||
{
|
||||
"title": "## 🧪 Tests and some 🪄 Magic",
|
||||
"labels": ["test", "magic"],
|
||||
"exclude_labels": ["no-magic"],
|
||||
"exhaustive": true,
|
||||
"empty_content": "- no matching PRs"
|
||||
}
|
||||
],
|
||||
"ignore_labels": [
|
||||
@@ -230,7 +227,7 @@ This configuration is a `.json` file in the following format.
|
||||
|
||||
Any section of the configuration can be omitted to have defaults apply.
|
||||
|
||||
💡 `ignore_labels` take precedence over category labels, allowing to specifically exclude certain PRs.
|
||||
> **Warning**: `ignore_labels` take precedence over category labels, allowing to specifically exclude certain PRs.
|
||||
|
||||
Defaults for the configuration can be found in the [configuration.ts](https://github.com/mikepenz/release-changelog-builder-action/blob/develop/src/configuration.ts)
|
||||
|
||||
@@ -255,7 +252,7 @@ For advanced use cases additional settings can be provided to the action
|
||||
token: ${{ secrets.PAT }}
|
||||
```
|
||||
|
||||
💡 All input values are optional. It is only required to provide the `token` either via the input, or as `env` variable.
|
||||
> **Note**: All input values are optional. It is only required to provide the `token` either via the input, or as `env` variable.
|
||||
|
||||
| **Input** | **Description** |
|
||||
|-------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
@@ -274,7 +271,7 @@ For advanced use cases additional settings can be provided to the action
|
||||
| `fetchReviewers` | Will enable fetching the users/reviewers who approved the PR. Default: false |
|
||||
| `commitMode` | Special configuration for projects which work without PRs. Uses commit messages as changelog. This mode looses access to information only available for PRs. Default: false |
|
||||
|
||||
💡 `${{ secrets.GITHUB_TOKEN }}` only grants rights to the current repository, for other repositories please use a PAT (Personal Access Token).
|
||||
> **Warning**: `${{ secrets.GITHUB_TOKEN }}` only grants rights to the current repository, for other repositories please use a PAT (Personal Access Token).
|
||||
|
||||
### PR Template placeholders
|
||||
|
||||
@@ -329,6 +326,7 @@ Table of descriptions for the `configuration.json` options to configure the resu
|
||||
| category.labels | An array of labels, to match pull request labels against. If any PR label matches any category label, the pull request will show up under this category. |
|
||||
| category.exclude_labels | Similar to `labels`, an array of labels to match PRs against, but if a match occurs the PR is excluded from this category. |
|
||||
| category.exhaustive | Will require all labels defined within this category to be present on the matching PR. |
|
||||
| category.empty_content | If the category has no matching PRs, this content will be used. When not set, the category will be skipped in the changelog. |
|
||||
| ignore_labels | An array of labels, to match pull request labels against. If any PR label overlaps, the pull request will be ignored from the changelog. This takes precedence over category labels |
|
||||
| sort | A `sort` specification, offering the ability to define sort order and property. |
|
||||
| sort.order | The sort order. Allowed values: `ASC`, `DESC` |
|
||||
@@ -423,9 +421,9 @@ All patches and changes applied to the original source are licensed under the Ap
|
||||
## Sample result release notes / changelog
|
||||
|
||||
<div align="center">
|
||||
<a href="https://github.com/mikepenz/release-changelog-builder-action/runs/1270879787"><img src=".github/images/release_changelog_builder_expanded.png"/></a>
|
||||
<a href="https://github.com/mikepenz/release-changelog-builder-action/runs/1270879787"><img src="https://raw.githubusercontent.com/mikepenz/release-changelog-builder-action/develop/.github/images/release_changelog_builder_expanded.png"/></a>
|
||||
</div>
|
||||
|
||||
<div align="center">
|
||||
<a href="https://github.com/mikepenz/release-changelog-builder-action/releases/tag/v0.9.0"><img src=".github/images/release_changelog_result.png"/></a>
|
||||
<a href="https://github.com/mikepenz/release-changelog-builder-action/releases/tag/v0.9.0"><img src="https://raw.githubusercontent.com/mikepenz/release-changelog-builder-action/develop/.github/images/release_changelog_result.png"/></a>
|
||||
</div>
|
||||
|
||||
@@ -456,6 +456,38 @@ it('Deduplicate duplicated PRs DESC', async () => {
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
it('Use empty_content for empty category', async () => {
|
||||
const customConfig = Object.assign({}, DefaultConfiguration)
|
||||
customConfig.categories = [
|
||||
{
|
||||
title: '## 🚀 Features and 🐛 Issues',
|
||||
labels: ['Never-Matching-Category'],
|
||||
empty_content: "- No PRs in this category"
|
||||
},
|
||||
{
|
||||
title: '## 🚀 Features',
|
||||
labels: ['Feature'],
|
||||
}
|
||||
]
|
||||
|
||||
const resultChangelog = buildChangelog(pullRequestsWithLabels, {
|
||||
owner: 'mikepenz',
|
||||
repo: 'test-repo',
|
||||
fromTag: '1.0.0',
|
||||
toTag: '2.0.0',
|
||||
includeOpen: false,
|
||||
failOnError: false,
|
||||
fetchReviewers: false,
|
||||
commitMode: false,
|
||||
configuration: customConfig
|
||||
})
|
||||
|
||||
expect(resultChangelog).toStrictEqual(
|
||||
`## 🚀 Features and 🐛 Issues\n\n- No PRs in this category\n\n## 🚀 Features\n\n- [ABC-1234] - this is a PR 1 title message\n - PR: #1\n- [ABC-1234] - this is a PR 3 title message\n - PR: #3\n\n`
|
||||
)
|
||||
})
|
||||
|
||||
it('Commit SHA-1 in commitMode', async () => {
|
||||
const customConfig = Object.assign({}, DefaultConfiguration)
|
||||
customConfig.sort = "DESC"
|
||||
|
||||
+922
-57
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
Generated
+1103
-1883
File diff suppressed because it is too large
Load Diff
+9
-9
@@ -35,26 +35,26 @@
|
||||
"@actions/core": "^1.9.0",
|
||||
"@actions/exec": "^1.1.1",
|
||||
"@actions/github": "^5.0.3",
|
||||
"@octokit/rest": "^18.12.0",
|
||||
"@octokit/rest": "^19.0.1",
|
||||
"@types/semver": "^7.3.10",
|
||||
"moment": "^2.29.3",
|
||||
"moment": "^2.29.4",
|
||||
"semver": "^7.3.7",
|
||||
"tunnel": "^0.0.6",
|
||||
"webpack": "^5.73.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^28.1.1",
|
||||
"@types/node": "^18.0.0",
|
||||
"@typescript-eslint/parser": "^5.28.0",
|
||||
"@types/jest": "^28.1.4",
|
||||
"@types/node": "^18.0.3",
|
||||
"@typescript-eslint/parser": "^5.30.5",
|
||||
"@vercel/ncc": "^0.34.0",
|
||||
"eslint": "^8.17.0",
|
||||
"eslint": "^8.19.0",
|
||||
"eslint-plugin-github": "^4.3.6",
|
||||
"eslint-plugin-jest": "^26.5.3",
|
||||
"jest": "^28.1.1",
|
||||
"jest-circus": "^28.1.1",
|
||||
"jest": "^28.1.2",
|
||||
"jest-circus": "^28.1.2",
|
||||
"js-yaml": "^4.1.0",
|
||||
"prettier": "2.7.1",
|
||||
"ts-jest": "^28.0.5",
|
||||
"typescript": "^4.7.3"
|
||||
"typescript": "^4.7.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ export interface Category {
|
||||
labels: string[] // labels to associate PRs to this category
|
||||
exclude_labels?: string[] // if an exclude label is detected, the PR will be excluded from this category
|
||||
exhaustive?: boolean // requires all labels to be present in the PR
|
||||
empty_content?: string // if the category has no matching PRs, this content will be used. If not set, the category will be skipped in the changelog.
|
||||
}
|
||||
|
||||
export interface Sort {
|
||||
|
||||
+4
-3
@@ -183,9 +183,10 @@ export function buildChangelog(
|
||||
for (const pr of pullRequests) {
|
||||
changelog = `${changelog + pr}\n`
|
||||
}
|
||||
|
||||
// add space between
|
||||
changelog = `${changelog}\n`
|
||||
changelog = `${changelog}\n` // add space between sections
|
||||
} else if (category.empty_content !== undefined) {
|
||||
changelog = `${changelog + category.title}\n\n`
|
||||
changelog = `${changelog + category.empty_content}\n\n`
|
||||
}
|
||||
}
|
||||
core.info(`✒️ Wrote ${categorizedPrs.length} categorized pull requests down`)
|
||||
|
||||
Reference in New Issue
Block a user