mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-09-13 15:54:34 +00:00
feat: add manual Docker image publishing workflow
This commit is contained in:
@@ -1,179 +0,0 @@
|
|||||||
name: Publish Docker image (alpha)
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- alpha
|
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
name:
|
|
||||||
description: "reason"
|
|
||||||
required: false
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build_single_arch:
|
|
||||||
name: Build & push (${{ matrix.arch }}) [native]
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- arch: amd64
|
|
||||||
platform: linux/amd64
|
|
||||||
runner: ubuntu-latest
|
|
||||||
- arch: arm64
|
|
||||||
platform: linux/arm64
|
|
||||||
runner: ubuntu-24.04-arm
|
|
||||||
runs-on: ${{ matrix.runner }}
|
|
||||||
permissions:
|
|
||||||
packages: write
|
|
||||||
contents: read
|
|
||||||
id-token: write
|
|
||||||
steps:
|
|
||||||
- name: Check out (shallow)
|
|
||||||
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 1
|
|
||||||
|
|
||||||
- name: Determine alpha version
|
|
||||||
id: version
|
|
||||||
run: |
|
|
||||||
VERSION="alpha-$(date +'%Y%m%d')-$(git rev-parse --short HEAD)"
|
|
||||||
echo "$VERSION" > VERSION
|
|
||||||
echo "value=$VERSION" >> $GITHUB_OUTPUT
|
|
||||||
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
|
||||||
echo "Publishing version: $VERSION for ${{ matrix.arch }}"
|
|
||||||
|
|
||||||
- name: Normalize GHCR repository
|
|
||||||
run: echo "GHCR_REPOSITORY=${GITHUB_REPOSITORY,,}" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
|
|
||||||
|
|
||||||
- name: Log in to Docker Hub
|
|
||||||
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Log in to GHCR
|
|
||||||
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
|
|
||||||
with:
|
|
||||||
registry: ghcr.io
|
|
||||||
username: ${{ github.actor }}
|
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Extract metadata (labels)
|
|
||||||
id: meta
|
|
||||||
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5
|
|
||||||
with:
|
|
||||||
images: |
|
|
||||||
calciumion/new-api
|
|
||||||
ghcr.io/${{ env.GHCR_REPOSITORY }}
|
|
||||||
|
|
||||||
- name: Build & push single-arch (to both registries)
|
|
||||||
id: build
|
|
||||||
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
platforms: ${{ matrix.platform }}
|
|
||||||
push: true
|
|
||||||
tags: |
|
|
||||||
calciumion/new-api:alpha-${{ matrix.arch }}
|
|
||||||
calciumion/new-api:${{ steps.version.outputs.value }}-${{ matrix.arch }}
|
|
||||||
ghcr.io/${{ env.GHCR_REPOSITORY }}:alpha-${{ matrix.arch }}
|
|
||||||
ghcr.io/${{ env.GHCR_REPOSITORY }}:${{ steps.version.outputs.value }}-${{ matrix.arch }}
|
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
|
||||||
cache-from: type=gha
|
|
||||||
cache-to: type=gha,mode=max
|
|
||||||
provenance: mode=max
|
|
||||||
sbom: true
|
|
||||||
|
|
||||||
- name: Install cosign
|
|
||||||
uses: sigstore/cosign-installer@398d4b0eeef1380460a10c8013a76f728fb906ac # v3
|
|
||||||
|
|
||||||
- name: Sign image with cosign
|
|
||||||
run: |
|
|
||||||
cosign sign --yes calciumion/new-api@${{ steps.build.outputs.digest }}
|
|
||||||
cosign sign --yes ghcr.io/${{ env.GHCR_REPOSITORY }}@${{ steps.build.outputs.digest }}
|
|
||||||
|
|
||||||
- name: Output digest
|
|
||||||
run: |
|
|
||||||
echo "### Docker Image Digest (${{ matrix.arch }})" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo '```' >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "calciumion/new-api:alpha-${{ matrix.arch }}" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "ghcr.io/${{ env.GHCR_REPOSITORY }}:alpha-${{ matrix.arch }}" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "${{ steps.build.outputs.digest }}" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo '```' >> $GITHUB_STEP_SUMMARY
|
|
||||||
|
|
||||||
create_manifests:
|
|
||||||
name: Create multi-arch manifests (Docker Hub + GHCR)
|
|
||||||
needs: [build_single_arch]
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
permissions:
|
|
||||||
packages: write
|
|
||||||
contents: read
|
|
||||||
steps:
|
|
||||||
- name: Check out (shallow)
|
|
||||||
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 1
|
|
||||||
|
|
||||||
- name: Normalize GHCR repository
|
|
||||||
run: echo "GHCR_REPOSITORY=${GITHUB_REPOSITORY,,}" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Determine alpha version
|
|
||||||
id: version
|
|
||||||
run: |
|
|
||||||
VERSION="alpha-$(date +'%Y%m%d')-$(git rev-parse --short HEAD)"
|
|
||||||
echo "value=$VERSION" >> $GITHUB_OUTPUT
|
|
||||||
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Log in to Docker Hub
|
|
||||||
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Create & push manifest (Docker Hub - alpha)
|
|
||||||
run: |
|
|
||||||
docker buildx imagetools create \
|
|
||||||
-t calciumion/new-api:alpha \
|
|
||||||
calciumion/new-api:alpha-amd64 \
|
|
||||||
calciumion/new-api:alpha-arm64
|
|
||||||
|
|
||||||
- name: Create & push manifest (Docker Hub - versioned alpha)
|
|
||||||
run: |
|
|
||||||
docker buildx imagetools create \
|
|
||||||
-t calciumion/new-api:${VERSION} \
|
|
||||||
calciumion/new-api:${VERSION}-amd64 \
|
|
||||||
calciumion/new-api:${VERSION}-arm64
|
|
||||||
|
|
||||||
- name: Log in to GHCR
|
|
||||||
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
|
|
||||||
with:
|
|
||||||
registry: ghcr.io
|
|
||||||
username: ${{ github.actor }}
|
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Create & push manifest (GHCR - alpha)
|
|
||||||
run: |
|
|
||||||
docker buildx imagetools create \
|
|
||||||
-t ghcr.io/${GHCR_REPOSITORY}:alpha \
|
|
||||||
ghcr.io/${GHCR_REPOSITORY}:alpha-amd64 \
|
|
||||||
ghcr.io/${GHCR_REPOSITORY}:alpha-arm64
|
|
||||||
|
|
||||||
- name: Create & push manifest (GHCR - versioned alpha)
|
|
||||||
run: |
|
|
||||||
docker buildx imagetools create \
|
|
||||||
-t ghcr.io/${GHCR_REPOSITORY}:${VERSION} \
|
|
||||||
ghcr.io/${GHCR_REPOSITORY}:${VERSION}-amd64 \
|
|
||||||
ghcr.io/${GHCR_REPOSITORY}:${VERSION}-arm64
|
|
||||||
|
|
||||||
- name: Output manifest digest
|
|
||||||
run: |
|
|
||||||
echo "### Multi-arch Manifest Digests" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo '```' >> $GITHUB_STEP_SUMMARY
|
|
||||||
docker buildx imagetools inspect calciumion/new-api:alpha >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "---" >> $GITHUB_STEP_SUMMARY
|
|
||||||
docker buildx imagetools inspect ghcr.io/${GHCR_REPOSITORY}:alpha >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo '```' >> $GITHUB_STEP_SUMMARY
|
|
||||||
@@ -0,0 +1,170 @@
|
|||||||
|
name: Publish Docker image (manual branch)
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
branch:
|
||||||
|
description: "Branch name to build (e.g. alpha, nightly)"
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
prepare:
|
||||||
|
name: Prepare Docker tags
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
branch: ${{ steps.version.outputs.branch }}
|
||||||
|
sha: ${{ steps.version.outputs.sha }}
|
||||||
|
tag_prefix: ${{ steps.version.outputs.tag_prefix }}
|
||||||
|
version: ${{ steps.version.outputs.version }}
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
steps:
|
||||||
|
- name: Check out branch
|
||||||
|
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
|
ref: ${{ inputs.branch }}
|
||||||
|
|
||||||
|
- name: Resolve Docker tags
|
||||||
|
id: version
|
||||||
|
env:
|
||||||
|
BRANCH_NAME: ${{ inputs.branch }}
|
||||||
|
run: |
|
||||||
|
TAG_PREFIX=$(printf '%s' "$BRANCH_NAME" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9_.-]+/-/g; s/^[.-]+//; s/[.-]+$//')
|
||||||
|
TAG_PREFIX=${TAG_PREFIX:0:105}
|
||||||
|
TAG_PREFIX=$(printf '%s' "$TAG_PREFIX" | sed -E 's/[.-]+$//')
|
||||||
|
if [ -z "$TAG_PREFIX" ]; then
|
||||||
|
echo "::error::Branch '$BRANCH_NAME' cannot be converted to a valid Docker tag prefix"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
SHA=$(git rev-parse HEAD)
|
||||||
|
SHORT_SHA=$(git rev-parse --short HEAD)
|
||||||
|
VERSION="${TAG_PREFIX}-$(date +'%Y%m%d')-${SHORT_SHA}"
|
||||||
|
|
||||||
|
echo "branch=$BRANCH_NAME" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "sha=$SHA" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "tag_prefix=$TAG_PREFIX" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "Prepared Docker tags for $BRANCH_NAME at $SHORT_SHA"
|
||||||
|
|
||||||
|
build_single_arch:
|
||||||
|
name: Build & push (${{ matrix.arch }}) [native]
|
||||||
|
needs: [prepare]
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- arch: amd64
|
||||||
|
platform: linux/amd64
|
||||||
|
runner: ubuntu-latest
|
||||||
|
- arch: arm64
|
||||||
|
platform: linux/arm64
|
||||||
|
runner: ubuntu-24.04-arm
|
||||||
|
runs-on: ${{ matrix.runner }}
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
id-token: write
|
||||||
|
steps:
|
||||||
|
- name: Check out branch
|
||||||
|
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
|
ref: ${{ needs.prepare.outputs.sha }}
|
||||||
|
|
||||||
|
- name: Write VERSION
|
||||||
|
run: |
|
||||||
|
echo "${{ needs.prepare.outputs.version }}" > VERSION
|
||||||
|
echo "Publishing version: ${{ needs.prepare.outputs.version }} for ${{ matrix.arch }}"
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
|
||||||
|
|
||||||
|
- name: Log in to Docker Hub
|
||||||
|
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Extract metadata (labels)
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5
|
||||||
|
with:
|
||||||
|
images: |
|
||||||
|
calciumion/new-api
|
||||||
|
|
||||||
|
- name: Build & push single-arch
|
||||||
|
id: build
|
||||||
|
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
platforms: ${{ matrix.platform }}
|
||||||
|
push: true
|
||||||
|
tags: |
|
||||||
|
calciumion/new-api:${{ needs.prepare.outputs.tag_prefix }}-${{ matrix.arch }}
|
||||||
|
calciumion/new-api:${{ needs.prepare.outputs.version }}-${{ matrix.arch }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
|
provenance: mode=max
|
||||||
|
sbom: true
|
||||||
|
|
||||||
|
- name: Install cosign
|
||||||
|
uses: sigstore/cosign-installer@398d4b0eeef1380460a10c8013a76f728fb906ac # v3
|
||||||
|
|
||||||
|
- name: Sign image with cosign
|
||||||
|
run: cosign sign --yes calciumion/new-api@${{ steps.build.outputs.digest }}
|
||||||
|
|
||||||
|
- name: Output digest
|
||||||
|
run: |
|
||||||
|
echo "### Docker Image Digest (${{ matrix.arch }})" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo '```' >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "calciumion/new-api:${{ needs.prepare.outputs.tag_prefix }}-${{ matrix.arch }}" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "calciumion/new-api:${{ needs.prepare.outputs.version }}-${{ matrix.arch }}" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "${{ steps.build.outputs.digest }}" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo '```' >> $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
|
create_manifests:
|
||||||
|
name: Create multi-arch manifests (Docker Hub)
|
||||||
|
needs: [prepare, build_single_arch]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
id-token: write
|
||||||
|
steps:
|
||||||
|
- name: Log in to Docker Hub
|
||||||
|
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Create & push manifest (Docker Hub - branch)
|
||||||
|
run: |
|
||||||
|
docker buildx imagetools create \
|
||||||
|
-t calciumion/new-api:${{ needs.prepare.outputs.tag_prefix }} \
|
||||||
|
calciumion/new-api:${{ needs.prepare.outputs.tag_prefix }}-amd64 \
|
||||||
|
calciumion/new-api:${{ needs.prepare.outputs.tag_prefix }}-arm64
|
||||||
|
|
||||||
|
- name: Create & push manifest (Docker Hub - versioned)
|
||||||
|
run: |
|
||||||
|
docker buildx imagetools create \
|
||||||
|
-t calciumion/new-api:${{ needs.prepare.outputs.version }} \
|
||||||
|
calciumion/new-api:${{ needs.prepare.outputs.version }}-amd64 \
|
||||||
|
calciumion/new-api:${{ needs.prepare.outputs.version }}-arm64
|
||||||
|
|
||||||
|
- name: Install cosign
|
||||||
|
uses: sigstore/cosign-installer@398d4b0eeef1380460a10c8013a76f728fb906ac # v3
|
||||||
|
|
||||||
|
- name: Sign manifests with cosign
|
||||||
|
run: |
|
||||||
|
cosign sign --yes calciumion/new-api:${{ needs.prepare.outputs.tag_prefix }}
|
||||||
|
cosign sign --yes calciumion/new-api:${{ needs.prepare.outputs.version }}
|
||||||
|
|
||||||
|
- name: Output manifest digest
|
||||||
|
run: |
|
||||||
|
echo "### Multi-arch Manifest Digests" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo '```' >> $GITHUB_STEP_SUMMARY
|
||||||
|
docker buildx imagetools inspect calciumion/new-api:${{ needs.prepare.outputs.tag_prefix }} >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "---" >> $GITHUB_STEP_SUMMARY
|
||||||
|
docker buildx imagetools inspect calciumion/new-api:${{ needs.prepare.outputs.version }} >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo '```' >> $GITHUB_STEP_SUMMARY
|
||||||
@@ -1,113 +0,0 @@
|
|||||||
name: Publish Docker image (nightly)
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- nightly
|
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
name:
|
|
||||||
description: "reason"
|
|
||||||
required: false
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build_single_arch:
|
|
||||||
name: Build & push (${{ matrix.arch }}) [native]
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- arch: amd64
|
|
||||||
platform: linux/amd64
|
|
||||||
runner: ubuntu-latest
|
|
||||||
- arch: arm64
|
|
||||||
platform: linux/arm64
|
|
||||||
runner: ubuntu-24.04-arm
|
|
||||||
runs-on: ${{ matrix.runner }}
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Check out (shallow)
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 1
|
|
||||||
|
|
||||||
- name: Determine nightly version
|
|
||||||
id: version
|
|
||||||
run: |
|
|
||||||
VERSION="nightly-$(date +'%Y%m%d')-$(git rev-parse --short HEAD)"
|
|
||||||
echo "$VERSION" > VERSION
|
|
||||||
echo "value=$VERSION" >> $GITHUB_OUTPUT
|
|
||||||
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
|
||||||
echo "Publishing version: $VERSION for ${{ matrix.arch }}"
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
- name: Log in to Docker Hub
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Extract metadata (labels)
|
|
||||||
id: meta
|
|
||||||
uses: docker/metadata-action@v5
|
|
||||||
with:
|
|
||||||
images: |
|
|
||||||
calciumion/new-api
|
|
||||||
|
|
||||||
- name: Build & push single-arch
|
|
||||||
uses: docker/build-push-action@v6
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
platforms: ${{ matrix.platform }}
|
|
||||||
push: true
|
|
||||||
tags: |
|
|
||||||
calciumion/new-api:nightly-${{ matrix.arch }}
|
|
||||||
calciumion/new-api:${{ steps.version.outputs.value }}-${{ matrix.arch }}
|
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
|
||||||
cache-from: type=gha
|
|
||||||
cache-to: type=gha,mode=max
|
|
||||||
provenance: false
|
|
||||||
sbom: false
|
|
||||||
|
|
||||||
create_manifests:
|
|
||||||
name: Create multi-arch manifests (Docker Hub)
|
|
||||||
needs: [build_single_arch]
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Check out (shallow)
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 1
|
|
||||||
|
|
||||||
- name: Determine nightly version
|
|
||||||
id: version
|
|
||||||
run: |
|
|
||||||
VERSION="nightly-$(date +'%Y%m%d')-$(git rev-parse --short HEAD)"
|
|
||||||
echo "value=$VERSION" >> $GITHUB_OUTPUT
|
|
||||||
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Log in to Docker Hub
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Create & push manifest (Docker Hub - nightly)
|
|
||||||
run: |
|
|
||||||
docker buildx imagetools create \
|
|
||||||
-t calciumion/new-api:nightly \
|
|
||||||
calciumion/new-api:nightly-amd64 \
|
|
||||||
calciumion/new-api:nightly-arm64
|
|
||||||
|
|
||||||
- name: Create & push manifest (Docker Hub - versioned nightly)
|
|
||||||
run: |
|
|
||||||
docker buildx imagetools create \
|
|
||||||
-t calciumion/new-api:${VERSION} \
|
|
||||||
calciumion/new-api:${VERSION}-amd64 \
|
|
||||||
calciumion/new-api:${VERSION}-arm64
|
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
name: Sync Release to Gitee
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
tag_name:
|
|
||||||
description: 'Release Tag to sync (e.g. v1.0.0)'
|
|
||||||
required: true
|
|
||||||
type: string
|
|
||||||
|
|
||||||
# 配置你的 Gitee 仓库信息
|
|
||||||
env:
|
|
||||||
GITEE_OWNER: 'QuantumNous' # 修改为你的 Gitee 用户名
|
|
||||||
GITEE_REPO: 'new-api' # 修改为你的 Gitee 仓库名
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
sync-to-gitee:
|
|
||||||
runs-on: sync
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Get Release Info
|
|
||||||
id: release_info
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
TAG_NAME: ${{ github.event.inputs.tag_name }}
|
|
||||||
run: |
|
|
||||||
# 获取 release 信息
|
|
||||||
RELEASE_INFO=$(gh release view "$TAG_NAME" --json name,body,tagName,targetCommitish)
|
|
||||||
|
|
||||||
RELEASE_NAME=$(echo "$RELEASE_INFO" | jq -r '.name')
|
|
||||||
TARGET_COMMITISH=$(echo "$RELEASE_INFO" | jq -r '.targetCommitish')
|
|
||||||
|
|
||||||
# 使用多行字符串输出
|
|
||||||
{
|
|
||||||
echo "release_name=$RELEASE_NAME"
|
|
||||||
echo "target_commitish=$TARGET_COMMITISH"
|
|
||||||
echo "release_body<<EOF"
|
|
||||||
echo "$RELEASE_INFO" | jq -r '.body'
|
|
||||||
echo "EOF"
|
|
||||||
} >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
# 下载 release 的所有附件
|
|
||||||
gh release download "$TAG_NAME" --dir ./release_assets || echo "No assets to download"
|
|
||||||
|
|
||||||
# 列出下载的文件
|
|
||||||
ls -la ./release_assets/ || echo "No assets directory"
|
|
||||||
|
|
||||||
- name: Create Gitee Release
|
|
||||||
id: create_release
|
|
||||||
uses: nICEnnnnnnnLee/action-gitee-release@v2.0.0
|
|
||||||
with:
|
|
||||||
gitee_action: create_release
|
|
||||||
gitee_owner: ${{ env.GITEE_OWNER }}
|
|
||||||
gitee_repo: ${{ env.GITEE_REPO }}
|
|
||||||
gitee_token: ${{ secrets.GITEE_TOKEN }}
|
|
||||||
gitee_tag_name: ${{ github.event.inputs.tag_name }}
|
|
||||||
gitee_release_name: ${{ steps.release_info.outputs.release_name }}
|
|
||||||
gitee_release_body: ${{ steps.release_info.outputs.release_body }}
|
|
||||||
gitee_target_commitish: ${{ steps.release_info.outputs.target_commitish }}
|
|
||||||
|
|
||||||
- name: Upload Assets to Gitee
|
|
||||||
if: hashFiles('release_assets/*') != ''
|
|
||||||
uses: nICEnnnnnnnLee/action-gitee-release@v2.0.0
|
|
||||||
with:
|
|
||||||
gitee_action: upload_asset
|
|
||||||
gitee_owner: ${{ env.GITEE_OWNER }}
|
|
||||||
gitee_repo: ${{ env.GITEE_REPO }}
|
|
||||||
gitee_token: ${{ secrets.GITEE_TOKEN }}
|
|
||||||
gitee_release_id: ${{ steps.create_release.outputs.release-id }}
|
|
||||||
gitee_upload_retry_times: 3
|
|
||||||
gitee_files: |
|
|
||||||
release_assets/*
|
|
||||||
|
|
||||||
- name: Cleanup
|
|
||||||
if: always()
|
|
||||||
run: |
|
|
||||||
rm -rf release_assets/
|
|
||||||
|
|
||||||
- name: Summary
|
|
||||||
if: success()
|
|
||||||
run: |
|
|
||||||
echo "✅ Successfully synced release ${{ github.event.inputs.tag_name }} to Gitee!"
|
|
||||||
echo "🔗 Gitee Release URL: https://gitee.com/${{ env.GITEE_OWNER }}/${{ env.GITEE_REPO }}/releases/tag/${{ github.event.inputs.tag_name }}"
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user