From 44bc4b087f1f371f63ee270aba98589c542d72ba Mon Sep 17 00:00:00 2001 From: Boban Date: Thu, 23 Jan 2025 16:32:08 -0500 Subject: [PATCH] ci: update release job to automatically generate release notes (#3187) # PULL REQUEST ## Summary - Update release action to auto generate release notes - [Tag will get created if it does not exist](https://cli.github.com/manual/gh_release_create#:~:text=If%20a%20matching%20git%20tag%20does%20not%20yet%20exist%2C%20one%20will%20automatically%20get%20created%20from%20the%20latest%20state%20of%20the%20default%20branch.) - [Title will automatically be created based on the tag](https://cli.github.com/manual/gh_release_create#:~:text=When%20using%20automatically%20generated%20release%20notes%2C%20a%20release%20title%20will%20also%20be%20automatically%20generated%20unless%20a%20title%20was%20explicitly%20passed.%20Additional%20release%20notes%20can%20be%20prepended%20to%20automatically%20generated%20notes%20by%20using%20the%20%2D%2Dnotes%20flag.) ## Related Issue Fixes #3103 ## Acceptance Criteria - [x] Release notes contain the title and description for each merged pull request included in the release - [x] Pull requests that have been closed but not merged are not included in the release notes ## Additional Information Example of what `gh release create 0.0.2 --generate-notes` will create: ![image](https://github.com/user-attachments/assets/d41ce1d8-bf95-4dab-a096-b8785969447c) ## Checklist - [ ] If this code affects the other scrum team, have they been notified? (In Slack, as reviewers, etc.) [//]: # "PR title: Remember to name your PR descriptively!" --- .github/workflows/createNewRelease.yaml | 40 ++----------------------- 1 file changed, 3 insertions(+), 37 deletions(-) diff --git a/.github/workflows/createNewRelease.yaml b/.github/workflows/createNewRelease.yaml index 029da25b40..1df9f81b85 100644 --- a/.github/workflows/createNewRelease.yaml +++ b/.github/workflows/createNewRelease.yaml @@ -63,46 +63,12 @@ jobs: run: | VERSION_WITH_PHDI=$(poetry version) echo "version=${VERSION_WITH_PHDI:5}" >> $GITHUB_OUTPUT - # Create new release tag - - name: Set up Git user - run: | - git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" - - name: Tag Release - uses: EndBug/latest-tag@latest - with: - ref: ${{ steps.get_version.outputs.version }} - # Generate release notes - - name: Generate release notes - id: release_notes + - name: Create release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ steps.get_version.outputs.version }} run: | - latest_release_date=$(gh api "/repos/$GITHUB_REPOSITORY/releases?per_page=1" | jq ".[0].created_at") - prs=$(gh pr list --base main --state closed --json title,number,url,closedAt -q ".[] | select(.closedAt > $latest_release_date) | select(.title | contains(\"RELEASE\") | not)") - - echo "# Release Notes" > release-notes.md - echo "" >> release-notes.md - echo "" >> release-notes.md - - while IFS= read -r pr; do - pr_title=$(echo "$pr" | jq -r ".title") - pr_number=$(echo "$pr" | jq -r ".number") - pr_url=$(echo "$pr" | jq -r ".url") - line_text="- $pr_title ([#$pr_number]($pr_url))" - echo $line_text >> release-notes.md - done < <(printf '%s' "$prs") - - # Create new release based upon the latest created tag - - name: Create Release - id: create_release - uses: actions/create-release@v1.1.4 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ steps.get_version.outputs.version }} - release_name: ${{ steps.get_version.outputs.version }} - body_path: release-notes.md + gh release create "$tag" --generate-notes release-to-pypi: name: Build and publish PHDI to PyPI