78 lines
3.2 KiB
YAML
78 lines
3.2 KiB
YAML
name: Build Bifrost
|
|
|
|
on:
|
|
push:
|
|
branches: ["**"]
|
|
tags: ["v*.*.*"]
|
|
pull_request:
|
|
types: [opened, synchronize, reopened, closed]
|
|
workflow_dispatch:
|
|
inputs:
|
|
revision:
|
|
description: "Optional version override for a manual build"
|
|
required: false
|
|
|
|
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
|
|
with:
|
|
fetch-depth: 0
|
|
- name: Set up pinned Java
|
|
uses: actions/setup-java@v4.7.1
|
|
with:
|
|
distribution: temurin
|
|
java-version: "17.0.13+11"
|
|
cache: maven
|
|
- name: Calculate project version
|
|
id: version
|
|
run: |
|
|
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 }}
|
|
- name: Validate changelog on pull requests
|
|
if: github.event_name == 'pull_request'
|
|
run: |
|
|
sh scripts/check-changelog.sh
|
|
echo "Changelog preview:"
|
|
awk '/^## \[Unreleased\]$/ {show=1; next} /^## \[/ {show=0} show {print}' CHANGELOG.md
|
|
- name: Build and run unit tests
|
|
env:
|
|
BUILD_REVISION: ${{ steps.version.outputs.revision }}
|
|
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'
|
|
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'
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
|
GITEA_REPOSITORY: ${{ github.repository }}
|
|
GITEA_SERVER_URL: ${{ github.server_url }}
|
|
GITEA_MAIN_BRANCH: main
|
|
RELEASE_VERSION: ${{ steps.version.outputs.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"
|