Skip to content

Commit 4494968

Browse files
authored
Merge pull request #36 from unity-sds/develop
RELEASE
2 parents cac5341 + 2991b46 commit 4494968

File tree

5 files changed

+73
-8
lines changed

5 files changed

+73
-8
lines changed

.ci/catchup_pr.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
echo "setting email and name config"
4+
git config --local user.email "wai.phyo@jpl.nasa.gov"
5+
git config --local user.name ${GITHUB_TRIGGERING_ACTOR}
6+
7+
8+
echo "creating PR"
9+
result=`gh pr create --base "develop" --body "NA" --head "main" --title "chore: catchup from main"`
10+
echo "PR result $result"
11+
pr_number=`echo $result | grep -oE '[0-9]+$'`
12+
echo "PR number ${pr_number}"

.ci/update_setup_version.py

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,50 @@ def update_change_log(self):
107107
change_log_file.write(change_logs)
108108
return
109109

110+
def generate_release_msg(self):
111+
software_version = os.environ.get('software_version', '')
112+
if software_version == '':
113+
raise ValueError(f'missing software_version')
114+
release_lines = {
115+
'Added': ['### Added'],
116+
'Fixed': ['### Fixed'],
117+
'Changed': ['### Changed'],
118+
}
119+
change_log_path = os.path.join(self.root_dir, 'CHANGELOG.md')
120+
with open(change_log_path, 'r') as ff:
121+
all_lines = ff.read().splitlines()
122+
i = 0
123+
while i < len(all_lines):
124+
if f'{software_version}.dev' not in all_lines[i]:
125+
i += 1
126+
continue
127+
release_lines[all_lines[i+1].replace('###', '').strip()].append(all_lines[i+2])
128+
i += 3
129+
130+
message = [
131+
f'Link: https://pypi.org/project/mdps-ds-lib/{software_version}/',
132+
'',
133+
'Changes in this release:',
134+
''
135+
] + \
136+
(release_lines['Added'] if len(release_lines['Added']) > 1 else []) + \
137+
(release_lines['Fixed'] if len(release_lines['Fixed']) > 1 else []) + \
138+
(release_lines['Changed'] if len(release_lines['Changed']) > 1 else [])
139+
message = '\n'.join(message)
140+
release_path = os.path.join(self.root_dir, 'release_body.txt')
141+
with open(release_path, 'w') as f:
142+
f.write(message)
143+
return message
144+
110145

111146
if __name__ == '__main__':
112-
is_releasing = argv[1].strip().upper() == 'RELEASE'
147+
arg1 = argv[1].strip().upper()
113148
version_update = VersionUpdate()
114-
new_version_from_setup = version_update.update_version(is_releasing)
115-
version_update.update_change_log()
149+
if arg1 == 'RELEASE_BODY':
150+
new_version_from_setup = version_update.generate_release_msg()
151+
elif argv[1].strip().upper() == 'RELEASE':
152+
new_version_from_setup = version_update.update_version(True)
153+
version_update.update_change_log()
154+
else:
155+
new_version_from_setup = version_update.update_version(False)
156+
version_update.update_change_log()

.github/workflows/feature_pr.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,25 @@ jobs:
9595
run: |
9696
python3 -m twine upload --repository pypi dist/*
9797
98+
- name: MAIN -- Catch up PR
99+
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' && contains(github.event.pull_request.title, 'update version + change log')
100+
run: |
101+
chmod +x "${GITHUB_WORKSPACE}/.ci/catchup_pr.sh"
102+
"${GITHUB_WORKSPACE}/.ci/catchup_pr.sh"
103+
104+
98105
- name: MAIN -- Upload to PyPI
99106
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' && contains(github.event.pull_request.title, 'update version + change log')
100107
run: |
101108
# make file runnable, might not be necessary
102109
chmod +x "${GITHUB_WORKSPACE}/.ci/store_version.sh"
103110
"${GITHUB_WORKSPACE}/.ci/store_version.sh"
104111
112+
- name: MAIN -- Create Release Body
113+
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' && contains(github.event.pull_request.title, 'update version + change log')
114+
run: |
115+
python3 "${GITHUB_WORKSPACE}/.ci/update_setup_version.py" RELEASE_BODY
116+
105117
- name: MAIN -- Create Release
106118
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' && contains(github.event.pull_request.title, 'update version + change log')
107119
id: create_release
@@ -111,9 +123,6 @@ jobs:
111123
with:
112124
tag_name: "v${{ env.software_version }}"
113125
release_name: "Release v${{ env.software_version }} - ${{ github.ref }}"
114-
body: |
115-
Changes in this release:
116-
${{ github.event.head_commit.message }}
117-
body_path: release.md
126+
body_path: ./release_body.txt
118127
draft: false
119128
prerelease: false

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.4.0.dev000200] - 2024-09-18
9+
### Changed
10+
- [#34](https://github.com/unity-sds/unity-data-services/pull/34) feat: new ways to write release notes
811

912
## [0.4.0] - 2024-09-18
1013

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "mdps-ds-lib"
3-
version="0.4.0"
3+
version="0.4.0.dev000200"
44
description = "Mission Data System - MDPS (Unity) Data Service Core library"
55
authors = ["Wai Phyo <wai.phyo@jpl.nasa.gov>"]
66
license = "Apache 2.0"

0 commit comments

Comments
 (0)