From 653d380797e154b9e4db226dcc9859d2ddc0d95b Mon Sep 17 00:00:00 2001 From: Arnaud Dartois Date: Fri, 6 Nov 2026 08:57:42 +0100 Subject: [PATCH] fix(ci): publish releases from main pushes --- .claude/skills/gitea-actions-ci/SKILL.md | 2 +- .../skills/release-versioning-changelog/SKILL.md | 2 +- .gitea/workflows/build.yml | 14 +++----------- README.md | 4 ++-- scripts/version.sh | 3 +++ 5 files changed, 10 insertions(+), 15 deletions(-) diff --git a/.claude/skills/gitea-actions-ci/SKILL.md b/.claude/skills/gitea-actions-ci/SKILL.md index f6fe4a6..143247f 100644 --- a/.claude/skills/gitea-actions-ci/SKILL.md +++ b/.claude/skills/gitea-actions-ci/SKILL.md @@ -8,7 +8,7 @@ description: Use when creating or changing CI workflows, artifact upload, releas - Fetch complete history and tags before version calculation (`fetch-depth: 0` where supported). - Pin actions to immutable commits or exact versions and document when a mirror is required; act_runner compatibility must be checked. - Cache Maven dependencies without caching secrets. Never put tokens in command output. -- Gate release on push to the configured main branch, version script release-needed output, and a workflow-generated-commit guard. Do not rely only on `[skip ci]`. +- Gate release on pushes to the configured main branch and a workflow-generated-commit guard. For this repository, every main-branch merge creates a release; Conventional Commits choose the major/minor/patch bump and other types default to patch. - Update changelog, commit, tag that commit, push commit and tag, then create Gitea release from the exact changelog section. - Use repository secrets for API credentials; describe branch protection permissions required for the release identity. - Avoid release loops by checking actor/commit marker and tag state. diff --git a/.claude/skills/release-versioning-changelog/SKILL.md b/.claude/skills/release-versioning-changelog/SKILL.md index 39ac82c..498576e 100644 --- a/.claude/skills/release-versioning-changelog/SKILL.md +++ b/.claude/skills/release-versioning-changelog/SKILL.md @@ -5,7 +5,7 @@ description: Use when changing semantic version calculation, release automation, # Release versioning and changelog - Treat `vMAJOR.MINOR.PATCH` Git tags as the sole release version source. -- Parse commits since the latest reachable version tag: breaking change or `!` bumps major; `feat` bumps minor; `fix`, `perf`, and `refactor` bump patch; other types do not request release. +- Parse commits since the latest reachable version tag: breaking change or `!` bumps major; `feat` bumps minor; `fix`, `perf`, and `refactor` bump patch. For this repository every merge to `main` releases, so other commit types default to a patch bump. - Use a valid plugin manifest version format; keep snapshot metadata out of release tags. - Keep `CHANGELOG.md` in Keep a Changelog 1.1.0 structure, newest first, with only Added, Changed, Deprecated, Removed, Fixed, and Security categories. - Never invent a user-facing changelog detail from an unclear commit. Allow maintainers to edit generated entries before release. diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 9874477..cd73bbe 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -5,7 +5,7 @@ on: branches: ["**"] tags: ["v*.*.*"] pull_request: - types: [opened, synchronize, reopened, closed] + types: [opened, synchronize, reopened] workflow_dispatch: inputs: revision: @@ -15,7 +15,6 @@ on: jobs: build: runs-on: ubuntu-latest - if: github.event_name != 'pull_request' || github.event.action != 'closed' || github.event.pull_request.merged == true steps: - name: Checkout full history and tags uses: actions/checkout@v4.2.2 @@ -33,7 +32,6 @@ jobs: revision=$(sh scripts/version.sh) if [ -n "$REVISION_OVERRIDE" ]; then revision="$REVISION_OVERRIDE"; fi echo "revision=$revision" >> "$GITHUB_OUTPUT" - echo "release_needed=$(sh scripts/version.sh --release-needed)" >> "$GITHUB_OUTPUT" echo "release_version=$(sh scripts/version.sh --next-release)" >> "$GITHUB_OUTPUT" env: REVISION_OVERRIDE: ${{ github.event.inputs.revision }} @@ -49,21 +47,15 @@ jobs: run: | sh scripts/render-readme.sh "$BUILD_REVISION" sh ./mvnw -B -Drevision="$BUILD_REVISION" verify - - name: Upload plugin JAR - uses: actions/upload-artifact@v4.6.2 - with: - name: sonar-bifrost-plugin-${{ steps.version.outputs.revision }} - path: target/sonar-bifrost-plugin-${{ steps.version.outputs.revision }}.jar - if-no-files-found: error - name: Build release version - if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' + if: github.event_name == 'push' && github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, 'chore(release):') env: RELEASE_VERSION: ${{ steps.version.outputs.release_version }} run: | sh scripts/render-readme.sh "$RELEASE_VERSION" sh ./mvnw -B -Drevision="$RELEASE_VERSION" verify - name: Create release commit, tag, and Gitea release - if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' + if: github.event_name == 'push' && github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, 'chore(release):') env: GITEA_TOKEN: ${{ secrets.RELEASE_TOKEN }} GITEA_REPOSITORY: ${{ github.repository }} diff --git a/README.md b/README.md index 10bad8b..2ec0d54 100644 --- a/README.md +++ b/README.md @@ -112,9 +112,9 @@ Edit the `[Unreleased]` entries by hand before release when generated wording ne ## CI and releases -The Gitea Actions workflow checks out full history/tags, installs Java 17, calculates a version, validates changelog formatting on pull requests, runs Maven verification, and uploads the JAR. On a main-branch push, a release commit/tag and Gitea release are created when Conventional Commits request a bump. +The Gitea Actions workflow checks out full history/tags, installs Java 17, calculates a version, validates changelog formatting on pull requests, and runs Maven verification. A push to `main` (normally a merged PR) creates a changelog release commit, version tag, and Gitea release with the built JAR attached. Conventional Commit types select major, minor, or patch bumps; other commit types default to a patch so every merge produces a new release. The release commit is excluded from triggering another release. -Configure the repository secret `RELEASE_TOKEN`. The workflow derives the Gitea API and repository URLs from `github.server_url` and `github.repository`, so no `GITEA_*` repository variables are needed. The token needs repository write access to push the changelog commit/tag and create a release with an asset. For protected branches, allow this token identity to push the release commit to `main`, or use a dedicated release branch and adjust `GITEA_MAIN_BRANCH`. Actions use GitHub-hosted action sources (`actions/checkout`, `actions/setup-java`, `actions/upload-artifact`); an isolated act_runner may need those repositories mirrored or outbound GitHub access. +Configure the repository secret `RELEASE_TOKEN`. The workflow derives the Gitea API and repository URLs from `github.server_url` and `github.repository`, so no `GITEA_*` repository variables are needed. The token needs repository write access to push the changelog commit/tag and create a release with an asset. For protected branches, allow this token identity to push the release commit to `main`, or use a dedicated release branch and adjust `GITEA_MAIN_BRANCH`. Actions use GitHub-hosted sources (`actions/checkout`, `actions/setup-java`); an isolated act_runner may need those repositories mirrored or outbound GitHub access. ## Skills diff --git a/scripts/version.sh b/scripts/version.sh index b3b3f19..d6be0d4 100644 --- a/scripts/version.sh +++ b/scripts/version.sh @@ -45,6 +45,9 @@ case "$bump" in 2) minor=$((minor + 1)); patch=0 ;; 1) patch=$((patch + 1)) ;; esac +if [ "${1:-}" = "--next-release" ] && [ "$bump" -eq 0 ]; then + patch=$((patch + 1)) +fi next="$major.$minor.$patch" case "${1:-}" in -- 2.54.1