From a90b7881387ac54d745fd8c11325e312c0fcc0d8 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Fri, 7 Nov 2025 00:09:53 -0800 Subject: [PATCH] Updated cd script. --- .github/workflows/cd.yml | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 1e070a7c..3098d314 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -6,8 +6,8 @@ on: - 'v*.*.*' workflow_dispatch: inputs: - manual_tag: - description: 'Optional image tag (e.g. 1.2.3, beta, nightly)' + version: + description: 'Optional image version (e.g. 3.0.0, beta)' required: false default: '' @@ -23,7 +23,6 @@ jobs: steps: - uses: actions/checkout@v5 - # Install cosign (for image signing) - name: Install cosign uses: sigstore/cosign-installer@v3 @@ -45,6 +44,21 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + # Normalize manual input if provided + - name: Normalize manual version + id: normalize + run: | + INPUT="${{ github.event.inputs.version }}" + if [[ -n "$INPUT" ]]; then + # Strip leading v if present + VERSION="${INPUT#v}" + MAJOR=$(echo "$VERSION" | cut -d. -f1) + MINOR=$(echo "$VERSION" | cut -d. -f2) + echo "version_tags=${VERSION},${MAJOR}.${MINOR},${MAJOR}" >> $GITHUB_ENV + else + echo "version_tags=" >> $GITHUB_ENV + fi + - name: Extract Docker metadata id: meta uses: docker/metadata-action@v5 @@ -55,11 +69,18 @@ jobs: flavor: | latest=auto tags: | + # Semver tags from real Git tags type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}} + + # Manual input derived tags + type=raw,value=${{ env.version_tags }},enable=${{ env.version_tags != '' }} + + # Fallbacks for branches/PRs type=ref,event=branch - type=raw,value=latest,enable=${{ github.event_name == 'workflow_dispatch' }} + type=ref,event=pr + type=sha - name: Build and push Docker image id: build-and-push @@ -73,7 +94,6 @@ jobs: cache-from: type=gha cache-to: type=gha,mode=max - # Sign the published image digest - name: Sign the published Docker image env: TAGS: ${{ steps.meta.outputs.tags }}