-
-
Notifications
You must be signed in to change notification settings - Fork 49
196 lines (181 loc) · 5.54 KB
/
build.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
name: Build
on:
push:
pull_request:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Lint
uses: ./.github/actions/lint
test:
runs-on: ubuntu-latest
needs: [lint]
services:
postgres:
image: postgres:alpine
ports:
- 5432:5432
env:
POSTGRES_USER: fief
POSTGRES_PASSWORD: fiefpassword
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
mariadb:
image: mariadb
ports:
- 3306:3306
env:
MARIADB_ROOT_PASSWORD: fiefpassword
mysql:
image: mysql
ports:
- 3307:3306
env:
MYSQL_ROOT_PASSWORD: fiefpassword
strategy:
fail-fast: false
matrix:
include:
- name: POSTGRESQL
database_type: POSTGRESQL
database_host: localhost
database_port: 5432
database_username: fief
database_password: fiefpassword
database_ssl_mode: disable
- name: MARIADB
database_type: MYSQL
database_host: localhost
database_port: 3306
database_username: root
database_password: fiefpassword
database_ssl_mode: DISABLED
- name: MYSQL
database_type: MYSQL
database_host: localhost
database_port: 3307
database_username: root
database_password: fiefpassword
database_ssl_mode: DISABLED
- name: SQLITE
database_type: SQLITE
database_host: null
database_port: null
database_username: null
database_password: null
database_ssl_mode: null
steps:
- uses: actions/checkout@v4
- name: Test with ${{ matrix.name }} database
uses: ./.github/actions/test
with:
database_type: ${{ matrix.database_type }}
database_host: ${{ matrix.database_host }}
database_port: ${{ matrix.database_port }}
database_username: ${{ matrix.database_username }}
database_password: ${{ matrix.database_password }}
database_name: fief
codecov_token: ${{ secrets.CODECOV_TOKEN }}
pypi-release:
runs-on: ubuntu-latest
needs: [test]
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
shell: bash
run: |
python -m pip install --upgrade pip
pip install hatch
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "18"
- name: Install Node dependencies
shell: bash
run: |
npm ci
- name: Compile translations, build assets and set telemetry key
shell: bash
env:
POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }}
run: |
hatch run translations.compile
hatch run static.build
hatch run telemetry.set-posthog-key $POSTHOG_API_KEY
- name: Build and publish on PyPI
env:
HATCH_INDEX_USER: ${{ secrets.HATCH_INDEX_USER }}
HATCH_INDEX_AUTH: ${{ secrets.HATCH_INDEX_AUTH }}
run: |
hatch build
hatch publish
- name: Create release
uses: ncipollo/release-action@v1
with:
draft: true
body: ${{ github.event.head_commit.message }}
artifacts: dist/*.whl,dist/*.tar.gz
token: ${{ secrets.GITHUB_TOKEN }}
docker-release:
runs-on: ubuntu-latest
needs: [pypi-release]
steps:
- uses: actions/checkout@v4
- name: Wait package to be truly available from PyPI
shell: bash
run: |
sleep 120
- name: Set raw version variable
shell: bash
run: |
echo "${{ github.ref_name }}" | sed "s/v/RAW_VERSION=$1/" >> $GITHUB_ENV
- name: Build Docker image
uses: ./.github/actions/docker-build
with:
fief_version: ${{ env.RAW_VERSION }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
registry: ghcr.io
image_name: ${{ github.repository }}
github_token: ${{ secrets.GITHUB_TOKEN }}
stronghold-build:
runs-on: ubuntu-latest
needs: [pypi-release]
steps:
- uses: actions/checkout@v4
- name: Wait package to be truly available from PyPI
shell: bash
run: |
sleep 120
- name: Set raw version variable
shell: bash
run: |
echo "${{ github.ref_name }}" | sed "s/v/RAW_VERSION=$1/" >> $GITHUB_ENV
- name: Generate a token
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.INTERNAL_GITHUB_APP_ID }}
private-key: ${{ secrets.INTERNAL_GITHUB_APP_PRIVATE_KEY }}
- name: Trigger Stronghold build
uses: octokit/[email protected]
with:
route: POST /repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches
owner: fief-dev
repo: stronghold
workflow_id: build.yml
fief_version: ${{ env.RAW_VERSION }}
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}