Skip to content

Commit 5908b57

Browse files
committed
feat: automatically update latest tag for cli releases
1 parent 950a115 commit 5908b57

File tree

2 files changed

+106
-2
lines changed

2 files changed

+106
-2
lines changed

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

Lines changed: 104 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ name: Build CLI Binaries
1818

1919
on:
2020
workflow_dispatch:
21+
inputs:
22+
version:
23+
description: 'Version tag to build (e.g., v1.0.0)'
24+
required: true
25+
type: string
26+
upload_to_release:
27+
description: 'Upload binaries to GitHub release and update latest tag'
28+
required: false
29+
type: boolean
30+
default: false
2131

2232
jobs:
2333
build:
@@ -253,4 +263,97 @@ jobs:
253263
}
254264
255265
# Clean up any remaining genkit processes
256-
Get-Process | Where-Object { $_.ProcessName -match "genkit" } | Stop-Process -Force -ErrorAction SilentlyContinue
266+
Get-Process | Where-Object { $_.ProcessName -match "genkit" } | Stop-Process -Force -ErrorAction SilentlyContinue
267+
268+
create-release:
269+
needs: [build, test]
270+
runs-on: ubuntu-latest
271+
if: inputs.upload_to_release == 'true'
272+
273+
steps:
274+
- name: Checkout code
275+
uses: actions/checkout@v4
276+
277+
- name: Create Release
278+
id: create_release
279+
uses: actions/create-release@v1
280+
env:
281+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
282+
with:
283+
tag_name: ${{ inputs.version }}
284+
release_name: Genkit CLI ${{ inputs.version }}
285+
body: |
286+
Genkit CLI ${{ inputs.version }}
287+
288+
## Downloads
289+
290+
- [Linux x64](https://github.com/firebase/genkit/releases/download/${{ inputs.version }}/genkit-linux-x64)
291+
- [Linux ARM64](https://github.com/firebase/genkit/releases/download/${{ inputs.version }}/genkit-linux-arm64)
292+
- [macOS x64](https://github.com/firebase/genkit/releases/download/${{ inputs.version }}/genkit-darwin-x64)
293+
- [macOS ARM64](https://github.com/firebase/genkit/releases/download/${{ inputs.version }}/genkit-darwin-arm64)
294+
- [Windows x64](https://github.com/firebase/genkit/releases/download/${{ inputs.version }}/genkit-win32-x64.exe)
295+
draft: false
296+
prerelease: false
297+
298+
upload-assets:
299+
needs: [build, test, create-release]
300+
runs-on: ubuntu-latest
301+
if: inputs.upload_to_release == 'true'
302+
strategy:
303+
matrix:
304+
include:
305+
- target: linux-x64
306+
- target: linux-arm64
307+
- target: darwin-x64
308+
- target: darwin-arm64
309+
- target: win32-x64
310+
311+
steps:
312+
- name: Set binary extension
313+
id: binary
314+
shell: bash
315+
run: |
316+
if [[ "${{ matrix.target }}" == win32-* ]]; then
317+
echo "ext=.exe" >> $GITHUB_OUTPUT
318+
else
319+
echo "ext=" >> $GITHUB_OUTPUT
320+
fi
321+
322+
- name: Download binary artifact
323+
uses: actions/download-artifact@v4
324+
with:
325+
name: genkit-${{ matrix.target }}
326+
path: ./
327+
328+
- name: Upload to GitHub Release
329+
uses: actions/upload-release-asset@v1
330+
env:
331+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
332+
with:
333+
upload_url: ${{ needs.create-release.outputs.upload_url }}
334+
asset_path: ./genkit-${{ matrix.target }}${{ steps.binary.outputs.ext }}
335+
asset_name: genkit-${{ matrix.target }}
336+
asset_content_type: application/octet-stream
337+
338+
update-latest-tag:
339+
needs: [create-release, upload-assets]
340+
runs-on: ubuntu-latest
341+
if: inputs.upload_to_release == 'true'
342+
343+
steps:
344+
- name: Checkout code
345+
uses: actions/checkout@v4
346+
with:
347+
token: ${{ secrets.GITHUB_TOKEN }}
348+
349+
- name: Update latest tag
350+
run: |
351+
# Delete the existing "latest" tag if it exists
352+
git tag -d latest 2>/dev/null || true
353+
git push origin :refs/tags/latest 2>/dev/null || true
354+
355+
# Create new "latest" tag pointing to the release tag
356+
git tag latest ${{ inputs.version }}
357+
git push origin latest
358+
359+
echo "Updated 'latest' tag to point to ${{ inputs.version }}"

bin/install_cli

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,8 @@ if [[ -z "$MACHINE" ]]; then
250250
fi
251251

252252
# We have enough information to generate the binary's download URL.
253-
DOWNLOAD_URL="https://$DOMAIN/bin/$MACHINE/latest"
253+
# Use GitHub releases with "latest" tag that gets updated by the workflow
254+
DOWNLOAD_URL="https://github.com/firebase/genkit/releases/download/latest/genkit-$MACHINE"
254255
echo "-- Downloading binary from $DOWNLOAD_URL"
255256

256257
# We use "curl" to download the binary with a flag set to follow redirects

0 commit comments

Comments
 (0)