Skip to content

Commit 249237a

Browse files
authored
[REL-4161] fix changelog formatting (#525)
Needed to massage the changelog into shape. <!-- 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 5b1714b commit 249237a

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

.github/workflows/release.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,19 @@ jobs:
2525
env:
2626
LD_RELEASE_VERSION: ${{ inputs.releaseVersion }}
2727
DRY_RUN: ${{ inputs.dryRun || 'false' }}
28-
CHANGELOG_ENTRY: ${{ inputs.changeLog }}
28+
CHANGELOG_ENTRY: ${{ toJSON(inputs.changeLog) }}
2929
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3030
ARTIFACT_DIRECTORY: "/tmp/release-artifacts"
3131
steps:
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
3541
- name: get secrets
3642
uses: launchdarkly/gh-actions/actions/[email protected]
3743
with:
@@ -70,5 +76,5 @@ jobs:
7076
with:
7177
token: ${{ secrets.GITHUB_TOKEN }}
7278
tag: v${{ inputs.releaseVersion }}
73-
body: ${{ inputs.changeLog }}
79+
body: ${{ fromJSON(toJSON(inputs.changeLog)) }}
7480
artifacts: ${{ env.ARTIFACT_DIRECTORY }}/*

scripts/release/commit-and-tag.sh

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,34 @@
22

33
set -euo pipefail
44

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

77
tag_exists() (
88
git fetch --tags
9-
git rev-parse "${RELEASE_TAG}" >/dev/null 2>&1
9+
git rev-parse "${release_tag}" >/dev/null 2>&1
1010
)
1111

1212
update_changelog() (
1313
local ts=$(date +"%Y-%m-%d")
14-
local changelog_entry=$(printf "## [%s] - %s\n%s\n" "$LD_RELEASE_VERSION" "$ts" "$CHANGELOG_ENTRY")
14+
local changelog_json=$(echo "$CHANGELOG_ENTRY" | jq =r .)
15+
local changelog_entry=$(printf "## [%s] - %s\n%s\n" "$LD_RELEASE_VERSION" "$ts" "$changelog_json")
1516

1617
# insert the new changelog entry (followed by empty line) after line 4
1718
# of CHANGELOG.md
1819
sed -i "4r /dev/stdin" CHANGELOG.md <<< "$changelog_entry"$'\n'
1920
)
2021

2122
release_summary() (
22-
echo
23-
echo "Changes staged for release $RELEASE_TAG:"
23+
echo "Changes staged for release $release_tag:"
2424
git diff
2525

26-
echo
2726
echo "Updated CHANGELOG:"
2827
cat CHANGELOG.md
29-
echo
3028
)
3129

3230
commit_and_tag() (
3331
if tag_exists; then
34-
echo "Tag $RELEASE_TAG already exists. Aborting."
32+
echo "Tag $release_tag already exists. Aborting."
3533
exit 1
3634
fi
3735

@@ -41,10 +39,10 @@ commit_and_tag() (
4139
git config user.name "LaunchDarklyReleaseBot"
4240
git config user.email "[email protected]"
4341
git add .
44-
git commit -m "Prepare release ${RELEASE_TAG}"
45-
git tag "${RELEASE_TAG}"
42+
git commit -m "Prepare release ${release_tag}"
43+
git tag "${release_tag}"
4644
git push origin HEAD
47-
git push origin "${RELEASE_TAG}"
45+
git push origin "${release_tag}"
4846
)
4947

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

0 commit comments

Comments
 (0)