Skip to content

Commit cc3cc9c

Browse files
committed
feat: add publish-to-releases workflow for GitHub releases
- Add publish-to-releases.yml workflow - Automates downloading artifacts from php-grpc-1.8RC - Creates GitHub releases with pre-compiled gRPC extensions - Supports manual trigger with gRPC version, PHP version, and source run ID - Updates README with usage instructions and workflow details
1 parent fc3e736 commit cc3cc9c

2 files changed

Lines changed: 251 additions & 1 deletion

File tree

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
name: Publish gRPC to GitHub Releases
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
grpc_version:
7+
description: 'gRPC Version (e.g., 1.80.0RC1, 1.80.0)'
8+
required: true
9+
default: '1.80.0'
10+
php_version:
11+
description: 'PHP Version (e.g., 8.3)'
12+
required: true
13+
default: '8.3'
14+
source_run_id:
15+
description: 'GitHub Actions Run ID dari php-grpc-1.8RC (opsional, otomatis jika kosong)'
16+
required: false
17+
18+
jobs:
19+
publish-release:
20+
name: Publish to GitHub Releases
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v4
26+
27+
- name: Find Build Artifacts
28+
id: find-artifacts
29+
env:
30+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
GRPC_VERSION: ${{ github.event.inputs.grpc_version }}
32+
PHP_VERSION: ${{ github.event.inputs.php_version }}
33+
RUN_ID: ${{ github.event.inputs.source_run_id }}
34+
run: |
35+
# Jika run_id tidak diberikan, cari yang terbaru dengan grpc_version dan php_version
36+
if [ -z "$RUN_ID" ]; then
37+
echo "Searching for latest build artifacts..."
38+
RUN_ID=$(gh run list \
39+
--repo agissept/php-grpc-1.8RC \
40+
--workflow build-grpc.yml \
41+
--status success \
42+
--json databaseId,headBranch \
43+
--jq ".[] | select(.headBranch == \"main\" or .headBranch == \"master\") | .databaseId" \
44+
| head -1)
45+
46+
if [ -z "$RUN_ID" ]; then
47+
echo "❌ No successful build found. Please provide source_run_id manually."
48+
exit 1
49+
fi
50+
fi
51+
52+
echo "Using Run ID: $RUN_ID"
53+
echo "run_id=$RUN_ID" >> $GITHUB_OUTPUT
54+
55+
- name: Download Artifacts from php-grpc-1.8RC
56+
id: download
57+
env:
58+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
RUN_ID: ${{ steps.find-artifacts.outputs.run_id }}
60+
PHP_VERSION: ${{ github.event.inputs.php_version }}
61+
GRPC_VERSION: ${{ github.event.inputs.grpc_version }}
62+
run: |
63+
mkdir -p artifacts
64+
65+
# Download artifacts from the build repo
66+
gh run download $RUN_ID \
67+
--repo agissept/php-grpc-1.8RC \
68+
--dir artifacts \
69+
--pattern "*php${PHP_VERSION}*"
70+
71+
# List downloaded files
72+
echo "Downloaded files:"
73+
find artifacts -type f -name "grpc.so"
74+
75+
# Rename files for clarity
76+
echo "Renaming files..."
77+
find artifacts -name "grpc.so" | while read file; do
78+
dirname=$(dirname "$file")
79+
80+
# Extract arch from directory name
81+
if [[ "$dirname" == *"amd64"* ]]; then
82+
mv "$file" "artifacts/grpc-amd64.so"
83+
elif [[ "$dirname" == *"arm64"* ]]; then
84+
mv "$file" "artifacts/grpc-arm64.so"
85+
fi
86+
done
87+
88+
echo "Final artifacts:"
89+
ls -lh artifacts/
90+
91+
- name: Create Release
92+
env:
93+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
94+
GRPC_VERSION: ${{ github.event.inputs.grpc_version }}
95+
PHP_VERSION: ${{ github.event.inputs.php_version }}
96+
run: |
97+
RELEASE_TAG="v${GRPC_VERSION}-php${PHP_VERSION}"
98+
RELEASE_NAME="gRPC ${GRPC_VERSION} for PHP ${PHP_VERSION}"
99+
100+
# Create release with assets
101+
gh release create "$RELEASE_TAG" \
102+
--title "$RELEASE_NAME" \
103+
--notes "Pre-compiled gRPC extension for PHP ${PHP_VERSION}
104+
105+
**gRPC Version:** ${GRPC_VERSION}
106+
**PHP Version:** ${PHP_VERSION}
107+
**Built on:** Ubuntu 22.04
108+
**Architectures:** AMD64, ARM64
109+
110+
## Usage in Dockerfile
111+
112+
\`\`\`dockerfile
113+
# Download and install gRPC
114+
RUN curl -L -o /tmp/grpc-amd64.so \\
115+
https://github.com/${{ github.repository }}/releases/download/${RELEASE_TAG}/grpc-amd64.so && \\
116+
mv /tmp/grpc-amd64.so /usr/local/lib/php/extensions/no-debug-non-zts-20220829/grpc.so && \\
117+
docker-php-ext-enable grpc
118+
\`\`\`
119+
120+
**Artifacts:**
121+
- \`grpc-amd64.so\` - AMD64 (x86_64) architecture
122+
- \`grpc-arm64.so\` - ARM64 architecture
123+
" \
124+
artifacts/grpc-amd64.so \
125+
artifacts/grpc-arm64.so
126+
127+
echo "✅ Release $RELEASE_TAG created successfully!"
128+
129+
- name: Print Release Info
130+
env:
131+
GRPC_VERSION: ${{ github.event.inputs.grpc_version }}
132+
PHP_VERSION: ${{ github.event.inputs.php_version }}
133+
run: |
134+
RELEASE_TAG="v${GRPC_VERSION}-php${PHP_VERSION}"
135+
136+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
137+
echo "✅ Release Published Successfully!"
138+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
139+
echo ""
140+
echo "Release Tag: $RELEASE_TAG"
141+
echo "Release URL: https://github.com/${{ github.repository }}/releases/tag/$RELEASE_TAG"
142+
echo ""
143+
echo "Download URLs:"
144+
echo " AMD64: https://github.com/${{ github.repository }}/releases/download/$RELEASE_TAG/grpc-amd64.so"
145+
echo " ARM64: https://github.com/${{ github.repository }}/releases/download/$RELEASE_TAG/grpc-arm64.so"
146+
echo ""
147+
echo "Dockerfile Usage:"
148+
echo " RUN curl -L -o /tmp/grpc.so \\"
149+
echo " https://github.com/${{ github.repository }}/releases/download/$RELEASE_TAG/grpc-amd64.so && \\"
150+
echo " mv /tmp/grpc.so /usr/local/lib/php/extensions/no-debug-non-zts-20220829/ && \\"
151+
echo " docker-php-ext-enable grpc"
152+
echo ""
153+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"

README.md

Lines changed: 98 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,98 @@
1-
# php-grpc-1.8RC
1+
# PHP gRPC Releases
2+
3+
Automated release management for pre-compiled PHP gRPC extensions.
4+
5+
This repository downloads gRPC extensions built from [php-grpc-1.8RC](https://github.com/agissept/php-grpc-1.8RC) and publishes them to GitHub Releases for easy distribution.
6+
7+
## Usage
8+
9+
### Option 1: Download Binary Files
10+
Download pre-compiled `.so` files from [Releases](https://github.com/agissept/php-grpc-releases/releases)
11+
12+
### Option 2: Use in Dockerfile
13+
14+
```dockerfile
15+
# Example for PHP 8.3 with gRPC v1.80.0
16+
FROM php:8.3.29-fpm
17+
18+
# Download gRPC extension from GitHub Releases
19+
RUN curl -L -o /tmp/grpc.so \
20+
https://github.com/agissept/php-grpc-releases/releases/download/v1.80.0-php8.3/grpc-amd64.so && \
21+
mv /tmp/grpc.so /usr/local/lib/php/extensions/no-debug-non-zts-20220829/ && \
22+
docker-php-ext-enable grpc
23+
```
24+
25+
## How It Works
26+
27+
1. Build gRPC in [php-grpc-1.8RC](https://github.com/agissept/php-grpc-1.8RC) using GitHub Actions
28+
2. Trigger this repo's workflow with the build run ID
29+
3. Artifacts are automatically downloaded and published to GitHub Releases
30+
4. Use the release URL in your Dockerfile
31+
32+
## Workflow: Publish gRPC to GitHub Releases
33+
34+
**Trigger:** Manual (workflow_dispatch)
35+
36+
**Inputs:**
37+
- `grpc_version` - gRPC version (e.g., 1.80.0RC1, 1.80.0)
38+
- `php_version` - PHP version (e.g., 8.3)
39+
- `source_run_id` - GitHub Actions Run ID (optional, auto-finds latest if empty)
40+
41+
**Steps:**
42+
1. Find build artifacts from php-grpc-1.8RC
43+
2. Download AMD64 and ARM64 binaries
44+
3. Create GitHub Release with assets
45+
4. Generate download URLs
46+
47+
## Release Format
48+
49+
Releases use the following convention:
50+
```
51+
Tag: v{GRPC_VERSION}-php{PHP_VERSION}
52+
Example: v1.80.0-php8.3
53+
```
54+
55+
Each release includes:
56+
- `grpc-amd64.so` - AMD64 architecture
57+
- `grpc-arm64.so` - ARM64 architecture
58+
59+
## Architecture
60+
61+
```
62+
php-grpc-1.8RC (Build gRPC)
63+
64+
Artifacts (amd64, arm64)
65+
66+
php-grpc-releases (Publish)
67+
68+
GitHub Releases (Public Download)
69+
70+
Your Dockerfile (Use in container)
71+
```
72+
73+
## Supported Versions
74+
75+
- PHP: 8.1, 8.2, 8.3
76+
- gRPC: 1.80.0+
77+
78+
## How to Create a Release
79+
80+
1. Go to [php-grpc-1.8RC](https://github.com/agissept/php-grpc-1.8RC/actions/workflows/build-grpc.yml)
81+
2. Click "Run workflow"
82+
3. Fill in:
83+
- gRPC Version: `1.80.0` (or desired version)
84+
- PHP Version: `8.3` (or desired version)
85+
4. Wait for build to complete
86+
5. Note the Run ID from the completed workflow
87+
6. Go to [this repo's Actions](https://github.com/agissept/php-grpc-releases/actions/workflows/publish-to-releases.yml)
88+
7. Click "Run workflow"
89+
8. Fill in:
90+
- gRPC Version: `1.80.0`
91+
- PHP Version: `8.3`
92+
- Source Run ID: (the ID from step 5, optional if auto-finds it)
93+
9. Wait for release to be created
94+
10. Download from [Releases](https://github.com/agissept/php-grpc-releases/releases)
95+
96+
## License
97+
98+
Same as [php-grpc-1.8RC](https://github.com/agissept/php-grpc-1.8RC)

0 commit comments

Comments
 (0)