Skip to content

Commit 0d401aa

Browse files
authored
ci: only publish helm-chart once (#1045)
Each file found with "release.extra_files" will become an artifact. Those artifacts cannot be filtered by "publishers[].ids". If the "release" step does not run (e.g. snapshot), the publishers will not have any artifacts to publish. This make the "release.extra_files" glob pattern more strict, and ensure that the helm chart publisher only runs once, for the helm chart package.
1 parent a157293 commit 0d401aa

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

.goreleaser.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,18 @@ release:
7171
- archive
7272
extra_files:
7373
- glob: ./deploy/ccm*.yaml
74-
- glob: ./hcloud-cloud-controller-manager-*.tgz
74+
- glob: ./hcloud-cloud-controller-manager-{{ .Version }}.tgz
7575

7676
publishers:
7777
- name: publish-helm-chart
7878

79-
# Only execute once by filtering all ids, and only running for the checksum.
79+
# Filter all artifacts, except the one generated by "release.extra_files" that
80+
# cannot be filtered. If the "release" step does not run, the publisher will have
81+
# not artifacts to publish.
8082
ids: ["none"]
81-
checksum: true
8283

8384
cmd: ./scripts/publish-helm-chart.sh hcloud-cloud-controller-manager-{{ .Version }}.tgz
8485
env:
8586
- CHART_REPO_REMOTE={{ .Env.CHART_REPO_REMOTE }}
87+
# Ensures we only publish once, when $1 == $GORELEASER_ARTIFACT_FILE
88+
- GORELEASER_ARTIFACT_FILE={{ .ArtifactPath }}

scripts/publish-helm-chart.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ if [[ -z "$CHART_FILE" ]]; then
1313
exit 1
1414
fi
1515

16+
# Ensures we only publish once, when $1 == $GORELEASER_ARTIFACT_FILE
17+
if [[ -n "${GORELEASER_ARTIFACT_FILE}" && "${GORELEASER_ARTIFACT_FILE}" != "${CHART_FILE}" ]]; then
18+
echo "skipping artifact: ${GORELEASER_ARTIFACT_FILE}" >&2
19+
exit 0
20+
fi
21+
1622
TMP_DIR=$(mktemp --directory chart-repo.XXXXX)
1723
# shellcheck disable=SC2064
1824
trap "rm -Rf '$(realpath "$TMP_DIR")'" EXIT

0 commit comments

Comments
 (0)