Skip to content

Commit

Permalink
ci: update release job to automatically generate release notes (#3187)
Browse files Browse the repository at this point in the history
# 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!"
  • Loading branch information
BobanL authored Jan 23, 2025
1 parent 45f437a commit 44bc4b0
Showing 1 changed file with 3 additions and 37 deletions.
40 changes: 3 additions & 37 deletions .github/workflows/createNewRelease.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 44bc4b0

Please # to comment.