Skip to content

Commit e07967a

Browse files
committed
feat: CI for binaries allowing signing via kokoro
1 parent 070348b commit e07967a

File tree

1 file changed

+215
-15
lines changed

1 file changed

+215
-15
lines changed

.github/workflows/build-cli-binaries.yml

Lines changed: 215 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,16 @@ on:
2020
workflow_dispatch:
2121
inputs:
2222
version:
23-
description: 'Version tag to build (e.g., v1.0.0)'
23+
description: 'Version tag to build (e.g., v1.0.0, v1.0.0-rc.1)'
2424
required: true
2525
type: string
26-
upload_to_release:
27-
description: 'Upload binaries to GitHub release and update latest tag'
26+
create_rc:
27+
description: 'Create release candidate with unsigned binaries'
28+
required: false
29+
type: boolean
30+
default: false
31+
promote_rc:
32+
description: 'Promote RC to final release (requires signed binaries)'
2833
required: false
2934
type: boolean
3035
default: false
@@ -60,7 +65,7 @@ jobs:
6065
run: |
6166
VERSION="${{ inputs.version }}"
6267
if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.-]+)?(\+[a-zA-Z0-9.-]+)?$ ]]; then
63-
echo "Error: Version '$VERSION' does not follow semantic versioning format (e.g., v1.0.0, v1.0.0-beta.1)"
68+
echo "Error: Version '$VERSION' does not follow semantic versioning format (e.g., v1.0.0, v1.0.0-rc.1)"
6469
exit 1
6570
fi
6671
echo "✓ Version format is valid: $VERSION"
@@ -120,7 +125,7 @@ jobs:
120125
with:
121126
name: genkit-${{ matrix.target }}
122127
path: genkit-tools/cli/dist/bin/genkit-${{ matrix.target }}${{ steps.binary.outputs.ext }}
123-
retention-days: 1 # TODO: Consider increasing to 7 days for better debugging capability
128+
retention-days: 7 # Increased for better debugging and signing workflow
124129

125130
test:
126131
needs: build
@@ -274,15 +279,178 @@ jobs:
274279
# Clean up any remaining genkit processes
275280
Get-Process | Where-Object { $_.ProcessName -match "genkit" } | Stop-Process -Force -ErrorAction SilentlyContinue
276281
277-
create-release:
282+
create-rc:
283+
needs: [build, test]
284+
runs-on: ubuntu-latest
285+
if: inputs.create_rc == 'true'
286+
287+
steps:
288+
- name: Checkout code
289+
uses: actions/checkout@v4
290+
291+
- name: Generate changelog
292+
id: changelog
293+
run: |
294+
# Get the previous release tag
295+
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD~1 2>/dev/null || echo "")
296+
297+
if [[ -n "$PREVIOUS_TAG" ]]; then
298+
# Generate changelog from previous tag to current
299+
CHANGELOG=$(git log --pretty=format:"- %s" $PREVIOUS_TAG..HEAD | head -20)
300+
echo "changelog<<EOF" >> $GITHUB_OUTPUT
301+
echo "$CHANGELOG" >> $GITHUB_OUTPUT
302+
echo "EOF" >> $GITHUB_OUTPUT
303+
else
304+
# First release
305+
echo "changelog<<EOF" >> $GITHUB_OUTPUT
306+
echo "- Initial release" >> $GITHUB_OUTPUT
307+
echo "EOF" >> $GITHUB_OUTPUT
308+
fi
309+
310+
- name: Create Release Candidate
311+
id: create_rc
312+
uses: actions/create-release@v1
313+
env:
314+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
315+
with:
316+
tag_name: ${{ inputs.version }}
317+
release_name: Genkit CLI ${{ inputs.version }} (Release Candidate)
318+
body: |
319+
# Genkit CLI ${{ inputs.version }} - Release Candidate
320+
321+
⚠️ **This is a release candidate with unsigned binaries for testing purposes.**
322+
323+
## Downloads (Unsigned - For Testing Only)
324+
325+
- [Linux x64](https://github.com/firebase/genkit/releases/download/${{ inputs.version }}/genkit-linux-x64)
326+
- [Linux ARM64](https://github.com/firebase/genkit/releases/download/${{ inputs.version }}/genkit-linux-arm64)
327+
- [macOS x64](https://github.com/firebase/genkit/releases/download/${{ inputs.version }}/genkit-darwin-x64)
328+
- [macOS ARM64](https://github.com/firebase/genkit/releases/download/${{ inputs.version }}/genkit-darwin-arm64)
329+
- [Windows x64](https://github.com/firebase/genkit/releases/download/${{ inputs.version }}/genkit-win32-x64.exe)
330+
331+
## Changes
332+
333+
${{ steps.changelog.outputs.changelog }}
334+
335+
## Next Steps
336+
337+
After testing, these binaries will be signed and promoted to the final release.
338+
339+
## Installation (Testing Only)
340+
341+
```bash
342+
# Download and test the RC binary
343+
curl -Lo genkit https://github.com/firebase/genkit/releases/download/${{ inputs.version }}/genkit-$(uname -s | tr '[:upper:]' '[:lower:]')-$(uname -m | sed 's/x86_64/x64/;s/aarch64/arm64/')
344+
chmod +x genkit
345+
./genkit --version
346+
```
347+
draft: false
348+
prerelease: true
349+
350+
upload-rc-assets:
351+
needs: [build, test, create-rc]
352+
runs-on: ubuntu-latest
353+
if: inputs.create_rc == 'true'
354+
strategy:
355+
matrix:
356+
include:
357+
- target: linux-x64
358+
- target: linux-arm64
359+
- target: darwin-x64
360+
- target: darwin-arm64
361+
- target: win32-x64
362+
363+
steps:
364+
- name: Set binary extension
365+
id: binary
366+
shell: bash
367+
run: |
368+
if [[ "${{ matrix.target }}" == win32-* ]]; then
369+
echo "ext=.exe" >> $GITHUB_OUTPUT
370+
else
371+
echo "ext=" >> $GITHUB_OUTPUT
372+
fi
373+
374+
- name: Download binary artifact
375+
uses: actions/download-artifact@v4
376+
with:
377+
name: genkit-${{ matrix.target }}
378+
path: ./
379+
380+
- name: Upload to GitHub Release Candidate
381+
uses: actions/upload-release-asset@v1
382+
env:
383+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
384+
with:
385+
upload_url: ${{ needs.create-rc.outputs.upload_url }}
386+
asset_path: ./genkit-${{ matrix.target }}${{ steps.binary.outputs.ext }}
387+
asset_name: genkit-${{ matrix.target }}
388+
asset_content_type: application/octet-stream
389+
390+
promote-to-release:
278391
needs: [build, test]
279392
runs-on: ubuntu-latest
280-
if: inputs.upload_to_release == 'true'
393+
if: inputs.promote_rc == 'true'
281394

282395
steps:
283396
- name: Checkout code
284397
uses: actions/checkout@v4
285398

399+
# Note: After RC creation, signed binaries should be uploaded via Kokoro
400+
# before running promote_rc. The promotion assumes signed binaries are
401+
# available for the final release.
402+
- name: Validate signed binaries exist
403+
run: |
404+
RC_VERSION="${{ inputs.version }}"
405+
FINAL_VERSION="${RC_VERSION%-rc*}"
406+
407+
echo "Validating signed binaries exist for RC: $RC_VERSION"
408+
echo "Will promote to final version: $FINAL_VERSION"
409+
410+
# Expected platforms that should have signed binaries
411+
EXPECTED_PLATFORMS=("linux-x64" "linux-arm64" "darwin-x64" "darwin-arm64" "win32-x64")
412+
413+
# Check if RC release exists and get its assets
414+
RELEASE_INFO=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
415+
"https://api.github.com/repos/firebase/genkit/releases/tags/$RC_VERSION")
416+
417+
if [[ $(echo "$RELEASE_INFO" | jq -r '.id') == "null" ]]; then
418+
echo "❌ Error: RC release $RC_VERSION not found"
419+
exit 1
420+
fi
421+
422+
echo "✓ RC release $RC_VERSION found"
423+
424+
# Get list of assets from the RC release
425+
ASSETS=$(echo "$RELEASE_INFO" | jq -r '.assets[].name' | sort)
426+
427+
# Check for expected signed binaries
428+
MISSING_BINARIES=()
429+
for platform in "${EXPECTED_PLATFORMS[@]}"; do
430+
if [[ "$platform" == win32-* ]]; then
431+
expected_file="genkit-$platform.exe"
432+
else
433+
expected_file="genkit-$platform"
434+
fi
435+
436+
if ! echo "$ASSETS" | grep -q "^$expected_file$"; then
437+
MISSING_BINARIES+=("$expected_file")
438+
else
439+
echo "✓ Found signed binary: $expected_file"
440+
fi
441+
done
442+
443+
if [[ ${#MISSING_BINARIES[@]} -gt 0 ]]; then
444+
echo "❌ Missing signed binaries:"
445+
printf ' - %s\n' "${MISSING_BINARIES[@]}"
446+
echo ""
447+
echo "Please ensure all binaries are signed before promoting to final release."
448+
echo "You can trigger the signing workflow or manually upload signed binaries."
449+
exit 1
450+
fi
451+
452+
echo "✅ All expected signed binaries found in RC release"
453+
286454
- name: Generate changelog
287455
id: changelog
288456
run: |
@@ -302,7 +470,7 @@ jobs:
302470
echo "EOF" >> $GITHUB_OUTPUT
303471
fi
304472
305-
- name: Create Release
473+
- name: Create Final Release
306474
id: create_release
307475
uses: actions/create-release@v1
308476
env:
@@ -327,16 +495,48 @@ jobs:
327495
328496
## Installation
329497
498+
### Quick Install (Recommended)
499+
330500
```bash
331-
TODO: Add installation instructions
501+
curl -sL https://genkit.tools | bash
332502
```
503+
504+
### Manual Installation
505+
506+
```bash
507+
# Download the appropriate binary for your platform
508+
curl -Lo genkit https://github.com/firebase/genkit/releases/download/${{ inputs.version }}/genkit-$(uname -s | tr '[:upper:]' '[:lower:]')-$(uname -m | sed 's/x86_64/x64/;s/aarch64/arm64/')
509+
510+
# Make it executable
511+
chmod +x genkit
512+
513+
# Move to a directory in your PATH
514+
sudo mv genkit /usr/local/bin/
515+
516+
# Verify installation
517+
genkit --version
518+
```
519+
520+
### Windows Installation
521+
522+
```powershell
523+
# Download the Windows binary
524+
Invoke-WebRequest -Uri "https://github.com/firebase/genkit/releases/download/${{ inputs.version }}/genkit-win32-x64.exe" -OutFile "genkit.exe"
525+
526+
# Add to PATH or run from current directory
527+
.\genkit.exe --version
528+
```
529+
530+
## Documentation
531+
532+
For more information, visit [https://firebase.google.com/docs/genkit/](https://firebase.google.com/docs/genkit/)
333533
draft: false
334534
prerelease: false
335535

336-
upload-assets:
337-
needs: [build, test, create-release]
536+
upload-release-assets:
537+
needs: [build, test, promote-to-release]
338538
runs-on: ubuntu-latest
339-
if: inputs.upload_to_release == 'true'
539+
if: inputs.promote_rc == 'true'
340540
strategy:
341541
matrix:
342542
include:
@@ -368,15 +568,15 @@ jobs:
368568
env:
369569
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
370570
with:
371-
upload_url: ${{ needs.create-release.outputs.upload_url }}
571+
upload_url: ${{ needs.promote-to-release.outputs.upload_url }}
372572
asset_path: ./genkit-${{ matrix.target }}${{ steps.binary.outputs.ext }}
373573
asset_name: genkit-${{ matrix.target }}
374574
asset_content_type: application/octet-stream
375575

376576
update-latest-tag:
377-
needs: [create-release, upload-assets]
577+
needs: [promote-to-release, upload-release-assets]
378578
runs-on: ubuntu-latest
379-
if: inputs.upload_to_release == 'true'
579+
if: inputs.promote_rc == 'true'
380580

381581
steps:
382582
- name: Checkout code

0 commit comments

Comments
 (0)