-
Notifications
You must be signed in to change notification settings - Fork 3
150 lines (140 loc) · 5.25 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
name: Release artifacts
on:
workflow_dispatch:
inputs:
artifacts:
description: Comma separeted artifact name list. e.g. plugin,schema
required: true
default: plugin,schema
ref:
description: Git Ref to release
required: true
default: master
snapshot-version:
description: Specify the snapshot version name. Keep empty for the production release.
push:
tags:
- \d.\d
- \d.\d.\d
jobs:
params:
runs-on: ubuntu-latest
steps:
- id: parse
run: |
if ${{ github.event_name == 'workflow_dispatch' }}; then
artifacts='${{ github.event.inputs.artifacts }}'
checkout_ref='${{ github.event.inputs.ref }}'
release_mode='${{ github.event.inputs.snapshot-version && 'false' || 'true' }}'
else
artifacts='schema'
checkout_ref='${{ github.ref }}'
release_mode='true'
fi
echo "::set-output name=artifacts::${artifacts}"
echo "::set-output name=checkout-ref::${checkout_ref}"
echo "::set-output name=release-mode::${release_mode}"
- uses: actions/checkout@v2
with:
ref: ${{ steps.parse.outputs.checkout-ref }}
- id: version
run: |
if ${{ github.event_name == 'workflow_dispatch' }}; then
version='${{ github.event.inputs.snapshot-version }}'
if [ -z "${version}" ]; then
version="$(cat VERSION)"
fi
else
version="${GITHUB_REF#refs/tags/}"
fi
echo "::set-output name=result::${version}"
if [ ! "$(cat VERSION)" = "${version}" ]; then
echo 'version mismatch'
exit 1
fi
outputs:
artifacts: ${{ steps.parse.outputs.artifacts }}
checkout-ref: ${{ steps.parse.outputs.checkout-ref }}
release-mode: ${{ steps.parse.outputs.release-mode }}
version: ${{ steps.version.outputs.result }}
schema-release:
if: contains(needs.params.outputs.artifacts, 'schema')
runs-on: ubuntu-latest
needs: [ params ]
env:
RELEASE_MODE: ${{ needs.params.outputs.release-mode }}
steps:
- uses: actions/checkout@v2
with:
ref: ${{ needs.params.outputs.checkout-ref }}
- uses: actions/setup-java@v1
with:
java-version: '8'
java-package: jdk
- uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('buildSrc/src/main/**/*.kt') }}
restore-keys: |
${{ runner.os }}-gradle-
- uses: actions/cache@v1
with:
path: ~/.gradle/wrapper
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}
- run: echo '${{ needs.params.outputs.version }}' > VERSION
- name: Publish artifacts
run: |
./gradlew ':license-list-schema:publishSchemaPublicationToMavenRepository'
env:
ORG_GRADLE_PROJECT_nexusUsername: jmatsu
ORG_GRADLE_PROJECT_nexusPassword: ${{ secrets.NEXUS_PASSWORD }}
ORG_GRADLE_PROJECT_signingRequired: true
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_SECRET_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_PASSPHRASE }}
- run: sleep 10
- name: Download startship
run: |
mkdir -p ~/.gradle
touch ~/.gradle/gradle.properties
curl -sSfL \
--url 'https://github.com/saket/startship/releases/download/1.1.1/startship.zip' \
-o startship.zip && \
unzip startship.zip
echo "$PWD/$(find startship -type d -name "bin")" >> $GITHUB_PATH
# repository id must be chosen.
# - name: Close and promote the schema
# run: |
# startship release \
# -c "io.github.jmatsu:license-list-schema:$(cat VERSION)" \
# -u jmatsu \
# -p ${{ secrets.NEXUS_PASSWORD }}
plugin-release:
if: contains(needs.params.outputs.artifacts, 'plugin')
runs-on: ubuntu-latest
needs: [ params ]
env:
RELEASE_MODE: ${{ needs.params.outputs.release-mode }}
steps:
- uses: actions/checkout@v2
with:
ref: ${{ needs.params.outputs.checkout-ref }}
- uses: actions/setup-java@v1
with:
java-version: '8'
java-package: jdk
- uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('buildSrc/src/main/**/*.kt') }}
restore-keys: |
${{ runner.os }}-gradle-
- uses: actions/cache@v1
with:
path: ~/.gradle/wrapper
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}
- run: echo '${{ needs.params.outputs.version }}' > VERSION
- name: Publish plugin
run: ./gradlew publishPlugins -Dgradle.publish.key=$GRADLE_PORTAL_PUBLISH_KEY -Dgradle.publish.secret=$GRADLE_PORTAL_PUBLISH_SECRET
env:
GRADLE_PORTAL_PUBLISH_KEY: ${{ secrets.GRADLE_PORTAL_PUBLISH_KEY }}
GRADLE_PORTAL_PUBLISH_SECRET: ${{ secrets.GRADLE_PORTAL_PUBLISH_SECRET }}