Skip to content

Commit 58c4d3f

Browse files
committed
fix: apply improvements to cli workflows
1 parent cca6438 commit 58c4d3f

File tree

3 files changed

+101
-97
lines changed

3 files changed

+101
-97
lines changed

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

Lines changed: 26 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ on:
2929
type: boolean
3030
default: false
3131

32+
permissions:
33+
contents: write
34+
3235
jobs:
3336
build:
3437
strategy:
@@ -280,8 +283,6 @@ jobs:
280283
needs: [build, test]
281284
runs-on: ubuntu-latest
282285
if: inputs.create_rc
283-
outputs:
284-
upload_url: ${{ steps.create_rc.outputs.upload_url }}
285286

286287
steps:
287288
- name: Checkout code
@@ -306,26 +307,29 @@ jobs:
306307
echo "EOF" >> $GITHUB_OUTPUT
307308
fi
308309
310+
- name: Download all binary artifacts
311+
uses: actions/download-artifact@v4
312+
with:
313+
path: release-assets
314+
309315
- name: Create Release Candidate
310316
id: create_rc
311-
uses: actions/create-release@v1
312-
env:
313-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
317+
uses: softprops/action-gh-release@v2
314318
with:
315319
tag_name: ${{ inputs.version }}
316-
release_name: Genkit CLI ${{ inputs.version }} (Release Candidate)
320+
name: Genkit CLI ${{ inputs.version }} (Release Candidate)
317321
body: |
318322
# Genkit CLI ${{ inputs.version }} - Release Candidate
319323
320324
⚠️ **This is a release candidate with unsigned binaries for testing purposes.**
321325
322326
## Downloads (Unsigned - For Testing Only)
323327
324-
- [Linux x64](https://github.com/firebase/genkit/releases/download/${{ inputs.version }}/genkit-linux-x64)
325-
- [Linux ARM64](https://github.com/firebase/genkit/releases/download/${{ inputs.version }}/genkit-linux-arm64)
326-
- [macOS x64](https://github.com/firebase/genkit/releases/download/${{ inputs.version }}/genkit-darwin-x64)
327-
- [macOS ARM64](https://github.com/firebase/genkit/releases/download/${{ inputs.version }}/genkit-darwin-arm64)
328-
- [Windows x64](https://github.com/firebase/genkit/releases/download/${{ inputs.version }}/genkit-win32-x64.exe)
328+
- [Linux x64](https://github.com/${{ github.repository }}/releases/download/${{ inputs.version }}/genkit-linux-x64)
329+
- [Linux ARM64](https://github.com/${{ github.repository }}/releases/download/${{ inputs.version }}/genkit-linux-arm64)
330+
- [macOS x64](https://github.com/${{ github.repository }}/releases/download/${{ inputs.version }}/genkit-darwin-x64)
331+
- [macOS ARM64](https://github.com/${{ github.repository }}/releases/download/${{ inputs.version }}/genkit-darwin-arm64)
332+
- [Windows x64](https://github.com/${{ github.repository }}/releases/download/${{ inputs.version }}/genkit-win32-x64.exe)
329333
330334
## Changes
331335
@@ -337,57 +341,25 @@ jobs:
337341
338342
## Installation (Testing Only)
339343
340-
```bash
344+
\`\`\`bash
341345
# Download and test the RC binary
342-
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/')
346+
curl -Lo genkit https://github.com/${{ github.repository }}/releases/download/${{ inputs.version }}/genkit-\$(uname -s | tr '[:upper:]' '[:lower:]')-\$(uname -m | sed 's/x86_64/x64/;s/aarch64/arm64/')
343347
chmod +x genkit
344348
./genkit --version
345-
```
349+
\`\`\`
346350
draft: false
347351
prerelease: true
352+
files: |
353+
release-assets/genkit-linux-x64/genkit-linux-x64
354+
release-assets/genkit-linux-arm64/genkit-linux-arm64
355+
release-assets/genkit-darwin-x64/genkit-darwin-x64
356+
release-assets/genkit-darwin-arm64/genkit-darwin-arm64
357+
release-assets/genkit-win32-x64/genkit-win32-x64.exe
358+
348359
349-
upload-rc-assets:
350-
needs: [build, test, create-rc]
351-
runs-on: ubuntu-latest
352-
if: inputs.create_rc
353-
strategy:
354-
matrix:
355-
include:
356-
- target: linux-x64
357-
- target: linux-arm64
358-
- target: darwin-x64
359-
- target: darwin-arm64
360-
- target: win32-x64
361-
362-
steps:
363-
- name: Set binary extension
364-
id: binary
365-
shell: bash
366-
run: |
367-
if [[ "${{ matrix.target }}" == win32-* ]]; then
368-
echo "ext=.exe" >> $GITHUB_OUTPUT
369-
else
370-
echo "ext=" >> $GITHUB_OUTPUT
371-
fi
372-
373-
- name: Download binary artifact
374-
uses: actions/download-artifact@v4
375-
with:
376-
name: genkit-${{ matrix.target }}
377-
path: ./
378-
379-
- name: Upload to GitHub Release Candidate
380-
uses: actions/upload-release-asset@v1
381-
env:
382-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
383-
with:
384-
upload_url: ${{ needs.create-rc.outputs.upload_url }}
385-
asset_path: ./genkit-${{ matrix.target }}${{ steps.binary.outputs.ext }}
386-
asset_name: genkit-${{ matrix.target }}${{ steps.binary.outputs.ext }}
387-
asset_content_type: application/octet-stream
388360
389361
create-rc-summary:
390-
needs: [upload-rc-assets]
362+
needs: [create-rc]
391363
runs-on: ubuntu-latest
392364
if: inputs.create_rc
393365

.github/workflows/promote-cli-release.yml

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ on:
2828
required: true
2929
type: string
3030

31+
permissions:
32+
contents: write
33+
3134
jobs:
3235
validate-and-promote:
3336
runs-on: ubuntu-latest
@@ -206,12 +209,10 @@ jobs:
206209
207210
- name: Create final release
208211
id: create_release
209-
uses: actions/create-release@v1
210-
env:
211-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
212+
uses: softprops/action-gh-release@v2
212213
with:
213214
tag_name: ${{ inputs.final_version }}
214-
release_name: Genkit CLI ${{ inputs.final_version }}
215+
name: Genkit CLI ${{ inputs.final_version }}
215216
body: |
216217
# Genkit CLI ${{ inputs.final_version }}
217218
@@ -231,15 +232,15 @@ jobs:
231232
232233
### Quick Install (Recommended)
233234
234-
```bash
235+
\`\`\`bash
235236
curl -sL https://genkit.tools | bash
236-
```
237+
\`\`\`
237238
238239
### Manual Installation
239240
240-
```bash
241+
\`\`\`bash
241242
# Download the appropriate binary for your platform
242-
curl -Lo genkit https://github.com/${{ github.repository }}/releases/download/${{ inputs.final_version }}/genkit-$(uname -s | tr '[:upper:]' '[:lower:]')-$(uname -m | sed 's/x86_64/x64/;s/aarch64/arm64/')
243+
curl -Lo genkit https://github.com/${{ github.repository }}/releases/download/${{ inputs.final_version }}/genkit-\$(uname -s | tr '[:upper:]' '[:lower:]')-\$(uname -m | sed 's/x86_64/x64/;s/aarch64/arm64/')
243244
244245
# Make it executable
245246
chmod +x genkit
@@ -249,45 +250,32 @@ jobs:
249250
250251
# Verify installation
251252
genkit --version
252-
```
253+
\`\`\`
253254
254255
### Windows Installation
255256
256-
```powershell
257+
\`\`\`powershell
257258
# Download the Windows binary
258259
Invoke-WebRequest -Uri "https://github.com/${{ github.repository }}/releases/download/${{ inputs.final_version }}/genkit-win32-x64.exe" -OutFile "genkit.exe"
259260
260261
# Add to PATH or run from current directory
261262
.\genkit.exe --version
262-
```
263+
\`\`\`
263264
264265
## Documentation
265266
266267
For more information, visit [https://firebase.google.com/docs/genkit/](https://firebase.google.com/docs/genkit/)
267268
draft: false
268269
prerelease: false
270+
files: |
271+
release-assets/genkit-linux-x64
272+
release-assets/genkit-linux-arm64
273+
release-assets/genkit-darwin-x64
274+
release-assets/genkit-darwin-arm64
275+
release-assets/genkit-win32-x64.exe
276+
make_latest: true
269277

270-
- name: Upload release assets
271-
env:
272-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
273-
run: |
274-
UPLOAD_URL="${{ steps.create_release.outputs.upload_url }}"
275-
276-
echo "Uploading binaries to final release..."
277-
278-
for file in release-assets/*; do
279-
filename=$(basename "$file")
280-
echo "Uploading $filename..."
281-
282-
curl -X POST \
283-
-H "Authorization: token $GITHUB_TOKEN" \
284-
-H "Content-Type: application/octet-stream" \
285-
--data-binary "@$file" \
286-
"${UPLOAD_URL}?name=$filename" | jq -r '.browser_download_url'
287-
done
288-
289-
echo ""
290-
echo "✅ All binaries uploaded successfully"
278+
291279

292280
- name: Update latest tag
293281
run: |

scripts/sign-and-upload-binaries.sh

Lines changed: 55 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,36 +109,80 @@ for platform in "${PLATFORMS[@]}"; do
109109
continue
110110
fi
111111

112-
# Simulate signing by renaming
112+
# Simulate signing process (preserve binary integrity)
113113
echo " Simulating signing process..."
114+
115+
# Method 1: Create a copy with signed name (binary remains unchanged)
114116
cp "$TEMP_DIR/$original_name" "$TEMP_DIR/$signed_name"
115117

116-
# Add a simple signature marker to the file
117-
echo "SIGNED:$VERSION:$(date -u +%Y%m%d%H%M%S)" >> "$TEMP_DIR/$signed_name"
118+
# Method 2: Create a separate signature file
119+
signature_name="$signed_name.sig"
120+
cat > "$TEMP_DIR/$signature_name" << EOF
121+
-----BEGIN GENKIT SIGNATURE-----
122+
Version: $VERSION
123+
Platform: $platform
124+
Signed: $(date -u -Iseconds)
125+
Signature: $(sha256sum "$TEMP_DIR/$original_name" | cut -d' ' -f1)
126+
Signer: Genkit Signing Service (Simulation)
127+
-----END GENKIT SIGNATURE-----
128+
EOF
129+
130+
echo " ✓ Signing simulated (binary integrity preserved)"
131+
echo " ✓ Signature file created: $signature_name"
118132

119-
echo " ✓ Signing simulated"
133+
# Verify binary integrity after "signing"
134+
if cmp -s "$TEMP_DIR/$original_name" "$TEMP_DIR/$signed_name"; then
135+
echo " ✓ Binary integrity verified (no corruption)"
136+
else
137+
echo " ✗ Binary integrity check failed!"
138+
exit 1
139+
fi
120140

121141
# Upload the signed binary
122142
echo " Uploading $signed_name..."
123143

124-
upload_response=$(curl -s -X POST \
144+
upload_binary_response=$(curl -s -X POST \
125145
-H "Authorization: token $GITHUB_TOKEN" \
126146
-H "Content-Type: application/octet-stream" \
127147
--data-binary "@$TEMP_DIR/$signed_name" \
128148
"$UPLOAD_URL?name=$signed_name")
129149

130-
# Check if upload was successful
131-
if echo "$upload_response" | jq -e '.id' > /dev/null; then
132-
asset_url=$(echo "$upload_response" | jq -r '.browser_download_url')
133-
echo "Uploaded successfully: $asset_url"
150+
# Check if binary upload was successful
151+
if echo "$upload_binary_response" | jq -e '.id' > /dev/null; then
152+
asset_url=$(echo "$upload_binary_response" | jq -r '.browser_download_url')
153+
echo "Binary uploaded successfully: $asset_url"
134154
else
135155
echo " ✗ Failed to upload $signed_name"
136-
echo " Error: $(echo "$upload_response" | jq -r '.message // "Unknown error"')"
156+
echo " Error: $(echo "$upload_binary_response" | jq -r '.message // "Unknown error"')"
157+
fi
158+
159+
# Upload the signature file
160+
echo " Uploading $signature_name..."
161+
162+
upload_signature_response=$(curl -s -X POST \
163+
-H "Authorization: token $GITHUB_TOKEN" \
164+
-H "Content-Type: text/plain" \
165+
--data-binary "@$TEMP_DIR/$signature_name" \
166+
"$UPLOAD_URL?name=$signature_name")
167+
168+
# Check if signature upload was successful
169+
if echo "$upload_signature_response" | jq -e '.id' > /dev/null; then
170+
sig_asset_url=$(echo "$upload_signature_response" | jq -r '.browser_download_url')
171+
echo " ✓ Signature file uploaded successfully: $sig_asset_url"
172+
else
173+
echo " ✗ Failed to upload signature file"
174+
echo " Error: $(echo "$upload_signature_response" | jq -r '.message // "Unknown error"')"
137175
fi
138176

139177
echo ""
140178
done
141179

142180
echo "=== Signing simulation complete ==="
143181
echo ""
144-
echo "View the release at: https://github.com/$REPO_OWNER/$REPO_NAME/releases/tag/$VERSION"
182+
echo "✓ All binaries signed and uploaded successfully"
183+
echo "✓ Binary integrity preserved (no corruption)"
184+
echo "✓ Separate signature files created for verification"
185+
echo ""
186+
echo "View the release at: https://github.com/$REPO_OWNER/$REPO_NAME/releases/tag/$VERSION"
187+
echo ""
188+
echo "Note: This is a simulation. In production, you would use proper code signing tools."

0 commit comments

Comments
 (0)