-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
211 SIM-OPS-Generate PR from staging to main with changelog #335
Changes from all commits
b390ac0
84df2eb
6311804
f8e5e21
0498dfa
5768419
5e2871c
e60eced
4b12c1e
b522899
dda43df
394b958
9c5b88e
9aab6e0
a8eacdd
057e8c5
f5ce388
bda7587
e483c63
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: Changelog | ||
on: | ||
push: | ||
branches: | ||
- release-* | ||
|
||
jobs: | ||
release-notes-pr: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
steps: | ||
- name: Extract branch | ||
id: extract_branch | ||
run: echo "branch=${GITHUB_REF#refs/heads/}" >> "$GITHUB_OUTPUT" | ||
env: | ||
GITHUB_REF: ${{ github.ref_name }} | ||
|
||
- name: Extract tag from branch name | ||
id: extract_tag | ||
run: echo "tag=${BRANCH#release-}" >> "$GITHUB_OUTPUT" | ||
env: | ||
BRANCH: ${{ steps.extract_branch.outputs.branch }} | ||
|
||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Get latest release | ||
id: get_latest_release | ||
run: | | ||
latest_release=$(gh release view --json tagName --jq .tagName) | ||
echo $latest_release | ||
echo "tag=$latest_release" >> "$GITHUB_OUTPUT" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Generate release notes | ||
id: generate_release_notes | ||
# https://docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28#generate-release-notes-content-for-a-release | ||
run: | | ||
response=$(curl -L \ | ||
-X POST \ | ||
-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/yeagerai/genlayer-simulator/releases/generate-notes \ | ||
-d '{"tag_name":"${{ steps.extract_tag.outputs.tag }}","target_commitish":"${{ steps.extract_branch.outputs.branch }}","previous_tag_name":"${{ steps.get_latest_release.outputs.tag}}"}' ) | ||
echo $response | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you use https://github.com/marketplace/actions/release-notes-generator instead of this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. First time I see that one, but I've researched a lot about tools to automate this and I didn't find anyone that would satisfy our needs. All of them had little to no flexibility to customize them. For example, the one you are sharing here only works with "milestones" Do you know how to use it for this use case? |
||
# Multi line output https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#example-of-a-multiline-string | ||
{ | ||
echo 'notes<<EOF' | ||
echo $response | jq -r -e .body | ||
echo EOF | ||
} >> "$GITHUB_OUTPUT" | ||
|
||
- name: Create pull request | ||
id: create_pull_request | ||
run: | | ||
gh pr create --title "Release ${{ steps.extract_tag.outputs.tag }}" --body "${{ steps.generate_release_notes.outputs.notes }}" --base main --head ${{ steps.extract_branch.outputs.branch }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if this curl command will fail from some rate-limiting rule? How to handle such errors?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This hasn't failed for me in my tests. I think for now we can go forward by just retrying the action manually if it fails and addressing it in a fix PR. I don't think we should complicate it now :)