Skip to content

Commit

Permalink
Add option to exclude tags
Browse files Browse the repository at this point in the history
Signed-off-by: Zuhair AlSader <zuhair@koor.tech>
  • Loading branch information
zalsader committed Sep 6, 2023
1 parent ed43eb3 commit a6ac56e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ A GitHub action to turn a GitHub project into a self-hosted Helm chart repo, usi
- `mark_as_latest`: When you set this to `false`, it will mark the created GitHub release not as 'latest'.
- `packages_with_index`: When you set this to `true`, it will upload chart packages directly into publishing branch.
- `pages_branch`: Name of the branch to be used to push the index and artifacts. (default to: gh-pages but it is not set in the action it is a default value for the chart-releaser binary)
- `exclude_tags`: Tags matching this glob are excluded when looking for the latest release

### Outputs

Expand Down
6 changes: 6 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ inputs:
required: false
pages_branch:
description: "Name of the branch to be used to push the index and artifacts. (default to: gh-pages but it is not set in the action it is a default value for the chart-releaser binary)"
exclude_tags:
description: "Tags matching this glob are excluded when looking for the latest release"
required: false
outputs:
changed_charts:
Expand Down Expand Up @@ -97,6 +99,10 @@ runs:
if [[ -n "${{ inputs.pages_branch }}" ]]; then
args+=(--pages-branch "${{ inputs.pages_branch }}")
fi
if [[ -n "${{ inputs.exclude_tags }}" ]]; then
args+=(--exclude-tags "${{ inputs.exclude_tags }}")
fi
"$GITHUB_ACTION_PATH/cr.sh" "${args[@]}"
Expand Down
14 changes: 13 additions & 1 deletion cr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Usage: $(basename "$0") <options>
--skip-existing Skip package upload if release exists
-l, --mark-as-latest Mark the created GitHub release as 'latest' (default: true)
--packages-with-index Upload chart packages directly into publishing branch
-e, --exclude-tags Tags matching this glob are excluded when looking for the latest release
EOF
}

Expand All @@ -53,6 +54,7 @@ main() {
local mark_as_latest=true
local packages_with_index=false
local pages_branch=
local exclude_tags=

parse_command_line "$@"

Expand Down Expand Up @@ -210,6 +212,12 @@ parse_command_line() {
shift
fi
;;
-e | --exclude-tags)
if [[ -n "${2:-}" ]]; then
exclude_tags="$2"
shift
fi
;;
*)
break
;;
Expand Down Expand Up @@ -264,8 +272,12 @@ install_chart_releaser() {

lookup_latest_tag() {
git fetch --tags >/dev/null 2>&1
local describe_args=(--tags --abbrev=0)
if [[ -n "$exclude_tags" ]]; then
describe_args+=(--exclude="$exclude_tags")
fi

if ! git describe --tags --abbrev=0 HEAD~ 2>/dev/null; then
if ! git describe "${describe_args[@]}" HEAD~ 2>/dev/null; then
git rev-list --max-parents=0 --first-parent HEAD
fi
}
Expand Down

0 comments on commit a6ac56e

Please sign in to comment.