-
Notifications
You must be signed in to change notification settings - Fork 1
329 lines (282 loc) · 10.7 KB
/
release.yml
File metadata and controls
329 lines (282 loc) · 10.7 KB
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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
name: Release
on:
push:
tags:
- 'v*.*.*'
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., 1.0.0)'
required: true
type: string
permissions:
contents: write
packages: write
env:
PYTHON_VERSION: "3.12"
jobs:
create-release:
name: Create Release
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get-version.outputs.version }}
upload_url: ${{ steps.create-release.outputs.upload_url }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get version
id: get-version
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
else
echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
fi
- name: Generate changelog
id: changelog
run: |
# Generate changelog from git log
if git describe --tags --abbrev=0 2>/dev/null; then
PREV_TAG=$(git describe --tags --abbrev=0 2>/dev/null | head -1)
CHANGELOG=$(git log ${PREV_TAG}..HEAD --pretty=format:"- %s (%h)" --no-merges)
else
CHANGELOG=$(git log --pretty=format:"- %s (%h)" --no-merges | head -20)
fi
echo "changelog<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Determine release type
id: release-type
run: |
VERSION="${{ steps.get-version.outputs.version }}"
if [[ "$VERSION" == *alpha* ]] || [[ "$VERSION" == *beta* ]] || [[ "$VERSION" == *rc* ]]; then
echo "is_prerelease=true" >> $GITHUB_OUTPUT
echo "channel=alpha" >> $GITHUB_OUTPUT
else
echo "is_prerelease=false" >> $GITHUB_OUTPUT
echo "channel=stable" >> $GITHUB_OUTPUT
fi
- name: Create Release
id: create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.get-version.outputs.version }}
release_name: Release v${{ steps.get-version.outputs.version }}
body: |
## 🚀 Release v${{ steps.get-version.outputs.version }}
**Channel**: ${{ steps.release-type.outputs.channel }}
### Changes
${{ steps.changelog.outputs.changelog }}
### Installation
**One-Command Install (Latest Stable):**
```bash
curl -fsSL https://raw.githubusercontent.com/${{ github.repository }}/main/install.sh | bash
```
**Install This Specific Version:**
```bash
curl -fsSL https://raw.githubusercontent.com/${{ github.repository }}/main/install.sh | bash -s -- --version ${{ steps.get-version.outputs.version }}
```
**Other Channels:**
```bash
# Latest alpha/pre-release
curl -fsSL ... | bash -s -- --alpha
# Latest nightly (built from main)
curl -fsSL ... | bash -s -- --nightly
```
**Docker:**
```bash
docker pull ghcr.io/${{ github.repository }}:${{ steps.get-version.outputs.version }}
```
**Obsidian Plugin:**
Download `thoth-obsidian-${{ steps.get-version.outputs.version }}.zip` from the assets below and extract to `.obsidian/plugins/thoth-obsidian/`
draft: false
prerelease: ${{ steps.release-type.outputs.is_prerelease }}
build-setup-image:
name: Build Setup Image
needs: create-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}}-setup,value=${{ needs.create-release.outputs.version }}
type=raw,value=setup
- name: Build and push setup image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile.setup
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-service-images:
name: Build Service Images
needs: create-release
runs-on: ubuntu-latest
strategy:
matrix:
service: [api, mcp, pdf-monitor, discovery]
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Determine if stable
id: release-type
run: |
VERSION="${{ needs.create-release.outputs.version }}"
if [[ "$VERSION" == *alpha* ]] || [[ "$VERSION" == *beta* ]] || [[ "$VERSION" == *rc* ]] || [[ "$VERSION" == *nightly* ]]; then
echo "is_stable=false" >> $GITHUB_OUTPUT
else
echo "is_stable=true" >> $GITHUB_OUTPUT
fi
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}/${{ matrix.service }}
tags: |
type=raw,value=${{ needs.create-release.outputs.version }}
type=semver,pattern={{major}}.{{minor}},value=${{ needs.create-release.outputs.version }},enable=${{ steps.release-type.outputs.is_stable }}
type=raw,value=latest,enable=${{ steps.release-type.outputs.is_stable }}
type=raw,value=alpha,enable=${{ contains(needs.create-release.outputs.version, 'alpha') }}
- name: Build and push ${{ matrix.service }}
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/${{ matrix.service }}/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=${{ matrix.service }}
cache-to: type=gha,scope=${{ matrix.service }},mode=max
build-args: |
VERSION=${{ needs.create-release.outputs.version }}
# Dev images - used by docker-compose.dev.yml and the installer (pull instead of build)
build-dev-images:
name: Build Dev Image - ${{ matrix.service }}
needs: create-release
runs-on: ubuntu-latest
strategy:
matrix:
include:
- service: dev-api
dockerfile: Dockerfile
extras: service-api
- service: dev-mcp
dockerfile: docker/mcp/Dockerfile
extras: service-mcp
target: development
- service: dev-discovery
dockerfile: Dockerfile
extras: service-discovery
- service: dev-monitor
dockerfile: Dockerfile
extras: service-monitor
- service: dev-dashboard
dockerfile: Dockerfile
extras: service-dashboard
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Determine if stable
id: release-type
run: |
VERSION="${{ needs.create-release.outputs.version }}"
if [[ "$VERSION" == *alpha* ]] || [[ "$VERSION" == *beta* ]] || [[ "$VERSION" == *rc* ]] || [[ "$VERSION" == *nightly* ]]; then
echo "is_stable=false" >> $GITHUB_OUTPUT
else
echo "is_stable=true" >> $GITHUB_OUTPUT
fi
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}/${{ matrix.service }}
tags: |
type=raw,value=${{ needs.create-release.outputs.version }}
type=raw,value=latest,enable=${{ steps.release-type.outputs.is_stable }}
type=raw,value=alpha,enable=${{ contains(needs.create-release.outputs.version, 'alpha') }}
- name: Build and push ${{ matrix.service }}
uses: docker/build-push-action@v5
with:
context: .
file: ./${{ matrix.dockerfile }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
target: ${{ matrix.target || '' }}
cache-from: type=gha,scope=${{ matrix.service }}
cache-to: type=gha,scope=${{ matrix.service }},mode=max
build-args: |
SERVICE_EXTRAS=${{ matrix.extras }}
build-obsidian-plugin:
name: Build Obsidian Plugin
needs: create-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
cache-dependency-path: obsidian-plugin/thoth-obsidian/package-lock.json
- name: Install dependencies
run: |
cd obsidian-plugin/thoth-obsidian
npm ci
- name: Build plugin
run: |
cd obsidian-plugin/thoth-obsidian
npm run build
- name: Update manifest version
run: |
cd obsidian-plugin/thoth-obsidian
jq '.version = "${{ needs.create-release.outputs.version }}"' manifest.json > manifest.tmp
mv manifest.tmp manifest.json
- name: Package plugin
run: |
cd obsidian-plugin/thoth-obsidian
mkdir -p release
cp dist/main.js manifest.json styles.css release/
cd release
zip -r ../thoth-obsidian-${{ needs.create-release.outputs.version }}.zip .
- name: Upload plugin zip to release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ./obsidian-plugin/thoth-obsidian/thoth-obsidian-${{ needs.create-release.outputs.version }}.zip
asset_name: thoth-obsidian-${{ needs.create-release.outputs.version }}.zip
asset_content_type: application/zip