forked from ScottBrenner/generate-changelog-action
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Conflicts: # entrypoint.sh
- Loading branch information
Showing
9 changed files
with
256 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Basic dependabot.yml file with | ||
# minimum configuration for two package managers | ||
|
||
version: 2 | ||
updates: | ||
# Enable version updates for GitHub Actions | ||
- package-ecosystem: "github-actions" | ||
# Look for GitHub Actions workflows in the `root` directory | ||
directory: "/" | ||
# Check the for updates once a week | ||
schedule: | ||
interval: "weekly" | ||
|
||
# Enable version updates for Docker | ||
- package-ecosystem: "docker" | ||
# Look for a `Dockerfile` in the `root` directory | ||
directory: "/" | ||
# Check for updates once a week | ||
schedule: | ||
interval: "weekly" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
on: | ||
push: | ||
# Sequence of patterns matched against refs/tags | ||
tags: | ||
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 | ||
|
||
name: Create Release | ||
|
||
jobs: | ||
build: | ||
name: Create Release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- name: Changelog | ||
uses: scottbrenner/generate-changelog-action@master | ||
id: Changelog | ||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@latest | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: Release ${{ github.ref }} | ||
body: | | ||
${{ steps.Changelog.outputs.changelog }} | ||
draft: false | ||
prerelease: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,48 @@ | ||
# generate-changelog-action | ||
|
||
GitHub Action for [lob/generate-changelog](https://github.com/lob/generate-changelog/). Intended to be used with [actions/create-release](https://github.com/actions/create-release) as follows: | ||
GitHub Action for [lob/generate-changelog](https://github.com/lob/generate-changelog/). Intended to be used with [actions/create-release](https://github.com/actions/create-release). | ||
|
||
### Example workflow - create a release | ||
Extends [actions/create-release: Example workflow - create a release](https://github.com/actions/create-release#example-workflow---create-a-release) to generate changelog from git commits and use it as the body for the GitHub release. | ||
Created during the GitHub Actions Hackathon 2020 and [selected as one of the winning projects!](https://docs.google.com/spreadsheets/d/1YL6mjJXGt3-75GejQCubsOvWwtYcGaqbJA7msnsh7Tg/edit#gid=0&range=A100:C100) | ||
|
||
## Usage | ||
|
||
**Note:** [Your repository must contain a `package.json` file](https://github.com/lob/generate-changelog/issues/38#issuecomment-362726723), although an empty file such as [the one in this repository](https://github.com/ScottBrenner/generate-changelog-action/blob/master/package.json) is fine. | ||
|
||
If your `package.json` isn't available in root directory of your repository, you can pass the path of the `package.json` file by setting `package-dir` as follows: | ||
|
||
```yaml | ||
on: | ||
push: | ||
# Sequence of patterns matched against refs/tags | ||
tags: | ||
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 | ||
|
||
name: Create Release | ||
|
||
jobs: | ||
build: | ||
name: Create Release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- name: changelog | ||
uses: scottbrenner/generate-changelog-action@master | ||
id: Changelog | ||
env: | ||
REPO: ${{ github.repository }} | ||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@latest | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: Release ${{ github.ref }} | ||
body: | | ||
${{ steps.Changelog.outputs.changelog }} | ||
draft: false | ||
prerelease: false | ||
- name: Changelog | ||
uses: scottbrenner/generate-changelog-action@master | ||
id: Changelog | ||
with: | ||
package-dir: 'root/to/my/package.json' | ||
``` | ||
The above workflow will create a release that looks like: | ||
![](release.png) | ||
By default, this Action generates changelogs using commits between the previous tag and the most recent tag. Generate changelogs from specific tag or range (e.g. `v1.2.3` or `v1.2.3..v1.2.4`) by passing the `from-tag` and `to-tag` inputs. An example is when your release tag on git is generated after the changelog so you must use something like `git log v1..HEAD --oneline`: | ||
|
||
```yaml | ||
- name: Changelog | ||
uses: scottbrenner/generate-changelog-action@master | ||
id: Changelog | ||
with: | ||
from-tag: v1.0 | ||
to-tag: HEAD | ||
``` | ||
|
||
This Action additionally supports the following inputs, in accordance with [lob/generate-changelog's CLI options](https://github.com/lob/generate-changelog/#cli). | ||
| Property | Default | Description | | ||
| ------------------------- | ------------- | ----------------------------------------------------------------------------------------------------------------------------- | | ||
| `package-dir` | `package.json`| The path for the package.json if it is not in root | | ||
| `from-tag` | "last tag" | The tag to generate changelog from. If not set, fallbacks to git last tag -1. Ex.: v1.0 | | ||
| `to-tag` | "current tag" | The tag to generate changelog up to. If not set, fallbacks to git last tag. Ex.: v2.0 | | ||
| `type` | Unset | The type of changelog to generate: patch, minor, or major. If not set, fallbacks to unset. | | ||
| `exclude` | Unset | Exclude selected commit types (comma separated). If not set, fallbacks to unset. | | ||
| `allow-unknown` | Unset | Allow unknown commit types. If not set, fallbacks to unset. | ||
|
||
For more information, see [actions/create-release: Usage](https://github.com/actions/create-release#usage), [lob/generate-changelog: Usage](https://github.com/lob/generate-changelog#usage), and [jobs.<job_id>.steps[*].with](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepswith). | ||
|
||
|
||
For more information, see [actions/create-release: Usage](https://github.com/actions/create-release#usage) and [lob/generate-changelog: Usage](https://github.com/lob/generate-changelog#usage) | ||
## Example workflow - create a release | ||
See [this repository's release.yml](https://github.com/ScottBrenner/generate-changelog-action/blob/master/.github/workflows/release.yml) for an example workflow which extends [actions/create-release: Example workflow - create a release](https://github.com/actions/create-release#example-workflow---create-a-release) to generate a changelog from git commits and use it as the body for the GitHub release. | ||
|
||
_Created during the GitHub Actions Hackathon 2020._ | ||
This workflow automatically creates [this repository's releases](https://github.com/ScottBrenner/generate-changelog-action/releases). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,70 @@ | ||
#!/bin/sh -l | ||
# shellcheck disable=SC2039 | ||
|
||
git clone --quiet https://github.com/$REPO &> /dev/null | ||
# For Docker Image CI test job | ||
if [ "$REPO" = "ScottBrenner/generate-changelog-action" ]; then | ||
git clone --quiet https://github.com/"$REPO" | ||
cd generate-changelog-action || exit | ||
fi | ||
|
||
echo "Generating commit range for the following tag range:" | ||
echo $TAG_RANGE | ||
|
||
changelog=$(generate-changelog $* --tag $TAG_RANGE --file -) | ||
|
||
echo $changelog | ||
if [ -z "$FROM_TAG" ]; then | ||
echo "No from-tag passed. Fallbacking to git previous tag." | ||
previous_tag=$(git tag --sort version:refname | tail -n 2 | head -n 1) | ||
else | ||
echo "From-tag detected. Using its value." | ||
previous_tag=$FROM_TAG | ||
fi | ||
|
||
if [ -z "$TO_TAG" ]; then | ||
echo "No to-tag passed. Fallbacking to git previous tag." | ||
new_tag=$(git tag --sort version:refname | tail -n 1) | ||
else | ||
echo "To-tag detected. Using its value." | ||
new_tag=$TO_TAG | ||
fi | ||
|
||
if [ -z "$TYPE" ]; then | ||
echo "No type passed. Fallbacking to unset." | ||
else | ||
echo "Type detected. Using its value." | ||
case $TYPE in | ||
patch) | ||
changelog_type="--patch" | ||
;; | ||
minor) | ||
changelog_type="--minor" | ||
;; | ||
major) | ||
changelog_type="--major" | ||
;; | ||
esac | ||
fi | ||
|
||
if [ -z "$EXCLUDE" ]; then | ||
echo "No commit types selected to exclude. Fallbacking to unset." | ||
else | ||
echo "Commit types selected to exclude. Using its value." | ||
exclude_types="--exclude $EXCLUDE" | ||
fi | ||
|
||
if [ -z "$ALLOW_UKNOWN" ]; then | ||
echo "Unknown commit types not allowed." | ||
else | ||
echo "Allowing unknown commit types." | ||
unknown_commits="--allow-unknown " | ||
fi | ||
|
||
changelog=$(generate-changelog "$changelog_type" -t "$previous_tag..$new_tag" "$exclude_types" "$unknown_commits" --file -) | ||
|
||
changelog="${changelog//'%'/'%25'}" | ||
changelog="${changelog//$'\n'/'%0A'}" | ||
changelog="${changelog//$'\r'/'%0D'}" | ||
|
||
echo "$changelog" | ||
|
||
echo "::set-output name=changelog::$changelog" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{ | ||
} |
Binary file not shown.