Skip to content

Commit 25d9b55

Browse files
authored
chore: [REL-4161] fix up tag checks (#558)
Two things being updated here: 1. update the tag-check (for this repo) to only check the remote repo for the tag. It will definitely exist in the local copy since we need to create it before running Goreleaser. Other minor tweak is that instead of bailing on the entire action, we just return 0, so the action can continue to run and complete the final step of creating the Github release. The only reason we're likely to be running the action again if the tag was created, is that the Github release failed, so we want to let the action continue, so it can do that last step. 2. checking for existing tag (GHA and Bitbucket Pipe) on dry-run as well. This was fixed for real runs of the action, but dry-runs will also bomb out if the tag exists (the tag could exist if we previously had a partially successful run, but need to re-run the action to retry the parts that didn't complete successfully) <!-- ld-jira-link --> --- Related Jira issue: [REL-4161: Migrate ld-find-code-refs from Releaser to GHA](https://launchdarkly.atlassian.net/browse/REL-4161) <!-- end-ld-jira-link -->
1 parent 4eea47f commit 25d9b55

File tree

3 files changed

+46
-27
lines changed

3 files changed

+46
-27
lines changed

scripts/release/push-to-origin.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,20 @@
22

33
set -euo pipefail
44

5-
release_tag="v${LD_RELEASE_VERSION}"
5+
release_tag="v$LD_RELEASE_VERSION"
66

77
tag_exists() (
8-
git fetch --tags
9-
git rev-parse "${release_tag}" >/dev/null 2>&1
8+
git ls-remote --tags [email protected]:launchdarkly/ld-find-code-refs.git "refs/tags/$release_tag" | grep -q "$release_tag"
109
)
1110

1211
push_to_origin() (
1312
if tag_exists; then
1413
echo "Tag $release_tag already exists. Aborting."
15-
exit 1
14+
return 0
1615
fi
1716

1817
git push origin HEAD
19-
git push origin "${release_tag}"
18+
git push origin "$release_tag"
2019
)
2120

2221
if [[ "$DRY_RUN" == "true" ]]; then

scripts/release/targets/bitbucket.sh

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,33 @@ clean_up_bitbucket() (
2121
cd .. && rm -rf bitbucketMetadataUpdates
2222
)
2323

24+
tag_exists() (
25+
git ls-remote --tags https://bitbucket.org/launchdarkly/ld-find-code-refs-pipe.git "refs/tags/v$LD_RELEASE_VERSION" | grep -q "v$LD_RELEASE_VERSION"
26+
)
27+
2428
publish_bitbucket() (
25-
if git ls-remote --tags https://bitbucket.org/launchdarkly/ld-find-code-refs-pipe.git "refs/tags/v$LD_RELEASE_VERSION" | grep -q "v$LD_RELEASE_VERSION"; then
29+
if tag_exists; then
2630
echo "Version exists; skipping publishing BitBucket Pipe"
27-
else
28-
setup_bitbucket
31+
return 0
32+
fi
2933

30-
echo "Live run: will publish pipe to bitbucket."
34+
setup_bitbucket
3135

32-
cd bitbucketMetadataUpdates
33-
git tag "$LD_RELEASE_VERSION"
34-
git push bb-origin master --tags
36+
echo "Live run: will publish pipe to bitbucket."
3537

36-
clean_up_bitbucket
37-
fi
38+
cd bitbucketMetadataUpdates
39+
git tag "$LD_RELEASE_VERSION"
40+
git push bb-origin master --tags
41+
42+
clean_up_bitbucket
3843
)
3944

4045
dry_run_bitbucket() (
46+
if tag_exists; then
47+
echo "Version exists; skipping push dry-run BitBucket Pipe"
48+
return 0
49+
fi
50+
4151
setup_bitbucket
4252

4353
echo "Dry run: will not publish pipe to bitbucket."

scripts/release/targets/gha.sh

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,27 +36,37 @@ clean_up_gha() (
3636
cd .. && rm -rf githubActionsMetadataUpdates
3737
)
3838

39+
tag_exists() (
40+
git ls-remote --tags [email protected]:launchdarkly/find-code-references.git "refs/tags/v$LD_RELEASE_VERSION" | grep -q "v$LD_RELEASE_VERSION"
41+
)
42+
3943
publish_gha() (
40-
if git ls-remote --tags [email protected]:launchdarkly/find-code-references.git "refs/tags/v$LD_RELEASE_VERSION" | grep -q "v$LD_RELEASE_VERSION"; then
44+
if tag_exists; then
4145
echo "Version exists; skipping publishing GHA"
42-
else
43-
setup_gha
46+
return 0
47+
fi
4448

45-
echo "Live run: will publish action to github action marketplace."
49+
setup_gha
4650

47-
cd githubActionsMetadataUpdates
48-
# tag the commit with the release version and create release
49-
git tag "$RELEASE_TAG"
50-
git push origin main --tags
51-
git tag -f "$RELEASE_TAG_MAJOR"
52-
git push -f origin "$RELEASE_TAG_MAJOR"
53-
gh release create "$RELEASE_TAG" --notes "$RELEASE_NOTES"
51+
echo "Live run: will publish action to github action marketplace."
5452

55-
clean_up_gha
56-
fi
53+
cd githubActionsMetadataUpdates
54+
# tag the commit with the release version and create release
55+
git tag "$RELEASE_TAG"
56+
git push origin main --tags
57+
git tag -f "$RELEASE_TAG_MAJOR"
58+
git push -f origin "$RELEASE_TAG_MAJOR"
59+
gh release create "$RELEASE_TAG" --notes "$RELEASE_NOTES"
60+
61+
clean_up_gha
5762
)
5863

5964
dry_run_gha() (
65+
if tag_exists; then
66+
echo "Version exists; skipping push dry-run GHA"
67+
return 0
68+
fi
69+
6070
setup_gha
6171

6272
echo "Dry run: will not publish action to github action marketplace."

0 commit comments

Comments
 (0)