From cd2a3a24f3c4c1709873dc712748ffe7291ce327 Mon Sep 17 00:00:00 2001 From: Arnaud Dartois Date: Fri, 6 Nov 2026 08:40:14 +0100 Subject: [PATCH] ci: publish release on merged pull requests --- .gitea/workflows/build.yml | 15 ++++++++++----- README.md | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index d6bd288..9874477 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -5,6 +5,7 @@ on: branches: ["**"] tags: ["v*.*.*"] pull_request: + types: [opened, synchronize, reopened, closed] workflow_dispatch: inputs: revision: @@ -14,6 +15,7 @@ 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 @@ -54,19 +56,22 @@ jobs: path: target/sonar-bifrost-plugin-${{ steps.version.outputs.revision }}.jar if-no-files-found: error - name: Build release version - if: github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.version.outputs.release_needed == 'true' && !contains(github.event.head_commit.message, 'chore(release):') + if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' 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 == 'push' && github.ref == 'refs/heads/main' && steps.version.outputs.release_needed == 'true' && !contains(github.event.head_commit.message, 'chore(release):') + if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' env: GITEA_TOKEN: ${{ secrets.RELEASE_TOKEN }} - GITEA_API_URL: ${{ vars.GITEA_API_URL }} GITEA_REPOSITORY: ${{ github.repository }} - GITEA_REPOSITORY_URL: ${{ vars.GITEA_REPOSITORY_URL }} + GITEA_SERVER_URL: ${{ github.server_url }} GITEA_MAIN_BRANCH: main RELEASE_VERSION: ${{ steps.version.outputs.release_version }} - run: sh scripts/release.sh "$RELEASE_VERSION" + run: | + export GITEA_API_URL="${GITEA_SERVER_URL%/}/api/v1" + export GITEA_REPOSITORY_URL="${GITEA_SERVER_URL%/}/${GITEA_REPOSITORY}" + git remote set-url origin "${GITEA_REPOSITORY_URL}.git" + sh scripts/release.sh "$RELEASE_VERSION" diff --git a/README.md b/README.md index 220bf78..10bad8b 100644 --- a/README.md +++ b/README.md @@ -114,7 +114,7 @@ Edit the `[Unreleased]` entries by hand before release when generated wording ne 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. -Configure repository variable `GITEA_API_URL` (for example, `https://gitea.example/api/v1`), repository variable `GITEA_REPOSITORY_URL` (the repository web URL), and secret `RELEASE_TOKEN`. 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 action sources (`actions/checkout`, `actions/setup-java`, `actions/upload-artifact`); an isolated act_runner may need those repositories mirrored or outbound GitHub access. ## Skills