Skip to content

Commit 0323f0d

Browse files
authored
chore: [REL-4161] write deploy key to file instead of adding contents directly (#553)
Since private keys are multiple lines, it's recommended to write them to a file instead of passing the contents directly to an env variable to avoid escaping issues \n characters being handled incorrectly, etc. Goreleaser supports (and probably prefers) writing private keys to a file, so I'm hopeful this will get us there. Hopefully, the private key is not malformed before writing to the file, but I guess we'll find out 😬. <!-- 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 973a2e9 commit 0323f0d

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

.github/workflows/release.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,6 @@ jobs:
6262
else
6363
./scripts/release/publish.sh
6464
fi
65-
env:
66-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67-
LAUNCHDARKLY_HOMEBREW_TAP_DEPLOY_KEY: ${{ secrets.LAUNCHDARKLY_HOMEBREW_TAP_DEPLOY_KEY }}
6865
- name: release details
6966
run: |
7067
git show -p

.goreleaser.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ brews:
6767
branch: main
6868
git:
6969
url: [email protected]:launchdarkly/homebrew-tap.git
70-
private_key: "{{ .Env.HOMEBREW_GH_TOKEN }}"
70+
private_key: "{{ .Env.HOMEBREW_KEY_PATH }}"
7171
folder: Formula
7272
url_template: "https://github.com/launchdarkly/ld-find-code-refs/releases/download/{{ .Tag }}/{{ .ArtifactName }}"
7373
install: |

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ clean:
7272
rm -f build/package/github-actions/ld-find-code-refs-github-action
7373
rm -f build/package/bitbucket-pipelines/ld-find-code-refs-bitbucket-pipeline
7474

75-
RELEASE_CMD=curl -sL https://git.io/goreleaser | GOPATH=$(mktemp -d) VERSION=$(GORELEASER_VERSION) GITHUB_TOKEN=$(GITHUB_TOKEN) HOMEBREW_GH_TOKEN=$(HOMEBREW_GH_TOKEN) bash -s -- --clean --debug --release-notes $(RELEASE_NOTES)
75+
RELEASE_CMD=curl -sL https://git.io/goreleaser | GOPATH=$(mktemp -d) VERSION=$(GORELEASER_VERSION) GITHUB_TOKEN=$(GITHUB_TOKEN) HOMEBREW_KEY_PATH=$(HOMEBREW_KEY_PATH) bash -s -- --clean --debug --release-notes $(RELEASE_NOTES)
7676

7777
publish:
7878
$(RELEASE_CMD)

scripts/release/stage-artifacts.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@ stage_artifacts() (
77

88
echo "$DOCKER_TOKEN" | sudo docker login --username "$DOCKER_USERNAME" --password-stdin
99

10-
sudo PATH="$PATH" GITHUB_TOKEN="$GITHUB_TOKEN" HOMEBREW_GH_TOKEN="$HOMEBREW_GH_TOKEN" make "$target"
10+
# write homebrew key to temporary file for Goreleaser
11+
if [[ -n "${HOMEBREW_GH_TOKEN:-}" ]]; then
12+
HOMEBREW_KEY_PATH="/tmp/homebrew-tap-deploy-key"
13+
echo "$HOMEBREW_GH_TOKEN" > "$HOMEBREW_KEY_PATH"
14+
chmod 600 "$HOMEBREW_KEY_PATH"
15+
export HOMEBREW_KEY_PATH
16+
fi
17+
18+
sudo PATH="$PATH" GITHUB_TOKEN="$GITHUB_TOKEN" HOMEBREW_KEY_PATH="$HOMEBREW_KEY_PATH" make "$target"
1119

1220
mkdir -p "$ARTIFACT_DIRECTORY"
1321
cp ./dist/*.deb ./dist/*.rpm ./dist/*.tar.gz ./dist/*.txt "$ARTIFACT_DIRECTORY"

0 commit comments

Comments
 (0)