From b75cb32f348b527cfe77f5697636823cf77708aa Mon Sep 17 00:00:00 2001 From: Daniel La Rocque Date: Tue, 14 May 2024 14:55:34 -0400 Subject: [PATCH 1/3] Add job to create a GitHub release --- .github/workflows/release-prod.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/.github/workflows/release-prod.yml b/.github/workflows/release-prod.yml index 6dcedb0b04a..e207493699c 100644 --- a/.github/workflows/release-prod.yml +++ b/.github/workflows/release-prod.yml @@ -124,3 +124,28 @@ jobs: curl -X POST -H "Content-Type:application/json" \ -d "{\"version\":\"$BASE_VERSION\",\"date\":\"$DATE\"}" \ $RELEASE_TRACKER_URL/logProduction + - name: Create Github release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # Get the newest release tag for the firebase package (e.g. firebase@10.12.0) + NEWEST_TAG=$(git describe --tags --match "firebase@[0-9]*.[0-9]*.[0-9]*" --abbrev=0) + + # Get the release notes from the description of the most recent merged PR into the "release" branch + # See: https://github.com/firebase/firebase-js-sdk/pull/8236 for an example description + RELEASE_NOTES=$(gh pr list \ + --repo "$GITHUB_REPOSITORY" \ + --state "merged" \ + --base "release" \ + --limit 1 \ + --json "body" \ + | jq '.[].body'\ + | jq -r . \ + | sed '1,/^# Releases/d') + + # Create the GitHub release + gh release create "$NEWEST_TAG" \ + --repo="$GITHUB_REPOSITORY" \ + --title="$NEWEST_TAG" \ + --notes "$RELEASE_NOTES" \ + --verify-tag From 52cbd720d8fa9b6715c33063aaa278b169aa95a0 Mon Sep 17 00:00:00 2001 From: Daniel La Rocque Date: Wed, 15 May 2024 15:46:52 -0400 Subject: [PATCH 2/3] Add release notes link and header to beginning of release notes --- .github/workflows/release-prod.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-prod.yml b/.github/workflows/release-prod.yml index e207493699c..8a079fb03e9 100644 --- a/.github/workflows/release-prod.yml +++ b/.github/workflows/release-prod.yml @@ -139,9 +139,13 @@ jobs: --base "release" \ --limit 1 \ --json "body" \ - | jq '.[].body'\ + | jq '.[].body' \ | jq -r . \ - | sed '1,/^# Releases/d') + | sed '1,/^# Releases/d' \ + ) + + # Prepend the Firebase release notes link and header + RELEASE_NOTES="For more detailed release notes, see [Firebase JavaScript SDK Release Notes](https://firebase.google.com/support/release-notes/js).\n\n# What's Changed\n\n${RELEASE_NOTES}" # Create the GitHub release gh release create "$NEWEST_TAG" \ From 37ccc60c712f602f300385ac376efc5b9b60e9d0 Mon Sep 17 00:00:00 2001 From: Daniel La Rocque Date: Thu, 16 May 2024 10:32:22 -0400 Subject: [PATCH 3/3] Add link to release notes and custom header --- .github/workflows/release-prod.yml | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release-prod.yml b/.github/workflows/release-prod.yml index 8a079fb03e9..d0c3de16859 100644 --- a/.github/workflows/release-prod.yml +++ b/.github/workflows/release-prod.yml @@ -133,23 +133,26 @@ jobs: # Get the release notes from the description of the most recent merged PR into the "release" branch # See: https://github.com/firebase/firebase-js-sdk/pull/8236 for an example description - RELEASE_NOTES=$(gh pr list \ + JSON_RELEASE_NOTES=$(gh pr list \ --repo "$GITHUB_REPOSITORY" \ --state "merged" \ --base "release" \ --limit 1 \ --json "body" \ - | jq '.[].body' \ - | jq -r . \ - | sed '1,/^# Releases/d' \ + | jq '.[].body | split("\n# Releases\n")[-1]' # Remove the generated changesets header ) + + # Prepend the new release header + # We have to be careful to insert the new release header after a " character, since we're + # modifying the JSON string + JSON_RELEASE_NOTES="\"For more detailed release notes, see [Firebase JavaScript SDK Release Notes](https://firebase.google.com/support/release-notes/js).\n\n# What's Changed\n\n${JSON_RELEASE_NOTES:1}" - # Prepend the Firebase release notes link and header - RELEASE_NOTES="For more detailed release notes, see [Firebase JavaScript SDK Release Notes](https://firebase.google.com/support/release-notes/js).\n\n# What's Changed\n\n${RELEASE_NOTES}" + # Format the JSON string into a readable markdown string + RELEASE_NOTES=$(echo -E $JSON_RELEASE_NOTES | jq -r .) # Create the GitHub release gh release create "$NEWEST_TAG" \ - --repo="$GITHUB_REPOSITORY" \ - --title="$NEWEST_TAG" \ + --repo "$GITHUB_REPOSITORY" \ + --title "$NEWEST_TAG" \ --notes "$RELEASE_NOTES" \ --verify-tag