Files
Bifrost/.gitea/workflows/build.yml
T

73 lines
2.9 KiB
YAML

name: Build Bifrost
on:
push:
branches: ["**"]
tags: ["v*.*.*"]
pull_request:
workflow_dispatch:
inputs:
revision:
description: "Optional version override for a manual build"
required: false
jobs:
build:
runs-on: ubuntu-latest
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 == 'push' && github.ref == 'refs/heads/main' && steps.version.outputs.release_needed == 'true' && !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 == 'push' && github.ref == 'refs/heads/main' && steps.version.outputs.release_needed == 'true' && !contains(github.event.head_commit.message, 'chore(release):')
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_MAIN_BRANCH: main
RELEASE_VERSION: ${{ steps.version.outputs.release_version }}
run: sh scripts/release.sh "$RELEASE_VERSION"