Release #84
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: Release | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- '.github/actions/**' | |
- '**.md' | |
jobs: | |
# FETCH CURRENT PLUGIN VERSION | |
fetch-version: | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.get_version.outputs.version }} | |
release: ${{ steps.get_version.outputs.release }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Get Plugin Version | |
id: get_version | |
run: | | |
VERSION=$(grep "version" gradle.properties | cut -d'=' -f2) | |
echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then | |
echo "release=true" >> $GITHUB_OUTPUT | |
else | |
echo "release=false" >> $GITHUB_OUTPUT | |
fi | |
# Compiles all Gosu test projects using Java 11 beforehand. | |
# By leveraging Gradle cache, this enabled us to run integration tests of Gosu projects against Sonarqube Server | |
# with versions running on Java 17. | |
# This is necessary UNTIL Gosu supports Java 17. | |
prep-integration-tests: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
java: | |
- 11 | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up JDK ${{ matrix.java }} | |
uses: actions/setup-java@v3 | |
with: | |
java-version: ${{ matrix.java }} | |
distribution: temurin | |
cache: 'gradle' | |
- name: Cache Gradle packages | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: integration-tests-${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
integration-tests-${{ runner.os }}-gradle | |
- name: Compile Test Projects | |
run: | | |
cd src/testIntegration/resources | |
./compile-projects.sh | |
integration-tests: | |
needs: [prep-integration-tests] | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
include: | |
# previous LTS version | |
- SONAR_SERVER_VERSION: 8.9.10 | |
SONAR_WS_VERSION: 8.9.9.56886 | |
SONAR_PLUGIN_API_VERSION: 6.7.7 | |
SONAR_JAVA_VERSION: 7.11.0.29148 | |
SONAR_SERVER_JAVA_VERSION: 11 | |
- SONAR_SERVER_VERSION: 9.7.0 | |
SONAR_WS_VERSION: 8.9.9.56886 | |
SONAR_PLUGIN_API_VERSION: 6.7.7 | |
SONAR_JAVA_VERSION: 7.13.0.29990 | |
SONAR_SERVER_JAVA_VERSION: 11 | |
# current LTS version | |
- SONAR_SERVER_VERSION: 9.9.0 | |
SONAR_WS_VERSION: 8.9.9.56886 | |
SONAR_PLUGIN_API_VERSION: 6.7.7 | |
SONAR_JAVA_VERSION: 7.13.0.29990 | |
SONAR_SERVER_JAVA_VERSION: 17 | |
- SONAR_SERVER_VERSION: 10.0.0 | |
SONAR_WS_VERSION: 8.9.9.56886 | |
SONAR_PLUGIN_API_VERSION: 6.7.7 | |
SONAR_JAVA_VERSION: 7.13.0.29990 | |
SONAR_SERVER_JAVA_VERSION: 17 | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up JDK ${{ matrix.SONAR_SERVER_JAVA_VERSION }} | |
uses: actions/setup-java@v3 | |
with: | |
java-version: ${{ matrix.SONAR_SERVER_JAVA_VERSION }} | |
distribution: temurin | |
cache: 'gradle' | |
- name: Cache Gradle packages | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: integration-tests-${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
integration-tests-${{ runner.os }}-gradle | |
- name: Run Integration Tests | |
run: | | |
./gradlew testIntegration --build-cache --no-daemon \ | |
-PsonarqubeServerVersion=${{ matrix.SONAR_SERVER_VERSION }} \ | |
-PsonarqubeWsVersion=${{ matrix.SONAR_WS_VERSION }} \ | |
-PsonarPluginApiVersion=${{ matrix.SONAR_PLUGIN_API_VERSION }} \ | |
-PsonarJavaVersion=${{ matrix.SONAR_JAVA_VERSION }} | |
snapshot: | |
needs: [fetch-version, integration-tests] | |
if: needs.fetch-version.outputs.release == 'false' | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
java: | |
- 11 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up JDK ${{ matrix.java }} | |
uses: actions/setup-java@v3 | |
with: | |
java-version: ${{ matrix.java }} | |
distribution: temurin | |
cache: 'gradle' | |
- name: Cache SonarCloud packages | |
uses: actions/cache@v3 | |
with: | |
path: ~/.sonar/cache | |
key: ${{ runner.os }}-sonar | |
restore-keys: ${{ runner.os }}-sonar | |
- name: Cache Gradle packages | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Build | |
run: | | |
./gradlew clean build --build-cache --no-daemon | |
- name: Sonar | |
run: | | |
./gradlew sonar --no-daemon \ | |
-Dsonar.projectKey=${{ env.SONAR_PROJECT_KEY }} \ | |
-Dsonar.organization=${{ env.SONAR_ORGANIZATION }} \ | |
-Dsonar.host.url=${{ env.SONAR_HOST_URL }} \ | |
-Dsonar.pullrequest.provider=github \ | |
-Dsonar.pullrequest.github.repository=${{ github.repository }} \ | |
-Dsonar.branch.name=${GITHUB_REF##*/} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
SONAR_PROJECT_KEY: ${{ secrets.SONAR_PROJECT_KEY }} | |
SONAR_ORGANIZATION: ${{ secrets.SONAR_ORGANIZATION }} | |
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} | |
- name: Archive artifact | |
if: success() && matrix.java == '11' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: snapshot | |
path: build/libs/*.jar | |
# RELEASE THE PLUGIN | |
release: | |
needs: [fetch-version, integration-tests] | |
if: needs.fetch-version.outputs.release == 'true' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.RELEASE_TOKEN }} | |
- name: Set up JDK | |
uses: actions/setup-java@v3 | |
with: | |
java-version: 11 | |
distribution: temurin | |
cache: 'gradle' | |
- name: Cache SonarCloud packages | |
uses: actions/cache@v3 | |
with: | |
path: ~/.sonar/cache | |
key: ${{ runner.os }}-sonar | |
restore-keys: ${{ runner.os }}-sonar | |
- name: Cache Gradle packages | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Set up Git | |
run: | | |
git config --global user.name "${{ env.RELEASE_USER_NAME }}" | |
git config --global user.email "${{ env.RELEASE_USER_EMAIL }}" | |
git remote set-url origin https://x-access-token:${RELEASE_TOKEN}@github.com/${GITHUB_REPOSITORY}.git | |
env: | |
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }} | |
RELEASE_USER_EMAIL: ${{ secrets.RELEASE_USER_EMAIL }} | |
RELEASE_USER_NAME: ${{ secrets.RELEASE_USER_NAME }} | |
- name: Generate Next Plugin Version | |
run: | | |
MAJOR=$(echo $RELEASE_VERSION | cut -d. -f1) | |
MINOR=$(echo $RELEASE_VERSION | cut -d. -f2) | |
PATCH=$(echo $RELEASE_VERSION | cut -d. -f3) | |
PATCH=$((PATCH + 1)) | |
NEXT_PLUGIN_VERSION="$MAJOR.$MINOR.$PATCH-SNAPSHOT" | |
echo "Next Version will be: ${NEXT_PLUGIN_VERSION}" | |
echo "NEXT_PLUGIN_VERSION=${NEXT_PLUGIN_VERSION}" >> $GITHUB_ENV | |
env: | |
RELEASE_VERSION: ${{ needs.fetch-version.outputs.version }} | |
- name: Release | |
if: success() | |
run: | | |
./gradlew clean release \ | |
-Prelease.useAutomaticVersion=true \ | |
-Prelease.releaseVersion=${{ needs.fetch-version.outputs.version }} \ | |
-Prelease.newVersion=${{ env.NEXT_PLUGIN_VERSION }} | |
env: | |
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }} | |
- name: Sonar | |
run: | | |
./gradlew sonar --no-daemon \ | |
-Dsonar.projectKey=${{ env.SONAR_PROJECT_KEY }} \ | |
-Dsonar.organization=${{ env.SONAR_ORGANIZATION }} \ | |
-Dsonar.host.url=${{ env.SONAR_HOST_URL }} \ | |
-Dsonar.pullrequest.provider=github \ | |
-Dsonar.pullrequest.github.repository=${{ github.repository }} \ | |
-Dsonar.projectVersion=${{ needs.fetch-version.outputs.version }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
SONAR_PROJECT_KEY: ${{ secrets.SONAR_PROJECT_KEY }} | |
SONAR_ORGANIZATION: ${{ secrets.SONAR_ORGANIZATION }} | |
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} | |
- name: Archive artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: release | |
path: build/libs/*.jar | |
- name: Fetch ChangeLog | |
if: success() | |
run: | | |
./gradlew getChangelog -q --no-header --no-summary > ${{ github.workspace }}-CHANGELOG.txt | |
- name: GitHub Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
name: ${{ needs.fetch-version.outputs.version }} | |
tag_name: v${{ needs.fetch-version.outputs.version }} | |
body_path: ${{ github.workspace }}-CHANGELOG.txt | |
draft: true | |
files: | | |
build/libs/*.jar | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |