Skip to content

Commit

Permalink
ci: fix latest_tag logic in chart-releaser workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
zebernst committed Sep 2, 2024
1 parent 0cc495c commit dbc53d1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
21 changes: 5 additions & 16 deletions .github/actions/chart-releaser-action/cr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -248,24 +248,13 @@ install_chart_releaser() {

lookup_latest_tag() {
git fetch --tags >/dev/null 2>&1
latest_tag=$(git tag --sort=-creatordate | sed -n '2p')

if git symbolic-ref --short -q HEAD; then
if ! git describe --tags --abbrev=0 HEAD~ 2>/dev/null; then
git rev-list --max-parents=0 --first-parent HEAD
fi
if [ -z "$latest_tag" ]; then
# If no tags are found, return the initial commit hash
git rev-list --max-parents=0 --first-parent HEAD
else
# In a detached HEAD state, such as when the pipeline
# is triggered by a push on a tag commit, we need to look back
# by date
current_commit=$(git rev-parse HEAD)
for tag in $(git tag --sort=-creatordate); do
if [ $(git rev-parse "$tag") = "$current_commit" ]; then
continue
else
echo "$tag"
break
fi
done
echo "$latest_tag"
fi
}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

- name: Run chart-releaser
# workaround until https://github.com/helm/chart-releaser-action/issues/150 is fixed
# workaround until https://github.com/helm/chart-releaser-action/pull/154 is fixed
uses: ./.github/actions/chart-releaser-action
with:
mark_as_latest: false
Expand Down

0 comments on commit dbc53d1

Please sign in to comment.