Skip to content

Commit

Permalink
feat: new ways to write release notes
Browse files Browse the repository at this point in the history
  • Loading branch information
wphyojpl committed Sep 18, 2024
1 parent 7aed565 commit 6387e7f
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 7 deletions.
12 changes: 12 additions & 0 deletions .ci/catchup_pr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

echo "setting email and name config"
git config --local user.email "wai.phyo@jpl.nasa.gov"
git config --local user.name ${GITHUB_TRIGGERING_ACTOR}


echo "creating PR"
result=`gh pr create --base "develop" --body "NA" --head "main" --title "chore: catchup from main"`
echo "PR result $result"
pr_number=`echo $result | grep -oE '[0-9]+$'`
echo "PR number ${pr_number}"
47 changes: 44 additions & 3 deletions .ci/update_setup_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,50 @@ def update_change_log(self):
change_log_file.write(change_logs)
return

def generate_release_msg(self):
software_version = os.environ.get('software_version', '')
if software_version == '':
raise ValueError(f'missing software_version')
release_lines = {
'Added': ['### Added'],
'Fixed': ['### Fixed'],
'Changed': ['### Changed'],
}
change_log_path = os.path.join(self.root_dir, 'CHANGELOG.md')
with open(change_log_path, 'r') as ff:
all_lines = ff.read().splitlines()
i = 0
while i < len(all_lines):
if f'{software_version}.dev' not in all_lines[i]:
i += 1
continue
release_lines[all_lines[i+1].replace('###', '').strip()].append(all_lines[i+2])
i += 3

message = [
f'Link: https://pypi.org/project/mdps-ds-lib/{software_version}/',
'',
'Changes in this release:',
''
] + \
(release_lines['Added'] if len(release_lines['Added']) > 1 else []) + \
(release_lines['Fixed'] if len(release_lines['Fixed']) > 1 else []) + \
(release_lines['Changed'] if len(release_lines['Changed']) > 1 else [])
message = '\n'.join(message)
release_path = os.path.join(self.root_dir, 'release_body.txt')
with open(release_path, 'w') as f:
f.write(message)
return message


if __name__ == '__main__':
is_releasing = argv[1].strip().upper() == 'RELEASE'
arg1 = argv[1].strip().upper()
version_update = VersionUpdate()
new_version_from_setup = version_update.update_version(is_releasing)
version_update.update_change_log()
if arg1 == 'RELEASE_BODY':
new_version_from_setup = version_update.generate_release_msg()
elif argv[1].strip().upper() == 'RELEASE':
new_version_from_setup = version_update.update_version(True)
version_update.update_change_log()
else:
new_version_from_setup = version_update.update_version(False)
version_update.update_change_log()
17 changes: 13 additions & 4 deletions .github/workflows/feature_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,25 @@ jobs:
run: |
python3 -m twine upload --repository pypi dist/*
- name: MAIN -- Catch up PR
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' && contains(github.event.pull_request.title, 'update version + change log')
run: |
chmod +x "${GITHUB_WORKSPACE}/.ci/catchup_pr.sh"
"${GITHUB_WORKSPACE}/.ci/catchup_pr.sh"
- name: MAIN -- Upload to PyPI
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' && contains(github.event.pull_request.title, 'update version + change log')
run: |
# make file runnable, might not be necessary
chmod +x "${GITHUB_WORKSPACE}/.ci/store_version.sh"
"${GITHUB_WORKSPACE}/.ci/store_version.sh"
- name: MAIN -- Create Release Body
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' && contains(github.event.pull_request.title, 'update version + change log')
run: |
python3 "${GITHUB_WORKSPACE}/.ci/update_setup_version.py" RELEASE_BODY
- name: MAIN -- Create Release
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' && contains(github.event.pull_request.title, 'update version + change log')
id: create_release
Expand All @@ -111,9 +123,6 @@ jobs:
with:
tag_name: "v${{ env.software_version }}"
release_name: "Release v${{ env.software_version }} - ${{ github.ref }}"
body: |
Changes in this release:
${{ github.event.head_commit.message }}
body_path: release.md
body_path: ./release_body.txt
draft: false
prerelease: false

0 comments on commit 6387e7f

Please sign in to comment.