Skip to content

Commit b75fa77

Browse files
authored
chore: [REL-4161] modify files with new version only after running goreleaser (#533)
Goreleaser doesn't allow any files tracked by Git to be modified before running Goreleaser. This update moves the version bump for various metadata/configuration files _after_ the artifacts are created with Goreleaser. Couple other notes: - I ended up not needing `jq`, so removing the install step - The prepare-release.sh script has been combined with stage-artifacts.sh script (now removed), and is called from publish.sh or publish-dry-run.sh, so the GHA has been removed - couple local vars were changed to lowercase <!-- 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 fd59766 commit b75fa77

5 files changed

Lines changed: 27 additions & 32 deletions

File tree

.github/workflows/release.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,6 @@ jobs:
3232
- uses: actions/checkout@v4
3333
with:
3434
fetch-depth: 0
35-
- name: Install jq
36-
run: |
37-
if ! command -v jq >/dev/null; then
38-
sudo apt-get update
39-
sudo apt-get install -y jq
40-
fi
4135
- name: get secrets
4236
uses: launchdarkly/gh-actions/actions/release-secrets@release-secrets-v1.2.0
4337
with:
@@ -58,8 +52,6 @@ jobs:
5852
fi
5953
6054
make build
61-
- name: prepare release
62-
run: ./scripts/release/prepare-release.sh
6355
- name: publish
6456
run: |
6557
if [[ "$DRY_RUN" = true ]]; then

scripts/release/prepare-release.sh

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,18 @@
22

33
set -euo pipefail
44

5-
RELEASE_TAG="v${LD_RELEASE_VERSION}"
5+
release_tag="v${LD_RELEASE_VERSION}"
6+
7+
stage_artifacts() (
8+
local target=$1
9+
10+
echo "$DOCKER_TOKEN" | sudo docker login --username "$DOCKER_USERNAME" --password-stdin
11+
12+
sudo PATH="$PATH" GITHUB_TOKEN="$GITHUB_TOKEN" make "$target"
13+
14+
mkdir -p "$ARTIFACT_DIRECTORY"
15+
cp ./dist/*.deb ./dist/*.rpm ./dist/*.tar.gz ./dist/*.txt "$ARTIFACT_DIRECTORY"
16+
)
617

718
update_go() (
819
sed -i "s/const Version =.*/const Version = \"${LD_RELEASE_VERSION}\"/g" internal/version/version.go
@@ -14,7 +25,7 @@ update_orb() (
1425
)
1526

1627
update_gha() (
17-
sed -i "s#launchdarkly/find-code-references@v.*#launchdarkly/find-code-references@${RELEASE_TAG}#g" build/metadata/github-actions/README.md
28+
sed -i "s#launchdarkly/find-code-references@v.*#launchdarkly/find-code-references@${release_tag}#g" build/metadata/github-actions/README.md
1829
sed -i "s#launchdarkly/ld-find-code-refs-github-action:.*#launchdarkly/ld-find-code-refs-github-action:${LD_RELEASE_VERSION}#g" build/metadata/github-actions/Dockerfile
1930
)
2031

@@ -23,7 +34,13 @@ update_bitbucket() (
2334
sed -i "s#image: launchdarkly/ld-find-code-refs-bitbucket-pipeline:.*#image: launchdarkly/ld-find-code-refs-bitbucket-pipeline:${LD_RELEASE_VERSION}#g" build/metadata/bitbucket/pipe.yml
2435
)
2536

26-
update_go
27-
update_orb
28-
update_gha
29-
update_bitbucket
37+
prepare_release() (
38+
# create artifacts with goreleaser
39+
stage_artifacts $1
40+
41+
# update metadata files
42+
update_go
43+
update_orb
44+
update_gha
45+
update_bitbucket
46+
)

scripts/release/publish-dry-run.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
set -euo pipefail
44

5-
source $(dirname $0)/stage-artifacts.sh
6-
stage_artifacts products-for-release
5+
source $(dirname $0)/prepare_release.sh
6+
prepare_release products-for-release
77

88
# Copy the Docker image that goreleaser just built into the artifacts - we only do
99
# this in a dry run, because in a real release the image will be available from

scripts/release/publish.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
set -euo pipefail
44

5-
source $(dirname $0)/stage-artifacts.sh
6-
stage_artifacts publish
5+
source $(dirname $0)/prepare-release.sh
6+
prepare_release publish
77

88
# make bitbucket and github known hosts to push successfully
99
mkdir -m700 ~/.ssh

scripts/release/stage-artifacts.sh

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)