-
Notifications
You must be signed in to change notification settings - Fork 0
191 lines (164 loc) · 6.58 KB
/
cd.yml
File metadata and controls
191 lines (164 loc) · 6.58 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
name: CD
on:
push:
branches:
- main
workflow_dispatch:
inputs:
publish-prerelease:
description: 'Publish pre-release versions to npm/PyPI'
required: false
type: boolean
default: false
permissions:
contents: read
jobs:
# Validate release-ready state
validate:
name: Validate Release-Ready State
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install Node dependencies
run: npm ci
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Verify package versions
run: |
TS_VERSION=$(node -p "require('./packages/flarelette-jwt-ts/package.json').version")
PY_VERSION=$(python -c "import sys; sys.path.insert(0, 'packages/flarelette-jwt-py'); from flarelette_jwt import __version__; print(__version__)")
echo "TypeScript version: $TS_VERSION"
echo "Python version: $PY_VERSION"
echo "✓ Versions verified (packages follow independent versioning)"
- name: Build all packages
run: |
npm run build
cd packages/flarelette-jwt-py && python prepare.py && python -m build
- name: Verify TypeScript package metadata
working-directory: packages/flarelette-jwt-ts
run: |
echo "Checking package.json..."
node -e "
const pkg = require('./package.json');
if (!pkg.name) throw new Error('Missing name');
if (!pkg.version) throw new Error('Missing version');
if (!pkg.main) throw new Error('Missing main');
if (!pkg.types) throw new Error('Missing types');
if (!pkg.exports) throw new Error('Missing exports');
console.log('✓ Package metadata valid');
"
- name: Verify Python package metadata
working-directory: packages/flarelette-jwt-py
run: |
echo "Checking distribution..."
twine check dist/*
echo "✓ Python package metadata valid"
- name: Check for uncommitted changes
run: |
if [[ -n $(git status --porcelain) ]]; then
echo "❌ Uncommitted changes detected"
git status
exit 1
fi
echo "✓ No uncommitted changes"
- name: Verify documentation is up to date
run: |
echo "Checking for required documentation..."
test -f README.md || (echo "❌ Missing README.md" && exit 1)
test -f CONTRIBUTING.md || (echo "❌ Missing CONTRIBUTING.md" && exit 1)
test -f docs/getting-started.md || (echo "❌ Missing getting-started.md" && exit 1)
test -f docs/user-guide/core-concepts.md || (echo "❌ Missing user-guide/core-concepts.md" && exit 1)
test -f docs/user-guide/usage-guide.md || (echo "❌ Missing user-guide/usage-guide.md" && exit 1)
test -f docs/security-guide.md || (echo "❌ Missing security-guide.md" && exit 1)
echo "✓ All required documentation exists"
- name: Upload release artifacts
uses: actions/upload-artifact@v4
with:
name: release-artifacts
path: |
packages/flarelette-jwt-ts/dist/
packages/flarelette-jwt-py/dist/
retention-days: 30
# Pre-release publishing (optional, manual trigger only)
publish-prerelease:
name: Publish Pre-Release
runs-on: ubuntu-latest
needs: validate
if: github.event_name == 'workflow_dispatch' && github.event.inputs.publish-prerelease == 'true'
environment: prerelease
permissions:
contents: read
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: npm ci
- name: Install Python build tools
run: |
python -m pip install --upgrade pip
pip install build
- name: Get version and create pre-release tag
id: version
run: |
VERSION=$(node -p "require('./packages/flarelette-jwt-ts/package.json').version")
PRERELEASE_VERSION="${VERSION}-next.$(date +%s)"
echo "prerelease_version=$PRERELEASE_VERSION" >> $GITHUB_OUTPUT
echo "Pre-release version: $PRERELEASE_VERSION"
- name: Update package versions
run: |
cd packages/flarelette-jwt-ts
npm version ${{ steps.version.outputs.prerelease_version }} --no-git-tag-version
cd ../flarelette-jwt-py
# Update Python version in __init__.py
sed -i "s/__version__ = .*/__version__ = \"${{ steps.version.outputs.prerelease_version }}\"/" flarelette_jwt/__init__.py
- name: Build packages
run: |
npm run build
cd packages/flarelette-jwt-py && python prepare.py && python -m build
- name: Publish TypeScript to npm (next tag)
working-directory: packages/flarelette-jwt-ts
run: npm publish --provenance --tag next --access public
- name: Publish Python to PyPI (with pre-release classifier)
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: packages/flarelette-jwt-py/dist/
- name: Summary
run: |
echo "## Pre-Release Published 🚀" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Version:** ${{ steps.version.outputs.prerelease_version }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Installation" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**TypeScript:**" >> $GITHUB_STEP_SUMMARY
echo '```bash' >> $GITHUB_STEP_SUMMARY
echo "npm install @chrislyons-dev/flarelette-jwt@next" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Python:**" >> $GITHUB_STEP_SUMMARY
echo '```bash' >> $GITHUB_STEP_SUMMARY
echo "pip install flarelette-jwt==${{ steps.version.outputs.prerelease_version }}" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY