Skip to content

Commit 3d7ba53

Browse files
authored
Merge pull request #1124 from PhenoApps/changelog_xml_action
Include changelog.xml update in release action
2 parents 7748af6 + 91c399b commit 3d7ba53

File tree

2 files changed

+99
-24
lines changed

2 files changed

+99
-24
lines changed

.github/workflows/github-release.yml

+67-23
Original file line numberDiff line numberDiff line change
@@ -14,61 +14,74 @@ on:
1414
types: [trigger-release]
1515

1616
jobs:
17-
release:
17+
check-changes:
1818
runs-on: ubuntu-latest
19-
19+
outputs:
20+
release_required: ${{ steps.release-check.outputs.release_required }}
21+
bump_type: ${{ steps.release-check.outputs.bump_type }}
2022
steps:
21-
2223
- name: Checkout Repo
2324
uses: actions/checkout@v4
2425
with:
2526
token: ${{ secrets.ACTIONS_PAT }}
2627
fetch-depth: 0
2728

28-
- name: Determine Bump Type Based on Trigger
29-
id: determine-bump-type
29+
- name: Determine Release Type and Necessity
30+
id: release-check
3031
run: |
3132
if [ "${{ github.event_name }}" == "schedule" ]; then
3233
LAST_RELEASE_TAG=$(git describe --tags $(git rev-list --tags --max-count=1))
33-
echo "LAST_RELEASE_TAG was $LAST_RELEASE_TAG"
34+
echo "LAST_RELEASE_TAG: $LAST_RELEASE_TAG"
3435
3536
LAST_RELEASE_COMMIT=$(git rev-list -n 1 $LAST_RELEASE_TAG)
36-
echo "LAST_RELEASE_COMMIT was $LAST_RELEASE_COMMIT"
37+
echo "LAST_RELEASE_COMMIT: $LAST_RELEASE_COMMIT"
38+
3739
changed_files=$(git diff-tree --no-commit-id --name-only $LAST_RELEASE_COMMIT HEAD | grep '^app' || echo "none")
40+
echo "Changed files: $changed_files"
41+
3842
if [ "$changed_files" != "none" ]; then
3943
echo "App directory has changed since the last release, proceeding with new release"
44+
echo "release_required=true" >> $GITHUB_OUTPUT
45+
echo "bump_type=patch" >> $GITHUB_OUTPUT
4046
else
4147
echo "No app directory changes since the last release. Skipping release."
42-
exit 0
48+
echo "release_required=false" >> $GITHUB_OUTPUT
4349
fi
44-
BUMP_TYPE="patch"
4550
elif [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
46-
BUMP_TYPE="${{ github.event.inputs.bump_type }}"
51+
echo "release_required=true" >> $GITHUB_OUTPUT
52+
echo "bump_type=${{ github.event.inputs.bump_type }}" >> $GITHUB_OUTPUT
4753
elif [ "${{ github.event_name }}" == "repository_dispatch" ]; then
48-
BUMP_TYPE="${{ github.event.client_payload.bump_type }}"
54+
echo "release_required=true" >> $GITHUB_OUTPUT
55+
echo "bump_type=${{ github.event.client_payload.bump_type }}" >> $GITHUB_OUTPUT
4956
else
5057
echo "Unknown trigger source."
5158
exit 1
5259
fi
60+
release:
61+
runs-on: ubuntu-latest
62+
needs: check-changes
63+
if: needs.check-changes.outputs.release_required == 'true'
64+
steps:
5365

54-
if [[ ! "$BUMP_TYPE" =~ ^(major|minor|patch)$ ]]; then
55-
echo "Invalid bump type: $BUMP_TYPE"
56-
exit 1
57-
fi
58-
echo "BUMP_TYPE=$BUMP_TYPE" >> $GITHUB_ENV
66+
- name: Checkout Repo
67+
uses: actions/checkout@v4
68+
with:
69+
token: ${{ secrets.ACTIONS_PAT }}
70+
fetch-depth: 0
5971

6072
- name: Bump Version in version.properties
6173
id: bump-version
6274
run: |
63-
echo "Bumping version with BUMP_TYPE: $BUMP_TYPE"
75+
bump_type="${{ needs.check-changes.outputs.bump_type }}"
76+
echo "Bumping version with BUMP_TYPE: $bump_type"
6477
6578
source version.properties
6679
67-
if [ "$BUMP_TYPE" == "major" ]; then
80+
if [ "$bump_type" == "major" ]; then
6881
majorVersion=$((majorVersion + 1))
6982
minorVersion=0
7083
patchVersion=0
71-
elif [ "$BUMP_TYPE" == "minor" ]; then
84+
elif [ "$bump_type" == "minor" ]; then
7285
minorVersion=$((minorVersion + 1))
7386
patchVersion=0
7487
else
@@ -80,9 +93,42 @@ jobs:
8093
echo "patchVersion=$patchVersion" >> version.properties
8194
8295
VERSION=$majorVersion.$minorVersion.$patchVersion
96+
VERSION_CODE=$((majorVersion * 10000 + minorVersion * 100 + patchVersion))
8397
echo "VERSION=$VERSION" >> $GITHUB_ENV
98+
echo "VERSION_CODE=$VERSION_CODE" >> $GITHUB_ENV
8499
85-
- name: Process Changelog Changes
100+
- name: Update changelog.xml
101+
id: update-changelog-xml
102+
run: |
103+
104+
# Read the Unreleased section and process notes based on type
105+
RELEASE_CONTENT="" CURRENT_TYPE=""
106+
while IFS= read -r note; do
107+
if [[ "$note" == "### Added"* ]]; then
108+
CURRENT_TYPE="new"
109+
elif [[ "$note" == "### Changed"* ]]; then
110+
CURRENT_TYPE="info"
111+
elif [[ "$note" == "### Fixed"* ]]; then
112+
CURRENT_TYPE="bugfix"
113+
elif [[ "$note" =~ ^- ]]; then
114+
clean_note=$(echo "$note" | sed -E 's/^- //; s/ *\(.*\)//')
115+
RELEASE_CONTENT+=" <${CURRENT_TYPE}>${clean_note}</${CURRENT_TYPE}>\n"
116+
#pr_number=$(echo "$note" | grep -oP 'pull/\K[0-9]+' || echo "N/A")
117+
#RELEASE_CONTENT+=" <${CURRENT_TYPE}>${clean_note} (#${pr_number})</${CURRENT_TYPE}>\n"
118+
119+
fi
120+
done < <(sed -n '/## \[Unreleased\]/,/^## /p' CHANGELOG.md | sed '1,2d' | sed '$d')
121+
122+
# Generate, insert, and log the new release block
123+
today=$(date +'%Y-%m-%d')
124+
RELEASE_BLOCK=" <release date=\"$today\" versionCode=\"$VERSION_CODE\" versionName=\"v$VERSION\">\n"
125+
RELEASE_BLOCK+="$RELEASE_CONTENT"
126+
RELEASE_BLOCK+=" </release>"
127+
sed -i "/<changelog>/a \\\n$RELEASE_BLOCK" app/src/main/res/raw/changelog.xml
128+
echo "Generated release block:"
129+
echo -e "$RELEASE_BLOCK"
130+
131+
- name: Process CHANGELOG.md
86132
id: process-changelog
87133
run: |
88134
unreleased_section=$(sed -n '/## \[Unreleased\]/,/^## /p' CHANGELOG.md | sed '1,2d' | sed '$d')
@@ -149,9 +195,7 @@ jobs:
149195
if: ${{ success() }}
150196
uses: EndBug/add-and-commit@v7
151197
with:
152-
add: |
153-
version.properties
154-
CHANGELOG.md
198+
add: "version.properties CHANGELOG.md app/src/main/res/raw/changelog.xml"
155199
message: "Bump ${{ env.BUMP_TYPE }} and update changelog for v${{ env.VERSION }}"
156200
token: ${{ secrets.ACTIONS_PAT }}
157201

app/src/main/res/raw/changelog.xml

+32-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,38 @@
11
<changelog>
22

33
<release
4-
date="2024-12-01"
4+
date="2024-12-16"
5+
versionCode="60020"
6+
versionName="v6.0.2">
7+
<new>Trial name included in BrAPI import and field details page</new>
8+
<new>Image EXIF tag metadata includes the device pitch, roll, and yaw at the time of capture</new>
9+
<new>Setting added to reset preferences to default</new>
10+
<info>Fields with different BrAPI study IDs can now have the same name</info>
11+
<bugfix>Min and max values now correctly saved for BrAPI traits</bugfix>
12+
<bugfix>Label print observations are now assigned to the correct entry when navigating before the print is complete</bugfix>
13+
<bugfix>Improved database export messaging</bugfix>
14+
<bugfix>Go to ID dialog now has cursor focus when opened</bugfix>
15+
</release>
16+
17+
<release
18+
date="2024-12-09"
19+
versionCode="60010"
20+
versionName="v6.0.1">
21+
<new>Accession number now included for germplasm imported via BrAPI</new>
22+
<new>Option added at trait creation to keep keyboard closed when navigating to text traits</new>
23+
<new>Proximity check added to disable GeoNav when away from field</new>
24+
<new>Experimental setting to use media keys for entry/trait navigation and picture capture</new>
25+
<info>Fields and traits that have already been imported are now hidden on the BrAPI import screen</info>
26+
<info>Long-pressing delete button on bottom toolbar will remove all observations for that trait</info>
27+
<info>Current time now used as lastSyncedTime when downloading Observations via BrAPI</info>
28+
<info>lastSyncedTime updated after creating/updating Observations</info>
29+
<info>Improved support for BrAPI servers not using https</info>
30+
<bugfix>"observation_time_stamp" and "last_synced_time" now correctly saved in DAO</bugfix>
31+
<bugfix>Synced and updated records now correctly identified</bugfix>
32+
</release>
33+
34+
<release
35+
date="2024-12-02"
536
versionCode="60000"
637
versionName="v6.0">
738
<new>Fields list updated to include bulk actions and individual field pages</new>

0 commit comments

Comments
 (0)