-
Notifications
You must be signed in to change notification settings - Fork 66
245 lines (211 loc) · 7.77 KB
/
production-new-version.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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
name: Production Release With Version
on:
workflow_dispatch:
inputs:
version:
description: "Version (optional)"
required: false
default: ""
confirm:
type: boolean
required: true
default: false
description: Yes, I want to release.
is-production:
type: boolean
required: true
default: true
description: "release to production saas"
is-self-hosted:
type: boolean
required: true
default: true
description: "release to self hosted"
jobs:
confirm:
name: Confirm publish
runs-on: ubuntu-latest
steps:
- name: Confirm
if: ${{ github.event.inputs.confirm != 'true' }}
run: |
echo "Please confirm that you want to release"
exit 1
set-version:
name: Set version
runs-on: ubuntu-latest
outputs:
build_version: ${{ steps.get_build_version.outputs.build_version }}
needs:
- confirm
steps:
- name: ⇣ Checkout
uses: actions/checkout@v2
with:
token: ${{ secrets.GH_BUILDER_TOKEN }}
- uses: actions/setup-java@v1
with:
java-version: 11
- name: Set version
run: |
set -e
OLD_VERSION="$(./gradlew -q :Tabnine:currentVersion)"
NEW_VERSION="${{ github.event.inputs.version }}"
if [ -z "$NEW_VERSION" ]; then
OLD_MAJOR=$(echo $OLD_VERSION | cut -d. -f1)
OLD_MINOR=$(echo $OLD_VERSION | cut -d. -f2)
OLD_PATCH=$(echo $OLD_VERSION | cut -d. -f3)
NEW_MINOR=$((OLD_MINOR + 1))
NEW_VERSION=$OLD_MAJOR.$NEW_MINOR.0
fi
sed -i "s/project\.externalVersion : '.*\..*\..*'/project\.externalVersion : '$NEW_VERSION'/g" Tabnine/build.gradle
sed -i "s/project\.externalVersion : '.*\..*\..*'/project\.externalVersion : '$NEW_VERSION'/g" TabnineSelfHosted/build.gradle
- name: Get Version
id: get_build_version
run: |
VERSION="$(./gradlew -q :Tabnine:currentVersion)"
echo "new version is $VERSION"
echo "build_version=$VERSION" >> $GITHUB_OUTPUT
- name: Setup git
run: |
set -ex
git config --global user.email "[email protected]"
git config --global user.name "codota-builder"
- name: Commit changes
run: |
NEW_VERSION="${{ steps.get_build_version.outputs.build_version }}"
git commit -am "Set version to $NEW_VERSION"
git push
git tag v$NEW_VERSION
git push origin v$NEW_VERSION
publish-production:
if: ${{ github.event.inputs.is-production == 'true' }}
name: Publish to PRODUCTION
runs-on: ubuntu-latest
needs:
- set-version
steps:
- name: ⇣ Checkout
uses: actions/checkout@v2
with:
token: ${{ secrets.GH_BUILDER_TOKEN }}
- uses: actions/setup-java@v1
with:
java-version: 11
- uses: actions/cache@v2
name: Cache Gradle packages
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Get Chat Version
id: get_chat_version
run: echo "version=$(cat ./.chatversion)" >> $GITHUB_ENV
- name: Checkout Chat Application Repository
uses: dsaltares/fetch-gh-release-asset@master
with:
repo: "codota/tabnine-chat-app"
version: "tags/${{ env.version }}"
file: "build.tar.gz"
token: ${{ secrets.gh_builder_token }}
- name: Extract Chat App Build
run: |
mkdir -p ./Tabnine/tabnineChat
cp build.tar.gz ./Tabnine/tabnineChat/chat-bundle.tar.gz
- name: Publish production plugin
run: |
./gradlew :Tabnine:publishPlugin -PexternalVersion=${{ needs.set-version.outputs.build_version }} -Pchannel=production
env:
HUB_TOKEN: ${{ secrets.HUB_TOKEN }}
- name: Get Plugin Path
id: get_plugin_path
run: echo "plugin_path=$(ls -t Tabnine/build/distributions/TabNine-*.zip | head -1)" >> $GITHUB_OUTPUT
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ needs.set-version.outputs.build_version }}
release_name: v${{ needs.set-version.outputs.build_version }}
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ steps.get_plugin_path.outputs.plugin_path }}
asset_name: TabNine.zip
asset_content_type: application/zip
- name: Send Slack release message
if: success()
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_RELEASES_CHANNEL_WEBHOOK_URL }}
SLACK_CHANNEL: releases-automation
SLACK_TITLE: "intellij ${{ needs.set-version.outputs.build_version }} version released to production"
SLACK_USERNAME: "intellij update"
SLACK_ICON_EMOJI: ":intellij:"
SLACK_MESSAGE: ${{ github.event.head_commit.message }}
SLACK_FOOTER: " "
publish-self-hosted:
if: ${{ github.event.inputs.is-self-hosted == 'true' }}
name: Publish self hosted
runs-on: ubuntu-latest
needs:
- set-version
steps:
- name: ⇣ Checkout
uses: actions/checkout@v2
with:
token: ${{ secrets.GH_BUILDER_TOKEN }}
- uses: actions/setup-java@v1
with:
java-version: 11
- uses: actions/cache@v2
name: Cache Gradle packages
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Get Chat Version
id: get_chat_version
run: echo "version=$(cat ./.chatversion)" >> $GITHUB_ENV
- name: Checkout Chat Application Repository
uses: dsaltares/fetch-gh-release-asset@master
with:
repo: "codota/tabnine-chat-app"
version: "tags/${{ env.version }}"
file: "build.tar.gz"
token: ${{ secrets.gh_builder_token }}
- name: Extract Chat App Build
run: |
mkdir -p ./TabnineSelfHosted/tabnineChat
cp build.tar.gz ./TabnineSelfHosted/tabnineChat/chat-bundle.tar.gz
- name: Build the self-hosted plugin
run: ./gradlew :TabnineSelfHosted:buildPlugin -PexternalVersion=${{ needs.set-version.outputs.build_version }} -Pchannel=self_hosted
- name: Get Plugin Path
id: get_plugin_path
run: echo "plugin_path=$(ls -t TabnineSelfHosted/build/distributions/TabNine*.zip | head -1)" >> $GITHUB_OUTPUT
- name: Set stable version file
run: |
echo ${{ needs.set-version.outputs.build_version }} > stable
- name: Authenticate to Google Cloud
uses: "google-github-actions/auth@v1"
with:
credentials_json: ${{ secrets.GCS_RELEASE_KEY }}
- name: ⬆️ Upload latest stable version to GCS
uses: google-github-actions/upload-cloud-storage@v1
with:
path: stable
destination: tabnine-self-hosted-artifacts/jetbrains
parent: false
gzip: false
headers: |-
content-type: text/plain
- name: ⬆️ Upload zip to GCS
uses: google-github-actions/upload-cloud-storage@v1
with:
path: ${{ steps.get_plugin_path.outputs.plugin_path }}
destination: tabnine-self-hosted-artifacts/jetbrains
parent: false