Skip to content

Commit 4453382

Browse files
committed
ci: fix the release workflow and update pom.xml
1 parent 6f40e0c commit 4453382

3 files changed

Lines changed: 50 additions & 4 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,39 @@ jobs:
5959
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.MAVENCENTRAL_USERNAME }}
6060
JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.MAVENCENTRAL_PASSWORD }}
6161

62+
- name: Prepare next development iteration
63+
env:
64+
DEVELOPMENT_BRANCH: ${{ github.ref_type == 'branch' && github.ref_name || github.event.repository.default_branch }}
65+
run: |
66+
./mvnw -B versions:set -DnextSnapshot=true -DgenerateBackupPoms=false
67+
NEXT_POM="$RUNNER_TEMP/next-development-pom.xml"
68+
cp pom.xml "$NEXT_POM"
69+
git restore -- pom.xml
70+
git fetch origin "refs/heads/$DEVELOPMENT_BRANCH"
71+
if ! git merge-base --is-ancestor HEAD FETCH_HEAD; then
72+
echo "The released commit is not on $DEVELOPMENT_BRANCH; update its development version manually."
73+
exit 1
74+
fi
75+
if ! git diff --quiet HEAD FETCH_HEAD -- pom.xml; then
76+
if git show FETCH_HEAD:pom.xml | cmp -s - "$NEXT_POM"; then
77+
echo "The next development version is already committed."
78+
exit 0
79+
fi
80+
echo "pom.xml changed since the released commit; update its development version manually."
81+
exit 1
82+
fi
83+
git checkout --detach FETCH_HEAD
84+
cp "$NEXT_POM" pom.xml
85+
if git diff --quiet -- pom.xml; then
86+
echo "The next development version is already committed."
87+
exit 0
88+
fi
89+
git config user.name "github-actions[bot]"
90+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
91+
git add -- pom.xml
92+
git commit -m "chore: prepare next development iteration after $JRELEASER_PROJECT_VERSION"
93+
git push origin "HEAD:refs/heads/$DEVELOPMENT_BRANCH"
94+
6295
- name: JReleaser release output
6396
if: always()
6497
uses: actions/upload-artifact@v7

‎RELEASE.md‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Releases are published to GitHub and Maven Central by JReleaser from a version t
1818
2. Select **Release** in the workflow list.
1919
3. Click **Run workflow**.
2020
4. Leave the branch set to `main` and enter the release version without a leading
21-
`v`, for example `0.0.8`.
21+
`v`, for example `0.1.1`.
2222
5. Click **Run workflow** to start the release.
2323
6. Open the newly created workflow run and wait for the `release` job to complete.
2424
7. Open [github.com/codejive/java-properties/releases](https://github.com/codejive/java-properties/releases)
@@ -34,14 +34,27 @@ any required environment approval is granted.
3434
2. Create and push an annotated tag whose name is the release version, for example:
3535

3636
```shell
37-
git tag -a v0.0.8 -m "Release v0.0.8"
38-
git push origin v0.0.8
37+
git tag -a v0.1.1 -m "Release v0.1.1"
38+
git push origin v0.1.1
3939
```
4040

4141
3. The `Release` workflow sets the Maven version from the tag, builds the sources and
4242
Javadoc artifacts, and runs JReleaser.
4343
4. Verify the GitHub release and the published component on Maven Central.
4444

45+
After a successful release, the workflow increments the patch version, appends
46+
`-SNAPSHOT`, and commits and pushes `pom.xml` for the next development iteration.
47+
For example, releasing `0.1.1` prepares `0.1.2-SNAPSHOT`. Manual releases update the
48+
selected branch; tag releases update the repository's default branch, which must
49+
contain the tagged commit. The workflow token needs permission to push to that
50+
branch under its branch protection rules.
51+
52+
The workflow preserves newer branch commits and skips an already committed version
53+
bump. If `pom.xml` has otherwise changed since the released commit, or the branch
54+
advances during the push, the preparation step fails without overwriting those
55+
changes. In that case, update and commit the next development version manually;
56+
the published release is already complete.
57+
4558
## Local Configuration Check
4659
4760
This validates the JReleaser configuration without publishing anything:

‎pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>org.codejive</groupId>
66
<artifactId>java-properties</artifactId>
7-
<version>0.0.9-SNAPSHOT</version>
7+
<version>0.1.1-SNAPSHOT</version>
88

99
<name>Java Properties parser</name>
1010
<description>A simple Java Properties parser that retains the exact format of the input file, including any comments</description>

0 commit comments

Comments
 (0)