-
Notifications
You must be signed in to change notification settings - Fork 1
136 lines (122 loc) · 4.06 KB
/
release.yml
File metadata and controls
136 lines (122 loc) · 4.06 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
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
packages: write
pull-requests: read
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
version: "latest"
enable-cache: true
- name: Set up Python
run: uv python install 3.11
- name: Install dependencies
run: uv sync --dev
- name: Run tests
env:
POSTGRES_USER: test_user
POSTGRES_PASSWORD: test_pass
POSTGRES_SERVER: localhost
POSTGRES_PORT: 5432
POSTGRES_DB: test_db
S3_ACCESS_KEY_ID: test_key
S3_ACCESS_KEY: test_secret
S3_BUCKET: test-bucket
REDIS_HOST: localhost
REDIS_PORT: 6379
ENVIRONMENT: testing
DEBUG: false
LOG_LEVEL: WARNING
services:
postgres:
image: postgres:15
env:
POSTGRES_USER: test_user
POSTGRES_PASSWORD: test_pass
POSTGRES_DB: test_db
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
redis:
image: redis:7
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
run: |
uv run pytest src/tests/ -v
- name: Extract version from tag
id: version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Build package
run: |
uv build
- name: Generate changelog
id: changelog
run: |
# Create changelog content
echo "## Changes in ${{ steps.version.outputs.tag }}" > RELEASE_CHANGELOG.md
echo "" >> RELEASE_CHANGELOG.md
# Get commits since last tag
LAST_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
if [ -z "$LAST_TAG" ]; then
echo "🎉 **Initial release**" >> RELEASE_CHANGELOG.md
echo "" >> RELEASE_CHANGELOG.md
echo "This is the first release of Web Service Python Template." >> RELEASE_CHANGELOG.md
else
echo "### Commits since $LAST_TAG:" >> RELEASE_CHANGELOG.md
echo "" >> RELEASE_CHANGELOG.md
git log --oneline $LAST_TAG..HEAD --pretty=format:"- %s (%h)" >> RELEASE_CHANGELOG.md
fi
echo "" >> RELEASE_CHANGELOG.md
echo "---" >> RELEASE_CHANGELOG.md
echo "" >> RELEASE_CHANGELOG.md
echo "### 📦 Installation" >> RELEASE_CHANGELOG.md
echo "" >> RELEASE_CHANGELOG.md
echo "\`\`\`bash" >> RELEASE_CHANGELOG.md
echo "git clone https://github.com/\${{ github.repository }}.git" >> RELEASE_CHANGELOG.md
echo "cd Web-Service-Python" >> RELEASE_CHANGELOG.md
echo "uv sync" >> RELEASE_CHANGELOG.md
echo "\`\`\`" >> RELEASE_CHANGELOG.md
echo "" >> RELEASE_CHANGELOG.md
echo "### 🐳 Docker" >> RELEASE_CHANGELOG.md
echo "" >> RELEASE_CHANGELOG.md
echo "\`\`\`bash" >> RELEASE_CHANGELOG.md
echo "cp .env-copy .env" >> RELEASE_CHANGELOG.md
echo "docker compose up -d" >> RELEASE_CHANGELOG.md
echo "\`\`\`" >> RELEASE_CHANGELOG.md
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.version.outputs.tag }}
name: Release ${{ steps.version.outputs.tag }}
body_path: RELEASE_CHANGELOG.md
files: |
dist/*
draft: false
prerelease: ${{ contains(steps.version.outputs.version, 'alpha') || contains(steps.version.outputs.version, 'beta') || contains(steps.version.outputs.version, 'rc') }}
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}