Skip to content

Commit 24553b1

Browse files
committed
ci(github): add github workflows
1 parent f70b56e commit 24553b1

11 files changed

Lines changed: 457 additions & 321 deletions

.github/workflows/publish.yml

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
name: gradle-semantic-gitlog
2+
3+
on: [push, pull_request]
4+
5+
env:
6+
GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_PUBLISH_KEY }}
7+
GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }}
8+
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
9+
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
10+
OSSRH_GPG_SECRET_ID: ${{ secrets.OSSRH_GPG_SECRET_ID }}
11+
OSSRH_GPG_SECRET_PASSWORD: ${{ secrets.OSSRH_GPG_SECRET_PASSWORD }}
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
17+
if: startsWith(github.event.head_commit.message, 'bumped version to ') != true
18+
19+
steps:
20+
- uses: actions/checkout@v2
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Set up JDK 1.8
25+
uses: actions/setup-java@v1
26+
with:
27+
java-version: 1.8
28+
29+
- name: Cache dependencies
30+
uses: actions/cache@v1
31+
with:
32+
path: ~/.gradle/caches
33+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
34+
restore-keys: ${{ runner.os }}-gradle-
35+
36+
- name: Prepare to build
37+
run: chmod +x ./gradlew
38+
39+
- name: Build project
40+
run: ./gradlew build -x test
41+
42+
test:
43+
needs: [build]
44+
runs-on: ubuntu-latest
45+
46+
if: (github.ref == 'refs/heads/master') && startsWith(github.event.head_commit.message, 'bumped version to ') != true && startsWith(github.event.head_commit.message, 'release:') != true
47+
48+
steps:
49+
- uses: actions/checkout@v2
50+
with:
51+
fetch-depth: 0
52+
53+
- name: Set up JDK 1.8
54+
uses: actions/setup-java@v1
55+
with:
56+
java-version: 1.8
57+
58+
- name: Cache dependencies
59+
uses: actions/cache@v1
60+
with:
61+
path: ~/.gradle/caches
62+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
63+
restore-keys: ${{ runner.os }}-gradle-
64+
65+
- name: Prepare to build
66+
run: chmod +x ./gradlew
67+
68+
- name: Run tests
69+
run: ./gradlew check test -S
70+
71+
deploy_snapshot:
72+
needs: [build, test]
73+
runs-on: ubuntu-latest
74+
75+
if: (github.ref == 'refs/heads/master') && startsWith(github.event.head_commit.message, 'bumped version to ') != true && startsWith(github.event.head_commit.message, 'release:') != true
76+
77+
steps:
78+
- uses: actions/checkout@v2
79+
with:
80+
fetch-depth: 0
81+
82+
- name: Set up JDK 1.8
83+
uses: actions/setup-java@v1
84+
with:
85+
java-version: 1.8
86+
87+
- name: Cache dependencies
88+
uses: actions/cache@v1
89+
with:
90+
path: ~/.gradle/caches
91+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
92+
restore-keys: ${{ runner.os }}-gradle-
93+
94+
- name: Prepare to build
95+
run: |
96+
chmod +x ./gradlew
97+
git show-ref
98+
git log --graph --full-history --all --color --date=short --pretty=format:"%Cred%x09%h %Creset%ad%Cgreen%d %Creset %s %C(bold)(%an)%Creset" || true
99+
100+
- id: install-secret-key
101+
name: Install gpg secret key
102+
run: echo "${{ secrets.OSSRH_GPG_SECRET_KEY }}" | base64 -d > ./secret.gpg
103+
104+
- id: publish
105+
name: Publish snapshot
106+
run: |
107+
newVersion=`./gradlew derive --preRelease='SNAPSHOT' -i | grep 'NEXT_VERSION:==' | sed 's/^.*NEXT_VERSION:==//g'`
108+
109+
echo "newVersion: ${newVersion}"
110+
111+
./gradlew setNewVersion -P newVersion=${newVersion} 1>/dev/null 2>/dev/null
112+
./gradlew publishMavenJavaPublicationToMavenRepository -x test -P OSSRH_GPG_SECRET_KEY=./secret.gpg
113+
./gradlew publishPlugins -x test -P OSSRH_GPG_SECRET_KEY=./secret.gpg -P gradle.publish.key=${{env.GRADLE_PUBLISH_KEY}} -P gradle.publish.secret=${{env.GRADLE_PUBLISH_SECRET}}
114+
115+
rm -rf ./secret.gpg
116+
117+
deploy_release:
118+
needs: [build]
119+
runs-on: ubuntu-latest
120+
121+
if: startsWith(github.ref, 'refs/tags/') && startsWith(github.event.head_commit.message, 'release')
122+
123+
steps:
124+
- uses: actions/checkout@v2
125+
with:
126+
fetch-depth: 0
127+
128+
- name: Set up JDK 1.8
129+
uses: actions/setup-java@v1
130+
with:
131+
java-version: 1.8
132+
133+
- name: Cache dependencies
134+
uses: actions/cache@v1
135+
with:
136+
path: ~/.gradle/caches
137+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
138+
restore-keys: ${{ runner.os }}-gradle-
139+
140+
- name: Prepare to build
141+
run: |
142+
chmod +x ./gradlew
143+
git show-ref
144+
git log --graph --full-history --all --color --date=short --pretty=format:"%Cred%x09%h %Creset%ad%Cgreen%d %Creset %s %C(bold)(%an)%Creset" || true
145+
146+
- id: install-secret-key
147+
name: Install gpg secret key
148+
run: echo "${{ secrets.OSSRH_GPG_SECRET_KEY }}" | base64 -d > ./secret.gpg
149+
150+
- name: Publish release
151+
run: |
152+
./gradlew publishMavenJavaPublicationToMavenRepository -x test -P OSSRH_GPG_SECRET_KEY=./secret.gpg
153+
./gradlew publishPlugins -x test -P OSSRH_GPG_SECRET_KEY=./secret.gpg -P gradle.publish.key=${{env.GRADLE_PUBLISH_KEY}} -P gradle.publish.secret=${{env.GRADLE_PUBLISH_SECRET}}
154+
155+
rm -rf ./secret.gpg

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@ pom.xml.versionsBackup
3838
### CUSTOM CONFIG ###
3939
.gradle
4040
.okhttpcache
41-
.travis/secret.gpg
42-
.travis/secret.gpg
41+
secret.gpg
42+
secret.gpg.*

.travis.yml

Lines changed: 0 additions & 48 deletions
This file was deleted.

.travis/deploy-release.sh

Lines changed: 0 additions & 44 deletions
This file was deleted.

.travis/deploy-snapshot.sh

Lines changed: 0 additions & 40 deletions
This file was deleted.

.travis/secret.gpg.enc

-3.27 KB
Binary file not shown.

0 commit comments

Comments
 (0)