From 97ddf445e601dbafbd45d390bd31bca1cb3e31f3 Mon Sep 17 00:00:00 2001 From: Scott Brenner Date: Sun, 4 Apr 2021 10:52:42 -0700 Subject: [PATCH 01/14] Move package-dir from arg to env --- action.yml | 3 +-- entrypoint.sh | 7 +++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index edbd4e0..51e1b25 100644 --- a/action.yml +++ b/action.yml @@ -20,11 +20,10 @@ inputs: runs: using: 'docker' image: 'Dockerfile' - args: - - ${{ inputs.package-dir }} env: FROM_TAG: ${{ inputs.from-tag }} TO_TAG: ${{ inputs.to-tag }} + PACKAGE_DIR: ${{ inputs.package-dir }} branding: icon: 'edit' color: 'gray-dark' diff --git a/entrypoint.sh b/entrypoint.sh index d919668..c2b42a8 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -7,8 +7,11 @@ if [ "$REPO" = "ScottBrenner/generate-changelog-action" ]; then cd generate-changelog-action || exit fi -if [ "$1" ] && [ "$1" != "package.json" ]; then - cp "$1" package.json +if [ -z "$PACKAGE_DIR" ]; then + echo "No path for the package.json passed. Fallbacking to root directory." +else + echo "package-dir detected. Using it's value." + cp $PACKAGE_DIR package.json fi if [ -z "$FROM_TAG" ]; then From a968b113b2e8bd12ae5145081971ab0e07a2cc6b Mon Sep 17 00:00:00 2001 From: Scott Brenner Date: Sun, 4 Apr 2021 10:55:38 -0700 Subject: [PATCH 02/14] Cleanup --- entrypoint.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index c2b42a8..d25c34b 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -10,7 +10,7 @@ fi if [ -z "$PACKAGE_DIR" ]; then echo "No path for the package.json passed. Fallbacking to root directory." else - echo "package-dir detected. Using it's value." + echo "package-dir detected. Using its value." cp $PACKAGE_DIR package.json fi @@ -18,15 +18,15 @@ 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 it's value." + echo "From-tag detected. Using its value." previous_tag=$FROM_TAG fi -if [ -z "$TO_TAG" ]; then +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 it's value." + echo "To-tag detected. Using its value." new_tag=$TO_TAG fi From 1f5965bb72b4128e530b6faa324e823aa8795f85 Mon Sep 17 00:00:00 2001 From: Scott Brenner Date: Sun, 4 Apr 2021 10:56:08 -0700 Subject: [PATCH 03/14] Cleanup --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 51e1b25..c4f821b 100644 --- a/action.yml +++ b/action.yml @@ -16,7 +16,7 @@ inputs: to-tag: description: 'The tag to generate changelog up to' required: false - default: '' + default: '' runs: using: 'docker' image: 'Dockerfile' From c2e126780e275e7773cb9c49b528589e0a1191b1 Mon Sep 17 00:00:00 2001 From: Scott Brenner Date: Sun, 4 Apr 2021 11:09:35 -0700 Subject: [PATCH 04/14] Support changelog type --- README.md | 1 + action.yml | 7 ++++++- entrypoint.sh | 19 ++++++++++++++++++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 89a842c..e0b75bf 100644 --- a/README.md +++ b/README.md @@ -77,3 +77,4 @@ For more information, see [actions/create-release: Usage](https://github.com/act | 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. | diff --git a/action.yml b/action.yml index c4f821b..22ae11c 100644 --- a/action.yml +++ b/action.yml @@ -17,13 +17,18 @@ inputs: description: 'The tag to generate changelog up to' required: false default: '' + type: + description: 'Type of changelog: patch, minor, or major' + required: false + default: '' runs: using: 'docker' image: 'Dockerfile' env: + PACKAGE_DIR: ${{ inputs.package-dir }} FROM_TAG: ${{ inputs.from-tag }} TO_TAG: ${{ inputs.to-tag }} - PACKAGE_DIR: ${{ inputs.package-dir }} + TYPE: ${{ inputs.type }} branding: icon: 'edit' color: 'gray-dark' diff --git a/entrypoint.sh b/entrypoint.sh index d25c34b..11d821e 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -30,7 +30,24 @@ else new_tag=$TO_TAG fi -changelog=$(generate-changelog -t "$previous_tag..$new_tag" --file -) +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" + ;; + patch) + changelog_type="--major" + ;; + esac +fi + +changelog=$(generate-changelog "$changelog_type" -t "$previous_tag..$new_tag" --file -) changelog="${changelog//'%'/'%25'}" changelog="${changelog//$'\n'/'%0A'}" From c7749bab43a026908d70f720e7c8d5d4dd9b6a07 Mon Sep 17 00:00:00 2001 From: Scott Brenner Date: Sun, 4 Apr 2021 11:16:01 -0700 Subject: [PATCH 05/14] Support excluded commit types --- README.md | 1 + action.yml | 7 ++++++- entrypoint.sh | 11 +++++++++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e0b75bf..7808a11 100644 --- a/README.md +++ b/README.md @@ -78,3 +78,4 @@ For more information, see [actions/create-release: Usage](https://github.com/act | 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. | diff --git a/action.yml b/action.yml index 22ae11c..7ca7950 100644 --- a/action.yml +++ b/action.yml @@ -20,7 +20,11 @@ inputs: type: description: 'Type of changelog: patch, minor, or major' required: false - default: '' + default: '' + exclude: + description: 'Exclude selected commit types (comma separated)' + required: false + default: '' runs: using: 'docker' image: 'Dockerfile' @@ -29,6 +33,7 @@ runs: FROM_TAG: ${{ inputs.from-tag }} TO_TAG: ${{ inputs.to-tag }} TYPE: ${{ inputs.type }} + EXCLUDE: ${{ inputs.exclude }} branding: icon: 'edit' color: 'gray-dark' diff --git a/entrypoint.sh b/entrypoint.sh index 11d821e..932b71a 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -31,7 +31,7 @@ else fi if [ -z "$TYPE" ]; then - echo "No type passed. Fallbacking to unset" + echo "No type passed. Fallbacking to unset." else echo "Type detected. Using its value." case $TYPE in @@ -47,7 +47,14 @@ else esac fi -changelog=$(generate-changelog "$changelog_type" -t "$previous_tag..$new_tag" --file -) +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 + +changelog=$(generate-changelog "$changelog_type" -t "$previous_tag..$new_tag" "$exclude_types" --file -) changelog="${changelog//'%'/'%25'}" changelog="${changelog//$'\n'/'%0A'}" From 8deb8b2c89f2dd25e7d0a7eb58797ada9a3fe8a8 Mon Sep 17 00:00:00 2001 From: Scott Brenner Date: Sun, 4 Apr 2021 11:20:57 -0700 Subject: [PATCH 06/14] Support unknown commit types --- README.md | 1 + action.yml | 5 +++++ entrypoint.sh | 9 ++++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7808a11..1d9fecb 100644 --- a/README.md +++ b/README.md @@ -79,3 +79,4 @@ For more information, see [actions/create-release: Usage](https://github.com/act | 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. | diff --git a/action.yml b/action.yml index 7ca7950..6a2172e 100644 --- a/action.yml +++ b/action.yml @@ -25,6 +25,10 @@ inputs: description: 'Exclude selected commit types (comma separated)' required: false default: '' + allow-unknown: + description: 'Allow unknown commit types' + required: false + default: '' runs: using: 'docker' image: 'Dockerfile' @@ -34,6 +38,7 @@ runs: TO_TAG: ${{ inputs.to-tag }} TYPE: ${{ inputs.type }} EXCLUDE: ${{ inputs.exclude }} + ALLOW_UNKNOWN: ${{ inputs.allow-unknown }} branding: icon: 'edit' color: 'gray-dark' diff --git a/entrypoint.sh b/entrypoint.sh index 932b71a..c5a0cea 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -54,7 +54,14 @@ else exclude_types="--exclude $EXCLUDE" fi -changelog=$(generate-changelog "$changelog_type" -t "$previous_tag..$new_tag" "$exclude_types" --file -) +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'}" From 83ee25834623be73fee6495651a67ebca2cc0234 Mon Sep 17 00:00:00 2001 From: Scott Brenner Date: Sun, 4 Apr 2021 11:24:22 -0700 Subject: [PATCH 07/14] Double quote to prevent globbing and word splitting. --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index c5a0cea..0f7685c 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -11,7 +11,7 @@ if [ -z "$PACKAGE_DIR" ]; then echo "No path for the package.json passed. Fallbacking to root directory." else echo "package-dir detected. Using its value." - cp $PACKAGE_DIR package.json + cp "$PACKAGE_DIR" package.json fi if [ -z "$FROM_TAG" ]; then From d5f8e1bf4a5c3fab07dd25de37dd64add2256f61 Mon Sep 17 00:00:00 2001 From: Scott Brenner Date: Sun, 4 Apr 2021 11:25:02 -0700 Subject: [PATCH 08/14] This pattern never matches because of a previous pattern --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 0f7685c..d5d9204 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -41,7 +41,7 @@ else minor) changelog_type="--minor" ;; - patch) + major) changelog_type="--major" ;; esac From d1fb9e282c7c671f2dec8ed1a90802792c7a8f3d Mon Sep 17 00:00:00 2001 From: Scott Brenner Date: Sun, 4 Apr 2021 11:31:27 -0700 Subject: [PATCH 09/14] Fix test step --- .github/workflows/dockerimage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 83864ae..610281d 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -24,7 +24,7 @@ jobs: run: docker run --entrypoint generate-changelog generate-changelog-action --version - name: Test generating changelog - run: docker run -e REPO=${{ github.repository }} generate-changelog-action + run: docker run -e repo-url="git+https://github.com/ScottBrenner/generate-changelog-action" generate-changelog-action lint: # Name the Job From b8891c3853bd13f555f73ae567e9df4cde78f6f7 Mon Sep 17 00:00:00 2001 From: Scott Brenner Date: Sun, 4 Apr 2021 11:38:19 -0700 Subject: [PATCH 10/14] Support repo url --- .github/workflows/dockerimage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 610281d..e6e615c 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -24,7 +24,7 @@ jobs: run: docker run --entrypoint generate-changelog generate-changelog-action --version - name: Test generating changelog - run: docker run -e repo-url="git+https://github.com/ScottBrenner/generate-changelog-action" generate-changelog-action + run: docker run -e REPO_URL="git+https://github.com/ScottBrenner/generate-changelog-action" generate-changelog-action lint: # Name the Job From 631143a62431e79dd2913ea10033b2df084dc820 Mon Sep 17 00:00:00 2001 From: Scott Brenner Date: Sun, 4 Apr 2021 11:40:08 -0700 Subject: [PATCH 11/14] Support repo url --- README.md | 1 + action.yml | 5 +++++ entrypoint.sh | 11 +++++++++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1d9fecb..eebaf48 100644 --- a/README.md +++ b/README.md @@ -80,3 +80,4 @@ For more information, see [actions/create-release: Usage](https://github.com/act | 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. | +| repo-url | package.json | Specify the repo URL for commit links, defaults to checking the package.json | diff --git a/action.yml b/action.yml index 6a2172e..35d7e92 100644 --- a/action.yml +++ b/action.yml @@ -29,6 +29,10 @@ inputs: description: 'Allow unknown commit types' required: false default: '' + repo-url: + description: 'Specify the repo URL for commit links, defaults to checking the package.json' + required: false + default: '' runs: using: 'docker' image: 'Dockerfile' @@ -39,6 +43,7 @@ runs: TYPE: ${{ inputs.type }} EXCLUDE: ${{ inputs.exclude }} ALLOW_UNKNOWN: ${{ inputs.allow-unknown }} + REPO_URL: ${{ inputs.repo-url }} branding: icon: 'edit' color: 'gray-dark' diff --git a/entrypoint.sh b/entrypoint.sh index d5d9204..d5ffbc3 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -58,10 +58,17 @@ if [ -z "$ALLOW_UKNOWN" ]; then echo "Unknown commit types not allowed." else echo "Allowing unknown commit types." - unknown_commits="--allow-unknown " + unknown_commits="--allow-unknown" fi -changelog=$(generate-changelog "$changelog_type" -t "$previous_tag..$new_tag" "$exclude_types" "$unknown_commits" --file -) +if [ -z "$REPO_URL" ]; then + echo "Repo URL for commit links not specified. Fallbacking to checking the package.json." +else + echo "Repo URL for commit links specified. Using its value." + commit_links="--repo-url $REPO_URL" +fi + +changelog=$(generate-changelog "$changelog_type" -t "$previous_tag..$new_tag" "$exclude_types" "$unknown_commits" "$commit_links" --file -) changelog="${changelog//'%'/'%25'}" changelog="${changelog//$'\n'/'%0A'}" From ab2b1e936c1276a9505e86b1540c2100bf9184c2 Mon Sep 17 00:00:00 2001 From: Scott Brenner Date: Sun, 4 Apr 2021 11:56:45 -0700 Subject: [PATCH 12/14] Revert "Support repo url" This reverts commit c35e90871d53bdd646ac5e8089b49a5708e0762b. --- README.md | 1 - action.yml | 5 ----- entrypoint.sh | 11 ++--------- 3 files changed, 2 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index eebaf48..1d9fecb 100644 --- a/README.md +++ b/README.md @@ -80,4 +80,3 @@ For more information, see [actions/create-release: Usage](https://github.com/act | 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. | -| repo-url | package.json | Specify the repo URL for commit links, defaults to checking the package.json | diff --git a/action.yml b/action.yml index 35d7e92..6a2172e 100644 --- a/action.yml +++ b/action.yml @@ -29,10 +29,6 @@ inputs: description: 'Allow unknown commit types' required: false default: '' - repo-url: - description: 'Specify the repo URL for commit links, defaults to checking the package.json' - required: false - default: '' runs: using: 'docker' image: 'Dockerfile' @@ -43,7 +39,6 @@ runs: TYPE: ${{ inputs.type }} EXCLUDE: ${{ inputs.exclude }} ALLOW_UNKNOWN: ${{ inputs.allow-unknown }} - REPO_URL: ${{ inputs.repo-url }} branding: icon: 'edit' color: 'gray-dark' diff --git a/entrypoint.sh b/entrypoint.sh index d5ffbc3..d5d9204 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -58,17 +58,10 @@ if [ -z "$ALLOW_UKNOWN" ]; then echo "Unknown commit types not allowed." else echo "Allowing unknown commit types." - unknown_commits="--allow-unknown" + unknown_commits="--allow-unknown " fi -if [ -z "$REPO_URL" ]; then - echo "Repo URL for commit links not specified. Fallbacking to checking the package.json." -else - echo "Repo URL for commit links specified. Using its value." - commit_links="--repo-url $REPO_URL" -fi - -changelog=$(generate-changelog "$changelog_type" -t "$previous_tag..$new_tag" "$exclude_types" "$unknown_commits" "$commit_links" --file -) +changelog=$(generate-changelog "$changelog_type" -t "$previous_tag..$new_tag" "$exclude_types" "$unknown_commits" --file -) changelog="${changelog//'%'/'%25'}" changelog="${changelog//$'\n'/'%0A'}" From 09b1197e00a6ad632b683e453502ff8a5df7e958 Mon Sep 17 00:00:00 2001 From: Scott Brenner Date: Sun, 4 Apr 2021 11:56:58 -0700 Subject: [PATCH 13/14] Revert "Support repo url" This reverts commit 6e0097cc30518b696cfe792b6cb58a7b668b43d0. --- .github/workflows/dockerimage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index e6e615c..610281d 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -24,7 +24,7 @@ jobs: run: docker run --entrypoint generate-changelog generate-changelog-action --version - name: Test generating changelog - run: docker run -e REPO_URL="git+https://github.com/ScottBrenner/generate-changelog-action" generate-changelog-action + run: docker run -e repo-url="git+https://github.com/ScottBrenner/generate-changelog-action" generate-changelog-action lint: # Name the Job From d75aede18cbba6856a7ed695570239baf4c85ed6 Mon Sep 17 00:00:00 2001 From: Scott Brenner Date: Sun, 4 Apr 2021 11:57:18 -0700 Subject: [PATCH 14/14] Revert "Fix test step" This reverts commit 5848c418506679ddd300ecb1990b5d8571a4dafe. --- .github/workflows/dockerimage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index 610281d..83864ae 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -24,7 +24,7 @@ jobs: run: docker run --entrypoint generate-changelog generate-changelog-action --version - name: Test generating changelog - run: docker run -e repo-url="git+https://github.com/ScottBrenner/generate-changelog-action" generate-changelog-action + run: docker run -e REPO=${{ github.repository }} generate-changelog-action lint: # Name the Job