-
Notifications
You must be signed in to change notification settings - Fork 1
222 lines (194 loc) · 7.14 KB
/
Copy pathfeat-test-release.yml
File metadata and controls
222 lines (194 loc) · 7.14 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
name: Test Build (feat/test)
on:
push:
branches:
- "feat/test"
workflow_dispatch:
permissions:
contents: write
jobs:
build-desktop:
name: Build Desktop (${{ matrix.platform }})
strategy:
matrix:
include:
- os: macos-latest
platform: mac
command: build:mac
- os: windows-latest
platform: win
command: build:win
- os: ubuntu-latest
platform: linux
command: build:linux
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: "pnpm"
- name: Install dependencies
env:
NPM_CONFIG_REGISTRY: https://registry.npmjs.org/
run: pnpm install --no-frozen-lockfile
- name: Build Desktop App
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: pnpm --filter @bookdock/desktop run ${{ matrix.command }}
- name: Upload Release Assets (Draft)
uses: softprops/action-gh-release@v2
with:
tag_name: test-build
name: Test Build (feat/test)
draft: true
files: |
apps/desktop/release/*.dmg
apps/desktop/release/*.zip
apps/desktop/release/*.exe
apps/desktop/release/*.AppImage
apps/desktop/release/*.deb
apps/desktop/release/*.blockmap
apps/desktop/release/latest*.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set version
id: version
shell: bash
run: echo "version=$(node -p "require('./apps/desktop/package.json').version")" >> $GITHUB_OUTPUT
- name: Upload artifacts to Minio
shell: bash
env:
MINIO_ENDPOINT: ${{ secrets.MINIO_ENDPOINT }}
MINIO_BUCKET: ${{ secrets.MINIO_BUCKET }}
MINIO_ACCESS: ${{ secrets.MINIO_ACCESS }}
MINIO_SECRET: ${{ secrets.MINIO_SECRET }}
MINIO_REGION: ${{ secrets.MINIO_REGION || 'us-east-1' }}
run: |
export AWS_ACCESS_KEY_ID="${MINIO_ACCESS}"
export AWS_SECRET_ACCESS_KEY="${MINIO_SECRET}"
export AWS_DEFAULT_REGION="${MINIO_REGION}"
aws s3 sync apps/desktop/release/ "s3://${MINIO_BUCKET}/bookdock/releases/${{ steps.version.outputs.version }}/" --endpoint-url "${MINIO_ENDPOINT}"
build-android:
name: Build Android
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: "zulu"
java-version: "17"
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: "pnpm"
- name: Install dependencies
env:
NPM_CONFIG_REGISTRY: https://registry.npmjs.org/
run: pnpm install --no-frozen-lockfile
- name: Build Android APK
run: |
cd apps/mobile/android
chmod +x gradlew
./gradlew assembleRelease
- name: Rename and Prepare APK
id: prepare_apk
run: |
VERSION=$(node -p "require('./apps/mobile/app.json').expo.version")
OLD_PATH="apps/mobile/android/app/build/outputs/apk/release/app-release.apk"
NEW_NAME="BookDock-${VERSION}-test.apk"
NEW_PATH="apps/mobile/android/app/build/outputs/apk/release/${NEW_NAME}"
mv "$OLD_PATH" "$NEW_PATH"
echo "apk_path=$NEW_PATH" >> $GITHUB_OUTPUT
echo "apk_name=$NEW_NAME" >> $GITHUB_OUTPUT
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Upload Release Assets (Draft)
uses: softprops/action-gh-release@v2
with:
tag_name: test-build
name: Test Build (feat/test)
draft: true
files: |
${{ steps.prepare_apk.outputs.apk_path }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Upload APK to Minio
env:
MINIO_ENDPOINT: ${{ secrets.MINIO_ENDPOINT }}
MINIO_BUCKET: ${{ secrets.MINIO_BUCKET }}
MINIO_ACCESS: ${{ secrets.MINIO_ACCESS }}
MINIO_SECRET: ${{ secrets.MINIO_SECRET }}
MINIO_REGION: ${{ secrets.MINIO_REGION || 'us-east-1' }}
run: |
export AWS_ACCESS_KEY_ID="${MINIO_ACCESS}"
export AWS_SECRET_ACCESS_KEY="${MINIO_SECRET}"
export AWS_DEFAULT_REGION="${MINIO_REGION}"
aws s3 cp "${{ steps.prepare_apk.outputs.apk_path }}" "s3://${MINIO_BUCKET}/bookdock/releases/${{ steps.prepare_apk.outputs.version }}/${{ steps.prepare_apk.outputs.apk_name }}" --endpoint-url "${MINIO_ENDPOINT}"
build-server-docker:
name: Build & Push Server Docker (feat-test)
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to Harbor
uses: docker/login-action@v3
with:
registry: ${{ secrets.HARBOR_REGISTRY }}
username: ${{ secrets.HARBOR_USERNAME }}
password: ${{ secrets.HARBOR_PASSWORD }}
- name: Set lowercase image name
id: image_name
run: |
REPO_LOWER=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
NAME_LOWER=$(echo "${{ github.event.repository.name }}" | tr '[:upper:]' '[:lower:]')
OWNER_LOWER=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
DOCKERHUB_USER_LOWER=$(echo "${{ secrets.DOCKERHUB_USERNAME }}" | tr '[:upper:]' '[:lower:]')
echo "ghcr=${REGISTRY}/${REPO_LOWER}" >> $GITHUB_OUTPUT
echo "dockerhub=${DOCKERHUB_USER_LOWER}/${NAME_LOWER}" >> $GITHUB_OUTPUT
echo "harbor=${{ secrets.HARBOR_REGISTRY }}/audiodock/${NAME_LOWER}" >> $GITHUB_OUTPUT
env:
REGISTRY: ghcr.io
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
target: runner
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ steps.image_name.outputs.ghcr }}:feat-test
${{ steps.image_name.outputs.dockerhub }}:feat-test
${{ steps.image_name.outputs.harbor }}:feat-test