Decreased version. Updated ci.yml #86
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Release version' | |
required: true | |
type: string | |
permissions: | |
actions: write | |
id-token: write | |
contents: write | |
concurrency: | |
# On master, we don't want any jobs cancelled so the sha is used to name the group | |
# On PR branches, we cancel the job if new commits are pushed | |
# More info: https://stackoverflow.com/a/68422069/253468 | |
group: ${{ (github.ref == 'refs/heads/master') && format('{0}-{1}', github.workflow_ref, github.sha) || format('{0}-{1}', github.workflow_ref, github.head_ref) }} | |
cancel-in-progress: true | |
env: | |
JAVA_VERSION: '21' | |
JAVA_DISTRO: 'adopt' | |
jobs: | |
determine-version: | |
runs-on: ubuntu-latest | |
outputs: | |
VERSION: ${{ steps.vars.outputs.VERSION }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Get or Set Version | |
id: vars | |
shell: bash | |
run: | | |
if [[ "${{ github.event_name }}" == "workflow_dispatch" && -n "${{ inputs.version }}" ]]; then | |
echo "Setting version from input: ${{ inputs.version }}" | |
echo "${{ inputs.version }}" > VERSION | |
sed -i "s/^version=.*/version=${{ inputs.version }}/" gradle.properties | |
git config --local user.email "action@github.com" | |
git config --local user.name "GitHub Action" | |
git commit -am "Set version to ${{ inputs.version }}" | |
git push origin main | |
VERSION=${{ inputs.version }} | |
else | |
VERSION=$(awk -F'=' '/^version=/ {print $2}' gradle.properties) | |
echo "Detected version: $VERSION" | |
fi | |
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
build: | |
needs: | |
- determine-version | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: main | |
fetch-depth: 0 | |
- name: Project Version | |
run: | | |
VERSION=$(awk -F'=' '/^version=/ {print $2}' gradle.properties) | |
echo "Project version: $VERSION" | |
- name: Setup Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: ${{ env.JAVA_DISTRO }} | |
java-version: ${{ env.JAVA_VERSION }} | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@v4 | |
- name: Cache SonarCloud packages | |
uses: actions/cache@v4 | |
with: | |
path: ~/.sonar/cache | |
key: ${{ runner.os }}-sonar | |
restore-keys: ${{ runner.os }}-sonar | |
- name: Build with Gradle | |
run: ./gradlew -q --no-daemon --scan build | |
- name: Publish Test Report | |
uses: mikepenz/action-junit-report@v4 | |
if: success() || failure() | |
with: | |
report_paths: '**/build/test-results/test/TEST-*.xml' | |
- name: Sonar | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
if: ${{ !cancelled() && env.SONAR_TOKEN != '' }} | |
run: ./gradlew sonar -Dsonar.gradle.skipCompile=true | |
release: | |
if: github.event_name != 'pull_request' | |
needs: | |
- determine-version | |
- build | |
runs-on: ubuntu-latest | |
env: | |
JRELEASER_PROJECT_VERSION: ${{ needs.determine-version.outputs.VERSION }} | |
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
JRELEASER_GPG_PASSPHRASE: ${{ secrets.JRELEASER_GPG_PASSPHRASE }} | |
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.JRELEASER_GPG_PUBLIC_KEY }} | |
JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_GPG_SECRET_KEY }} | |
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.JRELEASER_MAVENCENTRAL_USERNAME }} | |
JRELEASER_MAVENCENTRAL_TOKEN: ${{ secrets.JRELEASER_MAVENCENTRAL_TOKEN }} | |
USERNAME: ${{ secrets.USERNAME }} | |
TOKEN: ${{ secrets.TOKEN }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: main | |
fetch-depth: 0 | |
- name: Project Version | |
run: | | |
VERSION=$(awk -F'=' '/^version=/ {print $2}' gradle.properties) | |
echo "Project version: $VERSION" | |
- name: Setup Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: ${{ env.JAVA_DISTRO }} | |
java-version: ${{ env.JAVA_VERSION }} | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@v4 | |
- name: Publish with Gradle | |
run: ./gradlew -q --no-daemon --scan publish | |
- name: Release with Gradle | |
run: ./gradlew -q --no-daemon --scan jreleaserFullRelease --no-configuration-cache --full-stacktrace |