-
Notifications
You must be signed in to change notification settings - Fork 0
285 lines (247 loc) · 10.2 KB
/
Copy pathrelease.yml
File metadata and controls
285 lines (247 loc) · 10.2 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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
# =============================================================================
# TelemetryFlow PHP SDK - Release Workflow
# =============================================================================
#
# TelemetryFlow PHP SDK - AI-Powered Observability & Incident Response Management (IRM) Platform
# Copyright (c) 2024-2026 Telemetri Data Indonesia. All rights reserved.
#
# Builds and releases the TelemetryFlow PHP SDK:
# - Standalone telemetryflow-gen.phar (no PHP deps required to run)
# - SHA256 checksums
# - GitHub Release with generated notes
#
# Packages are also published to Packagist via the tag webhook (automatic).
#
# Triggers:
# - Push tags matching v*.*.*
# - Manual workflow dispatch
#
# =============================================================================
name: Release - TFO PHP SDK
on:
push:
tags:
- 'v*.*.*'
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., 1.0.0)'
required: true
default: '1.0.0'
prerelease:
description: 'Mark as pre-release'
required: false
type: boolean
default: false
env:
PHP_VERSION: '8.2'
PRODUCT_NAME: TelemetryFlow PHP SDK
VENDOR: Telemetri Data Indonesia
MAINTAINER: support@telemetryflow.id
HOMEPAGE: https://telemetryflow.id
permissions:
contents: write
packages: write
jobs:
# ===========================================================================
# Prepare Release
# ===========================================================================
prepare:
name: Prepare Release
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
commit: ${{ steps.version.outputs.commit }}
branch: ${{ steps.version.outputs.branch }}
build_time: ${{ steps.version.outputs.build_time }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Determine version
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="${{ github.event.inputs.version }}"
else
VERSION="${GITHUB_REF#refs/tags/v}"
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "commit=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "branch=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_OUTPUT
echo "build_time=$(date -u '+%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
# ===========================================================================
# Run full quality gate before releasing
# ===========================================================================
test:
name: Quality Gate
runs-on: ubuntu-latest
needs: prepare
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION }}
extensions: json, zip
coverage: xdebug
ini-values: error_reporting=E_ALL
- name: Install dependencies
run: composer install --no-interaction --prefer-dist
- name: Static analysis (PHPStan)
run: vendor/bin/phpstan analyse packages/php-native/src packages/laravel/src packages/generator/src --level=6 --no-progress
- name: Tests (php-native)
env:
XDEBUG_MODE: coverage
run: vendor/bin/phpunit --configuration packages/php-native/phpunit.xml.dist
- name: Tests (generator)
env:
XDEBUG_MODE: coverage
run: vendor/bin/phpunit --configuration packages/generator/phpunit.xml.dist
- name: Tests (laravel)
env:
XDEBUG_MODE: coverage
run: vendor/bin/phpunit --configuration packages/laravel/phpunit.xml.dist
# ===========================================================================
# Build the standalone Phar
# ===========================================================================
build-phar:
name: Build Phar
runs-on: ubuntu-latest
needs: [prepare, test]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION }}
extensions: json, zip, phar
ini-values: phar.readonly=0
- name: Install dependencies (no-dev for lean phar)
run: |
composer install --no-interaction --prefer-dist --no-dev
composer require symfony/console symfony/filesystem --no-interaction --no-update
composer install --no-interaction --prefer-dist
- name: Build the Phar
run: |
mkdir -p release
php -d phar.readonly=0 packages/generator/bin/build-phar.php
cp build/telemetryflow-gen.phar release/telemetryflow-gen-${{ needs.prepare.outputs.version }}.phar
- name: Verify the Phar
run: |
php release/telemetryflow-gen-${{ needs.prepare.outputs.version }}.phar version
php release/telemetryflow-gen-${{ needs.prepare.outputs.version }}.phar config --output /tmp/.env.telemetryflow
test -f /tmp/.env.telemetryflow && echo "Phar smoke test passed"
- name: Generate SHA256 checksums
run: |
cd release
sha256sum *.phar > checksums-sha256.txt
cat checksums-sha256.txt
- name: Upload Phar artifact
uses: actions/upload-artifact@v4
with:
name: telemetryflow-gen-phar
path: release/
retention-days: 30
# ===========================================================================
# Create the GitHub Release
# ===========================================================================
release:
name: Create Release
runs-on: ubuntu-latest
needs: [prepare, build-phar]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download Phar artifact
uses: actions/download-artifact@v4
with:
name: telemetryflow-gen-phar
path: release/
- name: Verify tag
run: |
TAG_NAME="v${{ needs.prepare.outputs.version }}"
if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then
echo "Tag $TAG_NAME already exists"
else
git tag "$TAG_NAME"
git push origin "$TAG_NAME"
fi
- name: Create Release
uses: softprops/action-gh-release@v2
with:
name: "${{ env.PRODUCT_NAME }} v${{ needs.prepare.outputs.version }}"
tag_name: "v${{ needs.prepare.outputs.version }}"
draft: false
prerelease: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.prerelease == 'true' }}
generate_release_notes: true
files: |
release/*
body: |
## ${{ env.PRODUCT_NAME }} v${{ needs.prepare.outputs.version }}
### Packages
| Package | Description |
|---------|-------------|
| `telemetryflow/php-native` | Framework-agnostic core SDK |
| `telemetryflow/laravel` | Laravel 10/11 integration |
| `telemetryflow/generator` | Symfony Console CLI generator |
### Installation
**Composer (recommended):**
```bash
composer require telemetryflow/php-native
composer require telemetryflow/laravel # optional Laravel integration
```
**Standalone Phar (no PHP project required):**
```bash
curl -LO https://github.com/telemetryflow/telemetryflow-php-sdk/releases/download/v${{ needs.prepare.outputs.version }}/telemetryflow-gen-${{ needs.prepare.outputs.version }}.phar
chmod +x telemetryflow-gen-${{ needs.prepare.outputs.version }}.phar
./telemetryflow-gen-${{ needs.prepare.outputs.version }}.phar version
```
**Docker:**
```bash
docker run --rm -v $(pwd):/workspace \
telemetryflow/telemetryflow-php-sdk:${{ needs.prepare.outputs.version }} \
init --project myapp --service my-service
```
### Usage
```bash
# Initialize SDK integration
telemetryflow-gen init --project myapp --service my-service
# Generate an example
telemetryflow-gen example basic --output ./example
```
### Verification
Verify downloads using SHA256 checksums in `checksums-sha256.txt`.
---
📚 [Documentation](https://docs.telemetryflow.id) | 🐛 [Report Issues](https://github.com/telemetryflow/telemetryflow-php-sdk/issues)
# ===========================================================================
# Summary
# ===========================================================================
summary:
name: Release Summary
runs-on: ubuntu-latest
needs: [prepare, test, build-phar, release]
if: always()
steps:
- name: Summary
run: |
echo "## ${{ env.PRODUCT_NAME }} - Release Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Item | Value |" >> $GITHUB_STEP_SUMMARY
echo "|------|-------|" >> $GITHUB_STEP_SUMMARY
echo "| **Version** | v${{ needs.prepare.outputs.version }} |" >> $GITHUB_STEP_SUMMARY
echo "| **Commit** | ${{ needs.prepare.outputs.commit }} |" >> $GITHUB_STEP_SUMMARY
echo "| **Build Time** | ${{ needs.prepare.outputs.build_time }} |" >> $GITHUB_STEP_SUMMARY
echo "| **Test** | ${{ needs.test.result }} |" >> $GITHUB_STEP_SUMMARY
echo "| **Phar** | ${{ needs.build-phar.result }} |" >> $GITHUB_STEP_SUMMARY
echo "| **Release** | ${{ needs.release.result }} |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Artifacts" >> $GITHUB_STEP_SUMMARY
echo "- \`telemetryflow-gen-${{ needs.prepare.outputs.version }}.phar\`" >> $GITHUB_STEP_SUMMARY
echo "- \`checksums-sha256.txt\`" >> $GITHUB_STEP_SUMMARY
echo "- Docker image: \`telemetryflow/telemetryflow-php-sdk:${{ needs.prepare.outputs.version }}\`" >> $GITHUB_STEP_SUMMARY