generated from matthieu-locussol/starter-turborepo-websocket-zod
-
Notifications
You must be signed in to change notification settings - Fork 4
181 lines (174 loc) · 6.43 KB
/
ci.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
name: CI
on:
push:
branches:
- master
tags:
- 'v*'
pull_request:
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.10.0'
- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: 9
run_install: false
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- run: pnpm install
- run: pnpm build
- run: pnpm test
startMaintenance:
name: Start Maintenance
runs-on: ubuntu-latest
needs: [build]
if: startsWith(github.ref, 'refs/tags/v')
steps:
- run: |
curl "${{ secrets.MAINTENANCE_ENDPOINT }}" \
-sSf \
-H 'Accept: application/json' \
-H 'Accept-Language: fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7' \
-H 'Connection: keep-alive' \
-H 'Content-Type: application/json' \
--data-raw '{"type":"start","token":"${{ secrets.MAINTENANCE_TOKEN }}"}' \
--compressed
deploy:
name: Update Server
runs-on: ubuntu-latest
needs: [startMaintenance]
if: startsWith(github.ref, 'refs/tags/v')
steps:
- run: echo "${{ secrets.SSHKEY }}" > key.pem
- run: chmod 600 key.pem
- run:
ssh -i key.pem ${{ secrets.USER }}@${{ secrets.HOST }} -o ConnectTimeout=1200 -o
StrictHostKeyChecking=no "cd ${{ secrets.DIR }} && git checkout . && git pull origin
master && ${{ secrets.INSTALL_COMMAND }} && ${{ secrets.BUILD_COMMAND }} && ${{
secrets.RESTART_COMMAND }}"
changelog:
name: Changelog
runs-on: ubuntu-latest
needs: [deploy]
if: startsWith(github.ref, 'refs/tags/v')
outputs:
changelog: ${{ steps.build_changelog.outputs.changelog }}
steps:
- uses: actions/checkout@v4
name: Checkout repository
with:
fetch-depth: 0
- name: Retrieve current tag
run:
echo "CURRENT_TAG=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' |
sed -n '1p')" >> "$GITHUB_ENV"
- name: Retrieve previous tag
run:
echo "PREV_TAG=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | sed
-n '2p')" >> "$GITHUB_ENV"
- name: Build changelog
id: build_changelog
run: |
{
echo "changelog<<EOF"
echo "$({ git log $PREV_TAG...$CURRENT_TAG --pretty=format:"- %s" | grep '^- feat' | sed 's/^- feat:/- New:/'; git log $PREV_TAG...$CURRENT_TAG --pretty=format:"- %s" | grep '^- fix' | sed 's/^- fix:/- Fixed/'; })"
echo EOF
} >> "$GITHUB_OUTPUT"
release:
name: Update Client
needs: [changelog]
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
strategy:
matrix:
include:
- platform: 'macos-latest' # for Arm based macs (M1 and above).
args: '--target aarch64-apple-darwin'
- platform: 'macos-latest' # for Intel based macs.
args: '--target x86_64-apple-darwin'
- platform: 'ubuntu-latest'
args: ''
- platform: 'windows-latest'
args: ''
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.10.0'
- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: 9
run_install: false
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
targets:
${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin'
|| '' }}
- name: install dependencies (ubuntu only)
if: matrix.platform == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
- run: pnpm install
- run: pnpm build:shared:noci
- run: pnpm build:noci
- uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
with:
tagName: v__VERSION__
releaseName: 'v__VERSION__'
releaseBody:
${{ needs.changelog.outputs.changelog || 'See the assets to download this version
and install it.' }}
releaseDraft: false
prerelease: false
args: ${{ matrix.args }}
endMaintenance:
name: End Maintenance
runs-on: ubuntu-latest
needs: [release]
if: startsWith(github.ref, 'refs/tags/v')
steps:
- run: |
curl "${{ secrets.MAINTENANCE_ENDPOINT }}" \
-sSf \
-H 'Accept: application/json' \
-H 'Accept-Language: fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7' \
-H 'Connection: keep-alive' \
-H 'Content-Type: application/json' \
--data-raw '{"type":"end","token":"${{ secrets.MAINTENANCE_TOKEN }}"}' \
--compressed