ci: publish release on merged pull requests
This commit is contained in:
1 parent
021281f3dd
commit
cd2a3a24f3
2 files changed
+11
-6
No files matched your search
@@ -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"
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in new issue
Block a user