-
Notifications
You must be signed in to change notification settings - Fork 0
187 lines (170 loc) · 7 KB
/
release.yml
File metadata and controls
187 lines (170 loc) · 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
name: Release
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+' # v1.0.0
- 'v[0-9]+.[0-9]+.[0-9]+-*' # v1.0.0-beta.1
permissions:
contents: write # needed to create GitHub releases
jobs:
# ─────────────────────────────────────────────────────────────────────────
# 1. Verify all tests pass against the tagged commit before releasing
# ─────────────────────────────────────────────────────────────────────────
verify-sqlite:
name: Verify — SQLite tests
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: swift-actions/setup-swift@v2
with:
swift-version: "6.0"
- name: Install SQLite
run: sudo apt-get install -y libsqlite3-dev
- run: swift test --filter SQLiteNioTests
- run: swift test --filter SQLNioCoreTests
verify-postgres:
name: Verify — PostgreSQL tests
runs-on: ubuntu-24.04
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_DB: PostgresNioTestDb
POSTGRES_USER: pguser
POSTGRES_PASSWORD: pgPass123
ports: ["5432:5432"]
options: >-
--health-cmd "pg_isready -U pguser"
--health-interval 5s
--health-retries 10
steps:
- uses: actions/checkout@v4
- uses: swift-actions/setup-swift@v2
with:
swift-version: "6.0"
- name: Install SQLite
run: sudo apt-get install -y libsqlite3-dev
- name: Run PostgreSQL tests
env:
PG_TEST_HOST: "127.0.0.1"
PG_TEST_DB: PostgresNioTestDb
PG_TEST_USER: pguser
PG_TEST_PASS: pgPass123
run: swift test --filter PostgresNioTests
verify-mysql:
name: Verify — MySQL tests
runs-on: ubuntu-24.04
services:
mysql:
image: mysql:8
env:
MYSQL_DATABASE: MySQLNioTestDb
MYSQL_USER: mysqluser
MYSQL_PASSWORD: mysqlPass123
MYSQL_ROOT_PASSWORD: root
ports: ["3306:3306"]
options: >-
--health-cmd "mysqladmin ping -u mysqluser -pmysqlPass123"
--health-interval 5s
--health-retries 15
steps:
- uses: actions/checkout@v4
- uses: swift-actions/setup-swift@v2
with:
swift-version: "6.0"
- name: Install SQLite
run: sudo apt-get install -y libsqlite3-dev
- name: Run MySQL tests
env:
MYSQL_TEST_HOST: "127.0.0.1"
MYSQL_TEST_DB: MySQLNioTestDb
MYSQL_TEST_USER: mysqluser
MYSQL_TEST_PASS: mysqlPass123
run: swift test --filter MySQLNioTests
verify-mssql:
name: Verify — SQL Server tests
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: swift-actions/setup-swift@v2
with:
swift-version: "6.0"
- name: Install SQLite
run: sudo apt-get install -y libsqlite3-dev
- name: Run MSSQL tests
env:
MSSQL_TEST_HOST: ${{ secrets.MSSQL_TEST_HOST }}
MSSQL_TEST_PORT: ${{ secrets.MSSQL_TEST_PORT }}
MSSQL_TEST_DB: ${{ secrets.MSSQL_TEST_DB }}
MSSQL_TEST_USER: ${{ secrets.MSSQL_TEST_USER }}
MSSQL_TEST_PASS: ${{ secrets.MSSQL_TEST_PASS }}
run: swift test --filter MSSQLNioTests
# ─────────────────────────────────────────────────────────────────────────
# 2. Create the GitHub Release with auto-generated changelog
# ─────────────────────────────────────────────────────────────────────────
create-release:
name: Create GitHub Release
needs: [verify-sqlite, verify-postgres, verify-mysql, verify-mssql]
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # full history for changelog
- name: Extract version from tag
id: version
run: |
TAG="${GITHUB_REF_NAME}" # e.g. v1.2.3
VERSION="${TAG#v}" # e.g. 1.2.3
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
# Determine if this is a pre-release (contains a hyphen: v1.0.0-beta.1)
if [[ "$VERSION" == *-* ]]; then
echo "prerelease=true" >> "$GITHUB_OUTPUT"
else
echo "prerelease=false" >> "$GITHUB_OUTPUT"
fi
- name: Build changelog
id: changelog
run: |
# Find the previous tag (or root commit if this is the first release)
PREV_TAG=$(git tag --sort=-version:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+' \
| grep -v "^${{ steps.version.outputs.tag }}$" | head -1 || true)
if [[ -z "$PREV_TAG" ]]; then
RANGE="HEAD"
else
RANGE="${PREV_TAG}..HEAD"
fi
echo "## What's Changed" > changelog.md
echo "" >> changelog.md
# Group commits by type
{
FEATURES=$(git log $RANGE --pretty=format:"- %s (%h)" \
--grep='^feat' --regexp-ignore-case 2>/dev/null || true)
FIXES=$(git log $RANGE --pretty=format:"- %s (%h)" \
--grep='^fix' --regexp-ignore-case 2>/dev/null || true)
OTHERS=$(git log $RANGE --pretty=format:"- %s (%h)" \
--invert-grep --grep='^feat\|^fix' 2>/dev/null | head -20 || true)
[[ -n "$FEATURES" ]] && echo "### ✨ Features" && echo "$FEATURES" && echo ""
[[ -n "$FIXES" ]] && echo "### 🐛 Bug Fixes" && echo "$FIXES" && echo ""
[[ -n "$OTHERS" ]] && echo "### 🔧 Other Changes" && echo "$OTHERS" && echo ""
} >> changelog.md
{
echo "### 📦 Installation"
echo ""
echo '```swift'
echo ".package(url: \"https://github.com/${{ github.repository }}.git\","
echo " from: \"${{ steps.version.outputs.version }}\")"
echo '```'
} >> changelog.md
echo "body<<EOF" >> "$GITHUB_OUTPUT"
cat changelog.md >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.tag }}
name: CosmoSQLClient ${{ steps.version.outputs.tag }}
body: ${{ steps.changelog.outputs.body }}
draft: false
prerelease: ${{ steps.version.outputs.prerelease }}