Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to exclude tags #157

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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