-
Notifications
You must be signed in to change notification settings - Fork 10
177 lines (165 loc) · 6.87 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
name: Build and prepare release
# This workflow repeats all of the ci.yml... Should try to avoid that
on:
push:
tags:
- 'v*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Print webhook information
run: 'cat ${{ github.event_path }}'
- name: Extract pushed tag name
id: parse_tag
# outputs: tag NAME (v1.0.0) and tag VERSION (1.0.0)
run: |
echo ::set-output name=NAME::${GITHUB_REF#refs/tags/}
echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/v}
- name: Meta information
run: 'echo Event ref: ${{ github.ref }} Tag name ${{ steps.parse_tag.outputs.NAME }} Commit hash: ${{ github.sha }}'
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Cache Gradle packages
uses: actions/cache@v2
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build (Compile, lint, checkApi, test, etc)
run: ./gradlew -DVERSION_OVERRIDE=${{ steps.parse_tag.outputs.VERSION }} build
- name: Archive build reports artifacts
if: always()
uses: actions/upload-artifact@v2
with:
name: build-reports
path: '**/build/reports'
- name: Ensure documentation is up to date
id: doc-check
run: |
./gradlew cleanDokka dokka
# the next command will list documentation files out of date. Please run ./gradlew dokka
#git diff --exit-code --name-only || echo ::set-output name=status::failure
# the line above commented out due to a weird behaviour where styles.css is generated differently in my local
# machine and github
git diff --name-only
- name: Check which documentation files have changed
if: steps.doc-check.outputs.status == 'failure'
run: git diff > git-diff.txt
- name: Upload diff artifact of the documentation files
uses: actions/upload-artifact@v2
if: steps.doc-check.outputs.status == 'failure'
with:
name: git-diff
path: git-diff.txt
- name: Fail build due to documentation being out of date
if: steps.doc-check.outputs.status == 'failure'
run: |
rm git-diff.txt
echo Documentation is out of date, you need to run ./gradlew dokka and try again. The following files have changed:
git diff --exit-code --name-only
release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: build
steps:
# To use this repository's private action, you must check out the repository
- name: Checkout
uses: actions/checkout@v2
- name: Extract pushed tag name
id: parse_tag
# outputs: tag NAME (v1.0.0) and tag VERSION (1.0.0)
run: |
echo ::set-output name=NAME::${GITHUB_REF#refs/tags/}
echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/v}
- name: Extract most recent tag
id: extract_previous_release_tag
run: |
git fetch --tags
echo ::set-output name=NAME::$(git tag --list 'v*' --sort=version:refname | grep '^${{ steps.parse_tag.outputs.NAME }}$' --before-context=1 --after-context=0 | head -n 1)
- name: Sanity check
run: |
git tag --list 'v*' --sort=version:refname
echo break
git tag --list 'v*' --sort=version:refname | grep '^${{ steps.parse_tag.outputs.NAME }}$' --before-context=1 --after-context=0
echo break break
git tag --list 'v*' --sort=version:refname | grep '^${{ steps.parse_tag.outputs.NAME }}$' --before-context=1 --after-context=0 | head -n 1
echo final break
echo ${{ steps.extract_previous_release_tag.outputs.NAME }}
- name: Generate changelog
# https://github.com/metcalfc/changelog-generator
id: changelog
uses: metcalfc/changelog-generator@v0.4.0
with:
myToken: ${{ secrets.GITHUB_TOKEN }}
base-ref: ${{ steps.extract_previous_release_tag.outputs.NAME }}
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.parse_tag.outputs.NAME }}
release_name: ${{ steps.parse_tag.outputs.VERSION }}
body: ${{ steps.changelog.outputs.changelog }}
draft: true
prerelease: "${{ contains( steps.parse_tag.outputs.VERSION, 'RC') || contains( steps.parse_tag.outputs.VERSION, 'SNAPSHOT') }}"
- name: Debug my logic
run: |
echo Is prerelease? ${{ contains( steps.parse_tag.outputs.VERSION, 'RC') || contains( steps.parse_tag.outputs.VERSION, 'SNAPSHOT') }}
echo Previous release tag name: ${{ steps.extract_previous_release_tag.NAME }}
publish:
name: Publish to Maven Central
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v2
- name: Extract pushed tag name
id: parse_tag
# outputs: tag NAME (v1.0.0) and tag VERSION (1.0.0)
run: |
echo ::set-output name=NAME::${GITHUB_REF#refs/tags/}
echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/v}
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Cache Gradle packages
uses: actions/cache@v2
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v3
with:
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
- name: GPG user IDs
run: |
echo "fingerprint: ${{ steps.import_gpg.outputs.fingerprint }}"
echo "keyid: ${{ steps.import_gpg.outputs.keyid }}"
echo "name: ${{ steps.import_gpg.outputs.name }}"
echo "email: ${{ steps.import_gpg.outputs.email }}"
- name: sign with gpg
env:
signing_keyId: ${{ secrets.SIGNING_KEY_ID }}
signing_password: ${{ secrets.GPG_PASSPHRASE }}
signing_key: ${{ secrets.GPG_PRIVATE_KEY }}
run: ./gradlew -DVERSION_OVERRIDE=${{ steps.parse_tag.outputs.VERSION }} signMVFlowPublication
- name: publish to OSSRH
env:
signing_keyId: ${{ secrets.SIGNING_KEY_ID }}
signing_password: ${{ secrets.GPG_PASSPHRASE }}
signing_key: ${{ secrets.GPG_PRIVATE_KEY }}
OSSRH_USER: ${{ secrets.OSSRH_USER}}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD}}
run: ./gradlew -DVERSION_OVERRIDE=${{ steps.parse_tag.outputs.VERSION }} publishMVFlowPublicationToOSSRHRepository