-
Notifications
You must be signed in to change notification settings - Fork 0
231 lines (195 loc) · 6.4 KB
/
release.yml
File metadata and controls
231 lines (195 loc) · 6.4 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
name: Release
on:
push:
tags:
- 'v*'
env:
DOCKER_IMAGE: manfredsteger/polly
NODE_VERSION: '22'
permissions:
contents: write
packages: write
jobs:
validate:
name: Validate & Test
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15
env:
POSTGRES_USER: test
POSTGRES_PASSWORD: test
POSTGRES_DB: polly_test
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Type Check
run: npx tsc --noEmit
- name: Validate Translations
run: node scripts/validate-translations.cjs
- name: Wait for PostgreSQL
run: |
until pg_isready -h localhost -p 5432 -U test; do
echo "Waiting for PostgreSQL..."
sleep 2
done
- name: Setup test database
env:
DATABASE_URL: postgresql://test:test@localhost:5432/polly_test
run: npm run db:push
- name: Run tests
env:
DATABASE_URL: postgresql://test:test@localhost:5432/polly_test
NODE_ENV: test
run: npx vitest run --no-file-parallelism
- name: Build
run: npm run build
docker:
name: Build & Push Docker Image
runs-on: ubuntu-latest
needs: validate
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Extract version from tag
id: version
run: |
TAG=${GITHUB_REF#refs/tags/v}
echo "version=$TAG" >> $GITHUB_OUTPUT
echo "Version: $TAG"
# Determine additional tags
if [[ "$TAG" == *"beta"* ]]; then
echo "channel=beta" >> $GITHUB_OUTPUT
elif [[ "$TAG" == *"rc"* ]]; then
echo "channel=rc" >> $GITHUB_OUTPUT
else
echo "channel=latest" >> $GITHUB_OUTPUT
fi
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
${{ env.DOCKER_IMAGE }}:${{ steps.version.outputs.version }}
${{ env.DOCKER_IMAGE }}:${{ steps.version.outputs.channel }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64
- name: Verify image
run: |
docker pull ${{ env.DOCKER_IMAGE }}:${{ steps.version.outputs.version }}
echo "Image size:"
docker images ${{ env.DOCKER_IMAGE }}:${{ steps.version.outputs.version }} --format "{{.Size}}"
github-release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: docker
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract version from tag
id: version
run: |
TAG=${GITHUB_REF#refs/tags/v}
echo "version=$TAG" >> $GITHUB_OUTPUT
if [[ "$TAG" == *"beta"* ]] || [[ "$TAG" == *"rc"* ]]; then
echo "prerelease=true" >> $GITHUB_OUTPUT
else
echo "prerelease=false" >> $GITHUB_OUTPUT
fi
- name: Generate changelog
id: changelog
run: |
# Get previous tag
PREV_TAG=$(git tag --sort=-v:refname | grep -v "^${GITHUB_REF#refs/tags/}" | head -1)
if [ -z "$PREV_TAG" ]; then
# First release - show all commits
CHANGES=$(git log --pretty=format:"- %s (%h)" --no-merges HEAD | head -50)
else
CHANGES=$(git log --pretty=format:"- %s (%h)" --no-merges ${PREV_TAG}..HEAD | head -50)
fi
# Write to file to handle multiline
cat > /tmp/changelog.md << 'HEREDOC'
## Docker
```bash
docker pull manfredsteger/polly:${{ steps.version.outputs.version }}
```
## Quick Start
```bash
# Clone and start
git clone https://github.com/manfredsteger/polly.git
cd polly
git checkout v${{ steps.version.outputs.version }}
make setup
```
## Changes
HEREDOC
echo "$CHANGES" >> /tmp/changelog.md
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: Polly v${{ steps.version.outputs.version }}
body_path: /tmp/changelog.md
prerelease: ${{ steps.version.outputs.prerelease }}
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
update-dockerhub-readme:
name: Update Docker Hub README
runs-on: ubuntu-latest
needs: docker
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Update Docker Hub description
uses: peter-evans/dockerhub-description@v5
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: manfredsteger/polly
readme-filepath: ./DOCKERHUB.md
short-description: "Self-hosted polling & scheduling platform — open-source Doodle/Calendly alternative"
mirror-gitlab:
name: Mirror to GitLab
runs-on: ubuntu-latest
needs: github-release
steps:
- name: Checkout
uses: actions/checkout@v4
if: ${{ env.HAS_GITLAB_TOKEN == 'true' }}
with:
fetch-depth: 0
- name: Push to GitLab
if: ${{ env.HAS_GITLAB_TOKEN == 'true' }}
env:
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
run: |
git remote add gitlab https://oauth2:${GITLAB_TOKEN}@projekte.services.kita.bayern/entwicklung/termine/polly.git 2>/dev/null || true
git push gitlab ${GITHUB_REF} 2>/dev/null || echo "GitLab mirror push skipped (token not set or access denied)"
env:
HAS_GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN != '' }}