Skip to content

Commit

Permalink
add merged PRs as release note
Browse files Browse the repository at this point in the history
  • Loading branch information
dvviktordelev committed Jun 4, 2024
1 parent 70319fe commit 676a0e2
Showing 1 changed file with 50 additions and 4 deletions.
54 changes: 50 additions & 4 deletions .github/workflows/release-source.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,18 +201,64 @@ jobs:
git add .
git commit -m "Update Helm documentation"
git push origin release-"$RELEASE_VERSION"
#- name: create pr
# id: create-pr
# run: |
# # create a pull request
# curl -L \
# -X POST \
# -H "Accept: application/vnd.github+json" \
# -H "Authorization: Bearer ${{ env.GITHUB_TOKEN}}" \
# -H "X-GitHub-Api-Version: 2022-11-28" \
# https://api.github.com/repos/${{ github.repository_owner }}/${{ github.event.repository.name }}/pulls \
# -d '{"title":"Release ${{ env.RELEASE_VERSION }}","body":"release ${{ env.RELEASE_VERSION }}","head":"release-${{ env.RELEASE_VERSION }}","base":"main","draft":false}'
- name: get latest release date
id: get-release-date
run: |
# Fetch the latest release information
LATEST_RELEASE=$(curl -s -H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository_owner }}/${{ github.event.repository.name }}/releases/latest")
# Extract the published date of the latest release
LATEST_RELEASE_DATE=$(echo "$LATEST_RELEASE" | jq -r '.published_at')
# Export the date
echo "RELEASE_DATE=$LATEST_RELEASE_DATE" >> "$GITHUB_ENV"
- name: fetch merged PRs since last release
id: fetch-prs
run: |
# Fetch merged PRs from the develop branch since the last release date
PRS=$(curl -s -H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/${{ github.repository_owner }}/${{ github.event.repository.name }}/pulls?state=closed&base=develop&sort=updated&direction=desc")
# Filter PRs merged after the last release date and format them
PR_NOTES=$(echo "$PRS" | jq -r --arg since "${{ env.RELEASE_DATE }}" '.[] | select(.merged_at != null) | select(.merged_at > $since) | "* [#\(.number)](\(.html_url)) \(.title)"')
# Set the PR_NOTES output
echo "PR_NOTES=$PR_NOTES" >> "$GITHUB_ENV"
- name: create pr
id: create-pr
run: |
# create a pull request
# Create a pull request with release notes
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ env.GITHUB_TOKEN}}" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository_owner }}/${{ github.event.repository.name }}/pulls \
-d '{"title":"Release ${{ env.RELEASE_VERSION }}","body":"release ${{ env.RELEASE_VERSION }}","head":"release-${{ env.RELEASE_VERSION }}","base":"main","draft":false}'
-d "$(jq -n \
--arg title "Release ${{ env.RELEASE_VERSION }}" \
--arg body "## What's changed\n\n${{ env.PR_NOTES }}" \
--arg head "release-${{ env.RELEASE_VERSION }}" \
--arg base "main" \
--argjson draft false \
'{title: $title, body: $body, head: $head, base: $base, draft: $draft}')"
Expand Down

0 comments on commit 676a0e2

Please sign in to comment.