Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
55858f35
authored
Jul 03, 2026
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add manual Docker image publishing workflow
parent
0977965d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
288 deletions
+75
-288
.github/workflows/docker-image-branch.yml
+75
-84
.github/workflows/docker-image-nightly.yml
+0
-113
.github/workflows/sync-to-gitee.yml
+0
-91
No files found.
.github/workflows/docker-image-
alpha
.yml
→
.github/workflows/docker-image-
branch
.yml
View file @
55858f35
name
:
Publish Docker image (
alpha
)
name
:
Publish Docker image (
manual branch
)
on
:
on
:
push
:
branches
:
-
alpha
workflow_dispatch
:
workflow_dispatch
:
inputs
:
inputs
:
name
:
branch
:
description
:
"
reason"
description
:
"
Branch
name
to
build
(e.g.
alpha,
nightly)"
required
:
false
required
:
true
type
:
string
jobs
:
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
:
build_single_arch
:
name
:
Build & push (${{ matrix.arch }}) [native]
name
:
Build & push (${{ matrix.arch }}) [native]
needs
:
[
prepare
]
strategy
:
strategy
:
fail-fast
:
false
fail-fast
:
false
matrix
:
matrix
:
...
@@ -25,26 +64,19 @@ jobs:
...
@@ -25,26 +64,19 @@ jobs:
runner
:
ubuntu-24.04-arm
runner
:
ubuntu-24.04-arm
runs-on
:
${{ matrix.runner }}
runs-on
:
${{ matrix.runner }}
permissions
:
permissions
:
packages
:
write
contents
:
read
contents
:
read
id-token
:
write
id-token
:
write
steps
:
steps
:
-
name
:
Check out
(shallow)
-
name
:
Check out
branch
uses
:
actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
# v4
uses
:
actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
# v4
with
:
with
:
fetch-depth
:
1
fetch-depth
:
1
ref
:
${{ needs.prepare.outputs.sha }}
-
name
:
Determine alpha version
-
name
:
Write VERSION
id
:
version
run
:
|
run
:
|
VERSION="alpha-$(date +'%Y%m%d')-$(git rev-parse --short HEAD)"
echo "${{ needs.prepare.outputs.version }}" > VERSION
echo "$VERSION" > VERSION
echo "Publishing version: ${{ needs.prepare.outputs.version }} for ${{ matrix.arch }}"
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
-
name
:
Set up Docker Buildx
uses
:
docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f
# v3
uses
:
docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f
# v3
...
@@ -55,22 +87,14 @@ jobs:
...
@@ -55,22 +87,14 @@ jobs:
username
:
${{ secrets.DOCKERHUB_USERNAME }}
username
:
${{ secrets.DOCKERHUB_USERNAME }}
password
:
${{ secrets.DOCKERHUB_TOKEN }}
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)
-
name
:
Extract metadata (labels)
id
:
meta
id
:
meta
uses
:
docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051
# v5
uses
:
docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051
# v5
with
:
with
:
images
:
|
images
:
|
calciumion/new-api
calciumion/new-api
ghcr.io/${{ env.GHCR_REPOSITORY }}
-
name
:
Build & push single-arch
(to both registries)
-
name
:
Build & push single-arch
id
:
build
id
:
build
uses
:
docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8
# v6
uses
:
docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8
# v6
with
:
with
:
...
@@ -78,10 +102,8 @@ jobs:
...
@@ -78,10 +102,8 @@ jobs:
platforms
:
${{ matrix.platform }}
platforms
:
${{ matrix.platform }}
push
:
true
push
:
true
tags
:
|
tags
:
|
calciumion/new-api:alpha-${{ matrix.arch }}
calciumion/new-api:${{ needs.prepare.outputs.tag_prefix }}-${{ matrix.arch }}
calciumion/new-api:${{ steps.version.outputs.value }}-${{ matrix.arch }}
calciumion/new-api:${{ needs.prepare.outputs.version }}-${{ 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 }}
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
...
@@ -92,88 +114,57 @@ jobs:
...
@@ -92,88 +114,57 @@ jobs:
uses
:
sigstore/cosign-installer@398d4b0eeef1380460a10c8013a76f728fb906ac
# v3
uses
:
sigstore/cosign-installer@398d4b0eeef1380460a10c8013a76f728fb906ac
# v3
-
name
:
Sign image with cosign
-
name
:
Sign image with cosign
run
:
|
run
:
cosign sign --yes calciumion/new-api@${{ steps.build.outputs.digest }}
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
-
name
:
Output digest
run
:
|
run
:
|
echo "### Docker Image Digest (${{ matrix.arch }})" >> $GITHUB_STEP_SUMMARY
echo "### Docker Image Digest (${{ matrix.arch }})" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "calciumion/new-api:
alpha
-${{ matrix.arch }}" >> $GITHUB_STEP_SUMMARY
echo "calciumion/new-api:
${{ needs.prepare.outputs.tag_prefix }}
-${{ matrix.arch }}" >> $GITHUB_STEP_SUMMARY
echo "
ghcr.io/${{ env.GHCR_REPOSITORY }}:alpha
-${{ 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 "${{ steps.build.outputs.digest }}" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
create_manifests
:
create_manifests
:
name
:
Create multi-arch manifests (Docker Hub
+ GHCR
)
name
:
Create multi-arch manifests (Docker Hub)
needs
:
[
build_single_arch
]
needs
:
[
prepare
,
build_single_arch
]
runs-on
:
ubuntu-latest
runs-on
:
ubuntu-latest
permissions
:
permissions
:
packages
:
write
id-token
:
write
contents
:
read
steps
:
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
-
name
:
Log in to Docker Hub
uses
:
docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9
# v3
uses
:
docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9
# v3
with
:
with
:
username
:
${{ secrets.DOCKERHUB_USERNAME }}
username
:
${{ secrets.DOCKERHUB_USERNAME }}
password
:
${{ secrets.DOCKERHUB_TOKEN }}
password
:
${{ secrets.DOCKERHUB_TOKEN }}
-
name
:
Create & push manifest (Docker Hub -
alpha
)
-
name
:
Create & push manifest (Docker Hub -
branch
)
run
:
|
run
:
|
docker buildx imagetools create \
docker buildx imagetools create \
-t calciumion/new-api:
alpha
\
-t calciumion/new-api:
${{ needs.prepare.outputs.tag_prefix }}
\
calciumion/new-api:
alpha
-amd64 \
calciumion/new-api:
${{ needs.prepare.outputs.tag_prefix }}
-amd64 \
calciumion/new-api:
alpha
-arm64
calciumion/new-api:
${{ needs.prepare.outputs.tag_prefix }}
-arm64
-
name
:
Create & push manifest (Docker Hub - versioned
alpha
)
-
name
:
Create & push manifest (Docker Hub - versioned)
run
:
|
run
:
|
docker buildx imagetools create \
docker buildx imagetools create \
-t calciumion/new-api:${
VERSION
} \
-t calciumion/new-api:${
{ needs.prepare.outputs.version }
} \
calciumion/new-api:${
VERSION
}-amd64 \
calciumion/new-api:${
{ needs.prepare.outputs.version }
}-amd64 \
calciumion/new-api:${
VERSION
}-arm64
calciumion/new-api:${
{ needs.prepare.outputs.version }
}-arm64
-
name
:
Log in to GHCR
-
name
:
Install cosign
uses
:
docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9
# v3
uses
:
sigstore/cosign-installer@398d4b0eeef1380460a10c8013a76f728fb906ac
# 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)
-
name
:
Sign manifests with cosign
run
:
|
run
:
|
docker buildx imagetools create \
cosign sign --yes calciumion/new-api:${{ needs.prepare.outputs.tag_prefix }}
-t ghcr.io/${GHCR_REPOSITORY}:${VERSION} \
cosign sign --yes calciumion/new-api:${{ needs.prepare.outputs.version }}
ghcr.io/${GHCR_REPOSITORY}:${VERSION}-amd64 \
ghcr.io/${GHCR_REPOSITORY}:${VERSION}-arm64
-
name
:
Output manifest digest
-
name
:
Output manifest digest
run
:
|
run
:
|
echo "### Multi-arch Manifest Digests" >> $GITHUB_STEP_SUMMARY
echo "### Multi-arch Manifest Digests" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
docker buildx imagetools inspect calciumion/new-api:
alpha
>> $GITHUB_STEP_SUMMARY
docker buildx imagetools inspect calciumion/new-api:
${{ needs.prepare.outputs.tag_prefix }}
>> $GITHUB_STEP_SUMMARY
echo "---" >> $GITHUB_STEP_SUMMARY
echo "---" >> $GITHUB_STEP_SUMMARY
docker buildx imagetools inspect
ghcr.io/${GHCR_REPOSITORY}:alpha
>> $GITHUB_STEP_SUMMARY
docker buildx imagetools inspect
calciumion/new-api:${{ needs.prepare.outputs.version }}
>> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
.github/workflows/docker-image-nightly.yml
deleted
100644 → 0
View file @
0977965d
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
.github/workflows/sync-to-gitee.yml
deleted
100644 → 0
View file @
0977965d
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 }}"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment