CI
This commit is contained in:
@@ -2,16 +2,14 @@ name: Publish Docker image (Multi-arch)
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
tags:
|
tags:
|
||||||
- '*'
|
- '*'
|
||||||
- '!nightly*'
|
- '!nightly*'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
tag:
|
tag:
|
||||||
description: 'Tag name to build (e.g., v0.10.8)'
|
description: 'Tag name to build (e.g., v0.10.8-alpha.3)'
|
||||||
required: false
|
required: true
|
||||||
type: string
|
type: string
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@@ -30,7 +28,6 @@ jobs:
|
|||||||
runs-on: ${{ matrix.runner }}
|
runs-on: ${{ matrix.runner }}
|
||||||
outputs:
|
outputs:
|
||||||
tag: ${{ steps.version.outputs.tag }}
|
tag: ${{ steps.version.outputs.tag }}
|
||||||
is_tag: ${{ steps.version.outputs.is_tag }}
|
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
packages: write
|
packages: write
|
||||||
@@ -44,43 +41,22 @@ jobs:
|
|||||||
fetch-depth: ${{ github.event_name == 'workflow_dispatch' && 0 || 1 }}
|
fetch-depth: ${{ github.event_name == 'workflow_dispatch' && 0 || 1 }}
|
||||||
ref: ${{ github.event.inputs.tag || github.ref }}
|
ref: ${{ github.event.inputs.tag || github.ref }}
|
||||||
|
|
||||||
- name: Resolve version
|
- name: Resolve tag & write VERSION
|
||||||
id: version
|
id: version
|
||||||
run: |
|
run: |
|
||||||
IS_TAG=false
|
|
||||||
if [ -n "${{ github.event.inputs.tag }}" ]; then
|
if [ -n "${{ github.event.inputs.tag }}" ]; then
|
||||||
TAG="${{ github.event.inputs.tag }}"
|
TAG="${{ github.event.inputs.tag }}"
|
||||||
if ! git rev-parse "refs/tags/$TAG" >/dev/null 2>&1; then
|
if ! git rev-parse "refs/tags/$TAG" >/dev/null 2>&1; then
|
||||||
echo "::error::Tag '$TAG' does not exist"
|
echo "::error::Tag '$TAG' does not exist"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
IS_TAG=true
|
|
||||||
elif [[ "${GITHUB_REF}" == refs/tags/* ]]; then
|
|
||||||
TAG="${GITHUB_REF#refs/tags/}"
|
|
||||||
IS_TAG=true
|
|
||||||
else
|
else
|
||||||
TAG="$(date +'%Y%m%d')-$(git rev-parse --short HEAD)"
|
TAG=${GITHUB_REF#refs/tags/}
|
||||||
fi
|
fi
|
||||||
echo "TAG=${TAG}" >> $GITHUB_ENV
|
echo "TAG=${TAG}" >> $GITHUB_ENV
|
||||||
echo "tag=${TAG}" >> $GITHUB_OUTPUT
|
echo "tag=${TAG}" >> $GITHUB_OUTPUT
|
||||||
echo "is_tag=${IS_TAG}" >> $GITHUB_OUTPUT
|
|
||||||
echo "${TAG}" > VERSION
|
echo "${TAG}" > VERSION
|
||||||
echo "Building version: ${TAG} for ${{ matrix.arch }}"
|
echo "Building tag: ${TAG} for ${{ matrix.arch }}"
|
||||||
|
|
||||||
- name: Compute image tags
|
|
||||||
id: tags
|
|
||||||
run: |
|
|
||||||
TAGS="calciumion/new-api:${TAG}-${{ matrix.arch }}"
|
|
||||||
if [ "${{ steps.version.outputs.is_tag }}" = "true" ]; then
|
|
||||||
TAGS="${TAGS}"$'\n'"calciumion/new-api:latest-${{ matrix.arch }}"
|
|
||||||
else
|
|
||||||
TAGS="${TAGS}"$'\n'"calciumion/new-api:main-${{ matrix.arch }}"
|
|
||||||
fi
|
|
||||||
{
|
|
||||||
echo "tags<<EOF"
|
|
||||||
echo "${TAGS}"
|
|
||||||
echo "EOF"
|
|
||||||
} >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -104,7 +80,9 @@ jobs:
|
|||||||
context: .
|
context: .
|
||||||
platforms: ${{ matrix.platform }}
|
platforms: ${{ matrix.platform }}
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ steps.tags.outputs.tags }}
|
tags: |
|
||||||
|
calciumion/new-api:${{ env.TAG }}-${{ matrix.arch }}
|
||||||
|
calciumion/new-api:latest-${{ matrix.arch }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
cache-from: type=gha
|
cache-from: type=gha
|
||||||
cache-to: type=gha,mode=max
|
cache-to: type=gha,mode=max
|
||||||
@@ -112,11 +90,9 @@ jobs:
|
|||||||
sbom: true
|
sbom: true
|
||||||
|
|
||||||
- name: Install cosign
|
- name: Install cosign
|
||||||
if: steps.version.outputs.is_tag == 'true'
|
|
||||||
uses: sigstore/cosign-installer@v3
|
uses: sigstore/cosign-installer@v3
|
||||||
|
|
||||||
- name: Sign image with cosign
|
- name: Sign image with cosign
|
||||||
if: steps.version.outputs.is_tag == 'true'
|
|
||||||
run: cosign sign --yes calciumion/new-api@${{ steps.build.outputs.digest }}
|
run: cosign sign --yes calciumion/new-api@${{ steps.build.outputs.digest }}
|
||||||
|
|
||||||
- name: Image summary
|
- name: Image summary
|
||||||
@@ -131,6 +107,7 @@ jobs:
|
|||||||
name: Create multi-arch manifests
|
name: Create multi-arch manifests
|
||||||
needs: [build_single_arch]
|
needs: [build_single_arch]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Set version
|
- name: Set version
|
||||||
@@ -150,21 +127,12 @@ jobs:
|
|||||||
calciumion/new-api:${TAG}-arm64
|
calciumion/new-api:${TAG}-arm64
|
||||||
|
|
||||||
- name: Create & push manifest (latest)
|
- name: Create & push manifest (latest)
|
||||||
if: needs.build_single_arch.outputs.is_tag == 'true'
|
|
||||||
run: |
|
run: |
|
||||||
docker buildx imagetools create \
|
docker buildx imagetools create \
|
||||||
-t calciumion/new-api:latest \
|
-t calciumion/new-api:latest \
|
||||||
calciumion/new-api:latest-amd64 \
|
calciumion/new-api:latest-amd64 \
|
||||||
calciumion/new-api:latest-arm64
|
calciumion/new-api:latest-arm64
|
||||||
|
|
||||||
- name: Create & push manifest (main)
|
|
||||||
if: needs.build_single_arch.outputs.is_tag != 'true'
|
|
||||||
run: |
|
|
||||||
docker buildx imagetools create \
|
|
||||||
-t calciumion/new-api:main \
|
|
||||||
calciumion/new-api:main-amd64 \
|
|
||||||
calciumion/new-api:main-arm64
|
|
||||||
|
|
||||||
- name: Manifest summary
|
- name: Manifest summary
|
||||||
run: |
|
run: |
|
||||||
echo "### Multi-arch Manifest" >> $GITHUB_STEP_SUMMARY
|
echo "### Multi-arch Manifest" >> $GITHUB_STEP_SUMMARY
|
||||||
|
|||||||
Reference in New Issue
Block a user