release.yaml•2.95 kB
# This is a GitHub Actions workflow to automate building and releasing your extension.
# It will trigger automatically whenever you push a new tag that starts with 'v' (e.g., v1.0.0).
name: Create Release
on:
# This allows the workflow to be triggered when a new tag is pushed
push:
tags:
- 'v*' # Triggers on tags like v1.0, v1.0.1, etc.
# This allows you to run the workflow manually from the Actions tab
workflow_dispatch:
permissions:
# This permission is required for the action to create a GitHub Release
contents: write
jobs:
build-and-release:
runs-on: ubuntu-latest
steps:
# 1. Checks out your repository's code
- name: Checkout code
uses: actions/checkout@v4
# 2. Sets up the Node.js environment
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20' # Specify the Node.js version you use
cache: 'npm'
# 3. Installs root dependencies
# We use 'npm ci' which is faster and safer for CI/CD environments
- name: Install root dependencies
run: npm ci
# 4. Install MCP server dependencies
# The MCP server needs its dependencies bundled in the release
- name: Install MCP server dependencies
run: cd mcp-server && npm ci
# 5. Runs your build script
# This assumes 'npm run build' creates a 'dist' or 'build' folder.
# If your build output is different, change the 'tar' command below.
- name: Run build
run: npm run build
# 6. Update extension version from tag
# This step extracts the version from the Git tag (e.g., v1.0.7 -> 1.0.7)
# and updates the gemini-extension.json file with the new version.
- name: Update extension version
run: |
VERSION=$(echo ${{ github.ref_name }} | sed 's/v//')
sed -i "s/\"version\": \".*\"/\"version\": \"$VERSION\"/" gemini-extension.json
# 7. Create TAR archive with MCP server dependencies
# Exclude root node_modules but INCLUDE mcp-server/node_modules
- name: Create TAR archive
run: tar -cvzf ../nanobanana-release.tar.gz --exclude='.git' --exclude='.github' --exclude='./node_modules' . && mv ../nanobanana-release.tar.gz .
# 8. Creates the GitHub Release
# This step uses the 'gh' CLI (pre-installed on the runner) to:
# - Create a new release based on the tag you pushed.
# - Automatically generate release notes from your commits.
# - Upload the 'nanobanana-release.tar.gz' file as a release asset.
- name: Create GitHub Release and Upload Asset
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create ${{ github.ref_name }} \
--generate-notes \
--title "Release ${{ github.ref_name }}" \
--notes "See the changelog for details." \
nanobanana-release.tar.gz