From 42ed85c9b68062c3f79229147fd579eec75fa5bd Mon Sep 17 00:00:00 2001 From: Tako Schotanus Date: Tue, 27 Oct 2026 10:39:16 +0100 Subject: [PATCH] ci: fix the release workflow and update pom.xml --- .github/workflows/release.yml | 33 +++++++++++++++++++++++++++++++++ RELEASE.md | 19 ++++++++++++++++--- pom.xml | 2 +- 3 files changed, 50 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bbed6cf..1c6fe2e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -59,6 +59,39 @@ jobs: JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.MAVENCENTRAL_USERNAME }} JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.MAVENCENTRAL_PASSWORD }} + - name: Prepare next development iteration + env: + DEVELOPMENT_BRANCH: ${{ github.ref_type == 'branch' && github.ref_name || github.event.repository.default_branch }} + run: | + ./mvnw -B versions:set -DnextSnapshot=true -DgenerateBackupPoms=false + NEXT_POM="$RUNNER_TEMP/next-development-pom.xml" + cp pom.xml "$NEXT_POM" + git restore -- pom.xml + git fetch origin "refs/heads/$DEVELOPMENT_BRANCH" + if ! git merge-base --is-ancestor HEAD FETCH_HEAD; then + echo "The released commit is not on $DEVELOPMENT_BRANCH; update its development version manually." + exit 1 + fi + if ! git diff --quiet HEAD FETCH_HEAD -- pom.xml; then + if git show FETCH_HEAD:pom.xml | cmp -s - "$NEXT_POM"; then + echo "The next development version is already committed." + exit 0 + fi + echo "pom.xml changed since the released commit; update its development version manually." + exit 1 + fi + git checkout --detach FETCH_HEAD + cp "$NEXT_POM" pom.xml + if git diff --quiet -- pom.xml; then + echo "The next development version is already committed." + exit 0 + fi + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git add -- pom.xml + git commit -m "chore: prepare next development iteration after $JRELEASER_PROJECT_VERSION" + git push origin "HEAD:refs/heads/$DEVELOPMENT_BRANCH" + - name: JReleaser release output if: always() uses: actions/upload-artifact@v7 diff --git a/RELEASE.md b/RELEASE.md index 06b1f80..ff1817d 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -18,7 +18,7 @@ Releases are published to GitHub and Maven Central by JReleaser from a version t 2. Select **Release** in the workflow list. 3. Click **Run workflow**. 4. Leave the branch set to `main` and enter the release version without a leading - `v`, for example `0.0.8`. + `v`, for example `0.1.1`. 5. Click **Run workflow** to start the release. 6. Open the newly created workflow run and wait for the `release` job to complete. 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. 2. Create and push an annotated tag whose name is the release version, for example: ```shell - git tag -a v0.0.8 -m "Release v0.0.8" - git push origin v0.0.8 + git tag -a v0.1.1 -m "Release v0.1.1" + git push origin v0.1.1 ``` 3. The `Release` workflow sets the Maven version from the tag, builds the sources and Javadoc artifacts, and runs JReleaser. 4. Verify the GitHub release and the published component on Maven Central. +After a successful release, the workflow increments the patch version, appends +`-SNAPSHOT`, and commits and pushes `pom.xml` for the next development iteration. +For example, releasing `0.1.1` prepares `0.1.2-SNAPSHOT`. Manual releases update the +selected branch; tag releases update the repository's default branch, which must +contain the tagged commit. The workflow token needs permission to push to that +branch under its branch protection rules. + +The workflow preserves newer branch commits and skips an already committed version +bump. If `pom.xml` has otherwise changed since the released commit, or the branch +advances during the push, the preparation step fails without overwriting those +changes. In that case, update and commit the next development version manually; +the published release is already complete. + ## Local Configuration Check This validates the JReleaser configuration without publishing anything: diff --git a/pom.xml b/pom.xml index cd58858..bba2a79 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.codejive java-properties - 0.0.9-SNAPSHOT + 0.1.1-SNAPSHOT Java Properties parser A simple Java Properties parser that retains the exact format of the input file, including any comments