1
1
name : build and publish
2
2
3
3
on :
4
- push :
5
- branches :
6
- - master
4
+ - push
5
+ - pull_request
6
+
7
7
8
8
jobs :
9
+ setup :
10
+ runs-on : ubuntu-latest
11
+ steps :
12
+ - name : Checkout
13
+ uses : actions/checkout@v1
14
+ - name : Declare outputs
15
+ id : declare
16
+ run : |
17
+ echo "::set-output name=version::1.$(date +%Y%m%d%H%M%S).$(git describe --always --dirty --exclude '*')"
18
+ echo "::set-output name=do_deploy::${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && !contains(github.event.head_commit.message, 'ci skip') }}"
19
+ outputs :
20
+ version : " ${{ steps.declare.outputs.version }}"
21
+ do_deploy : " ${{ steps.declare.outputs.do_deploy }}"
9
22
build :
10
23
runs-on : ubuntu-latest
24
+ needs :
25
+ - setup
26
+ env :
27
+ VERSION : " ${{ needs.setup.outputs.version }}"
11
28
steps :
12
29
- uses : actions/checkout@v1
13
30
- uses : actions/setup-java@v1
14
31
with :
15
32
java-version : ' 12.x'
16
33
- name : test and build
17
- run : ./gradlew -Pversion="1.$(git log -1 --pretty='%h')" build publish
18
- env :
19
- ORG_GRADLE_PROJECT_githubUser : x-access-token
20
- ORG_GRADLE_PROJECT_githubPassword : ${{ secrets.GITHUB_TOKEN }}
34
+ run : ./gradlew -Pversion="${VERSION}" build
35
+ - name : Save build artifacts
36
+ uses : actions/upload-artifact@v2
37
+ with :
38
+ path : build
21
39
22
40
release :
23
41
name : Create Release
24
- needs : build
42
+ needs :
43
+ - setup
44
+ - build
25
45
runs-on : ubuntu-latest
26
- if : github.ref == 'refs/heads/master' && !contains(github.event.head_commit.message, 'ci skip')
46
+ if : needs.setup.outputs.do_deploy == 'true'
47
+ env :
48
+ VERSION : " ${{ needs.setup.outputs.version }}"
27
49
steps :
28
50
- name : Checkout code
29
51
uses : actions/checkout@v1
30
- - name : Set release tag
31
- run : |
32
- export TAG_NAME="1.$(git log -1 --pretty='%h')"
33
- echo "::set-env name=RELEASE_TAG::$TAG_NAME"
34
52
- name : Set changelog
35
53
# (Escape newlines see https://github.com/actions/create-release/issues/25)
36
54
run : |
@@ -39,14 +57,23 @@ jobs:
39
57
text="${text//$'\n'/%0A}"
40
58
text="${text//$'\r'/%0D}"
41
59
echo "::set-env name=CHANGELOG::$text"
60
+ - name : Fetch build artifacts
61
+ uses : actions/download-artifact@v2
62
+ with :
63
+ path : build
64
+ - name : publish
65
+ run : ./gradlew -Pversion="${VERSION}" publish
66
+ env :
67
+ ORG_GRADLE_PROJECT_githubUser : x-access-token
68
+ ORG_GRADLE_PROJECT_githubPassword : ${{ secrets.GITHUB_TOKEN }}
42
69
- name : Create Release
43
70
id : create_release
44
71
uses : actions/create-release@latest
45
72
env :
46
73
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
47
74
with :
48
- tag_name : ${{ env.RELEASE_TAG }}
49
- release_name : ${{ env.RELEASE_TAG }}
75
+ tag_name : ${{ env.VERSION }}
76
+ release_name : ${{ env.VERSION }}
50
77
body : |
51
78
Changes in this Release
52
79
0 commit comments