-
Notifications
You must be signed in to change notification settings - Fork 0
171 lines (143 loc) · 5.87 KB
/
Copy pathrelease.yml
File metadata and controls
171 lines (143 loc) · 5.87 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
name: Release
on:
push:
tags:
- 'v*.*.*'
jobs:
validate:
runs-on: ubuntu-latest
name: Validate Release
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
extensions: mbstring, xml, ctype, iconv, intl, pdo, dom, filter, gd, json, session
- name: Cache Composer packages
uses: actions/cache@v4
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-dev --optimize-autoloader
- name: Validate composer.json
run: composer validate --strict
- name: Check PHP syntax
run: find src -name "*.php" -exec php -l {} \;
- name: Install dependencies for validation
run: composer install --prefer-dist --no-progress
- name: Run comprehensive release validation
run: |
echo "🚀 Running comprehensive validation for release..."
echo "📋 Using consolidated quality check with auto-version detection"
scripts/quality/quality-check.sh
- name: Prepare release validation
run: |
echo "📦 Running release preparation validation..."
chmod +x scripts/release/prepare_release.sh
scripts/release/prepare_release.sh
release:
needs: validate
runs-on: ubuntu-latest
name: Create Release
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
extensions: mbstring, xml, ctype, iconv, intl, pdo, dom, filter, gd, json, session
- name: Install dependencies (production only)
run: composer install --prefer-dist --no-progress --no-dev --optimize-autoloader
- name: Get tag version
id: tag_version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Get version from VERSION file
id: version_file
run: |
if [ -f "VERSION" ]; then
FILE_VERSION=$(cat VERSION | tr -d '\n')
echo "FILE_VERSION=$FILE_VERSION" >> $GITHUB_OUTPUT
else
echo "FILE_VERSION=unknown" >> $GITHUB_OUTPUT
fi
- name: Verify version consistency
run: |
TAG_VERSION="${{ steps.tag_version.outputs.VERSION }}"
FILE_VERSION="${{ steps.version_file.outputs.FILE_VERSION }}"
# Remove 'v' prefix from tag if present
TAG_VERSION_CLEAN=${TAG_VERSION#v}
if [ "$TAG_VERSION_CLEAN" != "$FILE_VERSION" ]; then
echo "❌ Version mismatch: Tag '$TAG_VERSION_CLEAN' vs VERSION file '$FILE_VERSION'"
exit 1
else
echo "✅ Version consistency verified: $FILE_VERSION"
fi
- name: Create archive
run: |
# Create clean directory for packaging
mkdir -p build/pivotphp-core
# Copy source files
cp -r src build/pivotphp-core/
cp composer.json build/pivotphp-core/
cp README.md build/pivotphp-core/
cp LICENSE build/pivotphp-core/
cp VERSION build/pivotphp-core/
cp -r docs build/pivotphp-core/
# Create tarball
cd build
tar -czf pivotphp-core-${{ steps.tag_version.outputs.VERSION }}.tar.gz pivotphp-core/
zip -r pivotphp-core-${{ steps.tag_version.outputs.VERSION }}.zip pivotphp-core/
- name: Generate changelog
id: changelog
run: |
# Extract changelog for this version from git commits
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
if [ -n "$PREVIOUS_TAG" ]; then
CHANGELOG=$(git log $PREVIOUS_TAG..HEAD --pretty=format:"- %s" --reverse)
else
CHANGELOG=$(git log --pretty=format:"- %s" --reverse)
fi
# Save changelog to file for GitHub release
echo "## What's Changed in ${{ steps.version_file.outputs.FILE_VERSION }}" > changelog.md
echo "" >> changelog.md
echo "$CHANGELOG" >> changelog.md
echo "" >> changelog.md
echo "## 🚀 PivotPHP Core Features" >> changelog.md
echo "" >> changelog.md
echo "- **High Performance**: Optimized object pooling and memory management" >> changelog.md
echo "- **Express.js API**: Familiar and intuitive routing and middleware" >> changelog.md
echo "- **PSR Compliance**: Full PSR-7, PSR-15, and PSR-12 support" >> changelog.md
echo "- **Automatic Version Detection**: All scripts use VERSION file" >> changelog.md
echo "- **Consolidated Scripts**: Streamlined development workflow" >> changelog.md
echo "" >> changelog.md
echo "**Full Changelog**: https://github.com/PivotPHP/pivotphp-core/compare/$PREVIOUS_TAG...${{ steps.tag_version.outputs.VERSION }}" >> changelog.md
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.tag_version.outputs.VERSION }}
name: PivotPHP Core ${{ steps.tag_version.outputs.VERSION }}
body_path: changelog.md
files: |
build/pivotphp-core-${{ steps.tag_version.outputs.VERSION }}.tar.gz
build/pivotphp-core-${{ steps.tag_version.outputs.VERSION }}.zip
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
packagist:
needs: [validate, release]
runs-on: ubuntu-latest
name: Update Packagist
steps:
- name: Update Packagist
run: |
echo "📦 Updating Packagist for PivotPHP Core..."
curl -XPOST -H'content-type:application/json' 'https://packagist.org/api/update-package?username=PivotPHP&apiToken=${{ secrets.PACKAGIST_TOKEN }}' \
-d'{"repository":{"url":"https://github.com/PivotPHP/pivotphp-core"}}'
continue-on-error: true