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

feat: add a "match_tags" option #89

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ A GitHub action to turn a GitHub project into a self-hosted Helm chart repo, usi
- `charts_dir`: The charts directory
- `skip_packaging`: This option, when populated, will skip the packaging step. This allows you to do more advanced packaging of your charts (for example, with the `helm package` command) before this action runs. This action will only handle the indexing and publishing steps.
- `mark_as_latest`: When you set this to `false`, it will mark the created GitHub release not as 'latest'.
- `match_tags`: The glob to use to filter Git tags, usually used with the `CR_RELEASE_NAME_TEMPLATE` environment variable (default: all tags)

### Outputs

Expand Down
7 changes: 7 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ inputs:
description: Mark the created GitHub release as 'latest'
required: false
default: true
match_tags:
description: "The glob to use to filter Git tags (default: all tags)"
required: false
outputs:
changed_charts:
description: "A comma-separated list of charts that were released on this run. Will be an empty string if no updates were detected, will be unset if `--skip_packaging` is used: in the latter case your custom packaging step is responsible for setting its own outputs if you need them."
Expand Down Expand Up @@ -84,6 +87,10 @@ runs:
args+=(--mark-as-latest "${{ inputs.mark_as_latest }}")
fi

if [[ -n "${{ inputs.match_tags }}" ]]; then
args+=(--match-tags "${{ inputs.match_tags }}")
fi

"$GITHUB_ACTION_PATH/cr.sh" "${args[@]}"

if [[ -f changed_charts.txt ]]; then
Expand Down
20 changes: 19 additions & 1 deletion cr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Usage: $(basename "$0") <options>
-s, --skip-packaging Skip the packaging step (run your own packaging before using the releaser)
--skip-existing Skip package upload if release exists
-l, --mark-as-latest Mark the created GitHub release as 'latest' (default: true)
-m, --match-tags The glob to use to filter Git tags (default: all tags)
EOF
}

Expand All @@ -44,6 +45,7 @@ main() {
local charts_dir=charts
local owner=
local repo=
local match_tags=
local install_dir=
local install_only=
local skip_packaging=
Expand Down Expand Up @@ -164,6 +166,16 @@ parse_command_line() {
exit 1
fi
;;
-m|--match-tags)
if [[ -n "${2:-}" ]]; then
match_tags="$2"
shift
else
echo "ERROR: '--match-tags' cannot be empty." >&2
show_help
exit 1
fi
;;
-n | --install-dir)
if [[ -n "${2:-}" ]]; then
install_dir="$2"
Expand Down Expand Up @@ -249,7 +261,13 @@ install_chart_releaser() {
lookup_latest_tag() {
git fetch --tags >/dev/null 2>&1

if ! git describe --tags --abbrev=0 HEAD~ 2>/dev/null; then
args=("describe" "--tags" "--abbrev=0")
if [ -n "$match_tags" ]; then
args+=(--match="$match_tags")
fi
args+=(HEAD~)

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