1
1
name : Continuous Integration
2
2
on : [push, pull_request, workflow_dispatch]
3
3
jobs :
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
-
64
4
publish :
65
5
name : Publish
66
6
runs-on : ubuntu-latest
67
- needs : [ test ]
68
- if : github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && github.repository == 'tschuchortdev/kotlin-compile-testing'
69
7
env :
70
8
# https://proandroiddev.com/publishing-a-maven-artifact-3-3-step-by-step-instructions-to-mavencentral-publishing-bd661081645d
71
9
SONATYPE_NEXUS_USERNAME : ${{ secrets.SONATYPE_NEXUS_USERNAME }}
@@ -74,17 +12,12 @@ jobs:
74
12
# https://stackoverflow.com/questions/57921325/gradle-signarchives-unable-to-read-secret-key
75
13
ORG_GRADLE_PROJECT_signingPassword : ${{ secrets.SONATYPE_SIGNING_KEY_PASSWORD }}
76
14
ORG_GRADLE_PROJECT_signingKey : ${{ secrets.SONATYPE_SIGNING_PRIVATE_KEY }}
77
- GH_PERSONAL_ACCESS_TOKEN : ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
15
+ permissions :
16
+ contents : write
78
17
steps :
79
18
- uses : actions/checkout@v3
80
19
with :
81
20
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'
88
21
- name : Set git config
89
22
run : |
90
23
git config user.name github-actions
95
28
echo "VERSION_NAME=$VERSION_NAME" >> $GITHUB_ENV
96
29
IS_SNAPSHOT_VERSION=$([[ "$VERSION_NAME" =~ ^[0-9]+\.[0-9]+\.[0-9]+-SNAPSHOT$ ]] && echo "true" || echo "false")
97
30
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/*.*
128
31
- name : Set next snapshot version
129
32
if : ${{ env.IS_SNAPSHOT_VERSION == 'false' }}
130
33
run : |
133
36
./gradlew setSnapshotVersionSuffix --info
134
37
git add gradle.properties
135
38
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
39
+ git push --follow-tags
0 commit comments