-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
93c1ffc
commit 12746ec
Showing
1 changed file
with
5 additions
and
104 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,9 @@ | ||
name: Continuous Integration | ||
on: [push, pull_request, workflow_dispatch] | ||
jobs: | ||
check_duplicate_workflows: | ||
name: Check for duplicate workflows | ||
runs-on: ubuntu-latest | ||
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }} | ||
# Map a step output to a job output | ||
outputs: | ||
should_skip: ${{ steps.skip_check.outputs.should_skip }} | ||
steps: | ||
- id: skip_check | ||
uses: fkirc/skip-duplicate-actions@master | ||
with: | ||
skip_after_successful_duplicate: 'false' | ||
concurrent_skipping: 'same_content' | ||
do_not_skip: '["pull_request", "workflow_dispatch", "schedule"]' | ||
paths_ignore: '["**/*.md"]' | ||
build: | ||
name: Build | ||
runs-on: ${{ matrix.platform }} | ||
needs: [check_duplicate_workflows] | ||
if: ${{ needs.check_duplicate_workflows.outputs.should_skip != 'true' }} | ||
strategy: | ||
matrix: | ||
java: [ '8', '11', '17' ] | ||
platform: ['windows-latest', 'ubuntu-latest'] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK ${{ matrix.java }} | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'adopt' | ||
java-version: ${{ matrix.java }} | ||
cache: 'gradle' | ||
- name: print Java version | ||
run: java -version | ||
- name: Run build | ||
run: ./gradlew clean assemble --info | ||
|
||
test: | ||
name: Test | ||
runs-on: ${{ matrix.platform }} | ||
needs: [build] | ||
strategy: | ||
matrix: | ||
java: [ '8', '11', '17' ] | ||
platform: ['windows-latest', 'ubuntu-latest'] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Gradle wrapper validation | ||
uses: gradle/wrapper-validation-action@v1 | ||
- name: Set up JDK | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'adopt' | ||
java-version: ${{ matrix.java }} | ||
cache: 'gradle' | ||
- name: print Java version | ||
run: java -version | ||
- name: Run test | ||
run: ./gradlew check --info | ||
|
||
publish: | ||
name : Publish | ||
runs-on: ubuntu-latest | ||
needs: [ test ] | ||
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && github.repository == 'tschuchortdev/kotlin-compile-testing' | ||
env: | ||
# https://proandroiddev.com/publishing-a-maven-artifact-3-3-step-by-step-instructions-to-mavencentral-publishing-bd661081645d | ||
SONATYPE_NEXUS_USERNAME: ${{ secrets.SONATYPE_NEXUS_USERNAME }} | ||
|
@@ -74,63 +12,26 @@ jobs: | |
# https://stackoverflow.com/questions/57921325/gradle-signarchives-unable-to-read-secret-key | ||
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SONATYPE_SIGNING_KEY_PASSWORD }} | ||
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SONATYPE_SIGNING_PRIVATE_KEY }} | ||
GH_PERSONAL_ACCESS_TOKEN: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} | ||
permissions: | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
persist-credentials: false # without this, all access tokens set later on will be ignored | ||
- name: Set up JDK | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'adopt' | ||
java-version: 11 | ||
cache: 'gradle' | ||
- name: Set git config | ||
run: | | ||
git config user.name github-actions | ||
git config user.email [email protected] | ||
- name: Check if snapshot version | ||
run: | | ||
VERSION_NAME=$(./gradlew -q printVersionName | tail -n 1) | ||
echo "VERSION_NAME=$VERSION_NAME" >> $GITHUB_ENV | ||
IS_SNAPSHOT_VERSION=$([[ "$VERSION_NAME" =~ ^[0-9]+\.[0-9]+\.[0-9]+-SNAPSHOT$ ]] && echo "true" || echo "false") | ||
echo "IS_SNAPSHOT_VERSION=$IS_SNAPSHOT_VERSION" >> $GITHUB_ENV | ||
- name: Publish to Sonatype Nexus | ||
run: | | ||
# --max-workers 1 limits Gradle to a single thread even if parallel builds are enabled in the hopes | ||
# of making the the upload to Sonatype Nexus less flaky | ||
if [[ "$IS_SNAPSHOT_VERSION" == "true" ]]; then | ||
echo "Version is a snapshot. No closing of the repository is necessary." | ||
./gradlew publishToSonatype --info --max-workers 1 | ||
elif [[ "$IS_SNAPSHOT_VERSION" == "false" ]]; then | ||
echo "Version is not a snapshot. Trying to close and release repository." | ||
# Note: Until https://github.com/gradle-nexus/publish-plugin/issues/19 is fixed | ||
# publish and close/release always have to be executed in the same Gradle call | ||
# or closing will fail with error 'No staging repository with name sonatype created'. | ||
./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository --info --max-workers 1 | ||
else | ||
echo "IS_SNAPSHOT_VERSION has unknown value: $IS_SNAPSHOT_VERSION" | ||
exit 1 | ||
fi | ||
- name: Make release on Github | ||
uses: marvinpinto/action-automatic-releases@latest | ||
if: ${{ env.IS_SNAPSHOT_VERSION == 'false' }} | ||
with: | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
automatic_release_tag: ${{ env.VERSION_NAME }} | ||
prerelease: false | ||
title: ${{ env.VERSION_NAME }} | ||
files: | | ||
LICENSE | ||
core/build/libs/*.* | ||
ksp/build/libs/*.* | ||
- name: Set next snapshot version | ||
if: ${{ env.IS_SNAPSHOT_VERSION == 'false' }} | ||
run: | | ||
echo "Setting next snapshot version" | ||
./gradlew incrementPatchVersion --info | ||
./gradlew setSnapshotVersionSuffix --info | ||
git config user.name github-actions | ||
git config user.email [email protected] | ||
git add gradle.properties | ||
git commit -m "Setting next snapshot version [skip ci]" | ||
git push https://x-access-token:${GH_PERSONAL_ACCESS_TOKEN}@github.com/${GITHUB_REPOSITORY}.git --follow-tags | ||
git push --follow-tags |