11name : Continuous Integration
22on : [push, pull_request, workflow_dispatch]
33jobs :
4- check_duplicate_workflows :
5- name : Check for duplicate workflows
6- runs-on : ubuntu-latest
7- if : ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
8- # Map a step output to a job output
9- outputs :
10- should_skip : ${{ steps.skip_check.outputs.should_skip }}
11- steps :
12- - id : skip_check
13- uses : fkirc/skip-duplicate-actions@master
14- with :
15- skip_after_successful_duplicate : ' false'
16- concurrent_skipping : ' same_content'
17- do_not_skip : ' ["pull_request", "workflow_dispatch", "schedule"]'
18- paths_ignore : ' ["**/*.md"]'
19- build :
20- name : Build
21- runs-on : ${{ matrix.platform }}
22- needs : [check_duplicate_workflows]
23- if : ${{ needs.check_duplicate_workflows.outputs.should_skip != 'true' }}
24- strategy :
25- matrix :
26- java : [ '8', '11', '17' ]
27- platform : ['windows-latest', 'ubuntu-latest']
28- steps :
29- - uses : actions/checkout@v3
30- - name : Set up JDK ${{ matrix.java }}
31- uses : actions/setup-java@v3
32- with :
33- distribution : ' adopt'
34- java-version : ${{ matrix.java }}
35- cache : ' gradle'
36- - name : print Java version
37- run : java -version
38- - name : Run build
39- run : ./gradlew clean assemble --info
40-
41- test :
42- name : Test
43- runs-on : ${{ matrix.platform }}
44- needs : [build]
45- strategy :
46- matrix :
47- java : [ '8', '11', '17' ]
48- platform : ['windows-latest', 'ubuntu-latest']
49- steps :
50- - uses : actions/checkout@v3
51- - name : Gradle wrapper validation
52- uses : gradle/wrapper-validation-action@v1
53- - name : Set up JDK
54- uses : actions/setup-java@v3
55- with :
56- distribution : ' adopt'
57- java-version : ${{ matrix.java }}
58- cache : ' gradle'
59- - name : print Java version
60- run : java -version
61- - name : Run test
62- run : ./gradlew check --info
63-
644 publish :
655 name : Publish
666 runs-on : ubuntu-latest
677 needs : [ test ]
68- if : github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && github.repository == 'tschuchortdev/kotlin-compile-testing'
698 env :
709 # https://proandroiddev.com/publishing-a-maven-artifact-3-3-step-by-step-instructions-to-mavencentral-publishing-bd661081645d
7110 SONATYPE_NEXUS_USERNAME : ${{ secrets.SONATYPE_NEXUS_USERNAME }}
@@ -74,17 +13,12 @@ jobs:
7413 # https://stackoverflow.com/questions/57921325/gradle-signarchives-unable-to-read-secret-key
7514 ORG_GRADLE_PROJECT_signingPassword : ${{ secrets.SONATYPE_SIGNING_KEY_PASSWORD }}
7615 ORG_GRADLE_PROJECT_signingKey : ${{ secrets.SONATYPE_SIGNING_PRIVATE_KEY }}
77- GH_PERSONAL_ACCESS_TOKEN : ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
16+ permissions :
17+ contents : write
7818 steps :
7919 - uses : actions/checkout@v3
8020 with :
8121 persist-credentials : false # without this, all access tokens set later on will be ignored
82- - name : Set up JDK
83- uses : actions/setup-java@v3
84- with :
85- distribution : ' adopt'
86- java-version : 11
87- cache : ' gradle'
8822 - name : Set git config
8923 run : |
9024 git config user.name github-actions
9529 echo "VERSION_NAME=$VERSION_NAME" >> $GITHUB_ENV
9630 IS_SNAPSHOT_VERSION=$([[ "$VERSION_NAME" =~ ^[0-9]+\.[0-9]+\.[0-9]+-SNAPSHOT$ ]] && echo "true" || echo "false")
9731 echo "IS_SNAPSHOT_VERSION=$IS_SNAPSHOT_VERSION" >> $GITHUB_ENV
98- - name : Publish to Sonatype Nexus
99- run : |
100- # --max-workers 1 limits Gradle to a single thread even if parallel builds are enabled in the hopes
101- # of making the the upload to Sonatype Nexus less flaky
102-
103- if [[ "$IS_SNAPSHOT_VERSION" == "true" ]]; then
104- echo "Version is a snapshot. No closing of the repository is necessary."
105- ./gradlew publishToSonatype --info --max-workers 1
106- elif [[ "$IS_SNAPSHOT_VERSION" == "false" ]]; then
107- echo "Version is not a snapshot. Trying to close and release repository."
108- # Note: Until https://github.com/gradle-nexus/publish-plugin/issues/19 is fixed
109- # publish and close/release always have to be executed in the same Gradle call
110- # or closing will fail with error 'No staging repository with name sonatype created'.
111- ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository --info --max-workers 1
112- else
113- echo "IS_SNAPSHOT_VERSION has unknown value: $IS_SNAPSHOT_VERSION"
114- exit 1
115- fi
116- - name : Make release on Github
117- uses : marvinpinto/action-automatic-releases@latest
118- if : ${{ env.IS_SNAPSHOT_VERSION == 'false' }}
119- with :
120- repo_token : ${{ secrets.GITHUB_TOKEN }}
121- automatic_release_tag : ${{ env.VERSION_NAME }}
122- prerelease : false
123- title : ${{ env.VERSION_NAME }}
124- files : |
125- LICENSE
126- core/build/libs/*.*
127- ksp/build/libs/*.*
12832 - name : Set next snapshot version
12933 if : ${{ env.IS_SNAPSHOT_VERSION == 'false' }}
13034 run : |
13337 ./gradlew setSnapshotVersionSuffix --info
13438 git add gradle.properties
13539 git commit -m "Setting next snapshot version [skip ci]"
136- git push https://x-access-token:${GH_PERSONAL_ACCESS_TOKEN }@github.com/${GITHUB_REPOSITORY}.git --follow-tags
40+ git push https://x-access-token:${GITHUB_TOKEN }@github.com/${GITHUB_REPOSITORY}.git --follow-tags
0 commit comments