mirror of
https://github.com/RuoJi6/ARTEX.git
synced 2026-11-18 07:23:50 +08:00
feat(release): publish standalone repository and Docker Hub images
This commit is contained in:
1 parent
714b00cccb
commit
dfef372b64
8 files changed
+149
-42
No files matched your search
@@ -3,7 +3,7 @@ on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: "已存在的正式版本标签,例如 v0.3.16"
|
||||
description: "已存在的正式版本标签,例如 v0.3.17"
|
||||
required: true
|
||||
type: string
|
||||
push:
|
||||
@@ -27,9 +27,14 @@ jobs:
|
||||
id: version
|
||||
env:
|
||||
RELEASE_TAG: ${{ inputs.tag || github.ref_name }}
|
||||
ARTEX_DOCKER_IMAGE: ${{ vars.ARTEX_DOCKER_IMAGE }}
|
||||
run: |
|
||||
if [[ ! "$RELEASE_TAG" =~ ^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]]; then
|
||||
echo "正式版本必须是 v主版本.次版本.修订号,例如 v0.3.16" >&2
|
||||
echo "正式版本必须是 v主版本.次版本.修订号,例如 v0.3.17" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! "$ARTEX_DOCKER_IMAGE" =~ ^[a-z0-9][a-z0-9_-]*/[a-z0-9]+([._-][a-z0-9]+)*$ ]]; then
|
||||
echo "请先配置 Actions 变量 ARTEX_DOCKER_IMAGE,格式为 Docker Hub 用户名/镜像名" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "tag=$RELEASE_TAG" >> "$GITHUB_OUTPUT"
|
||||
@@ -116,7 +121,7 @@ jobs:
|
||||
|
||||
# ③ 汇总所有 zip → 创建 GitHub Release
|
||||
release:
|
||||
needs: [prepare, binaries]
|
||||
needs: [prepare, binaries, docker-publish]
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
@@ -160,47 +165,102 @@ jobs:
|
||||
dist/*.zip
|
||||
dist/SHA256SUMS
|
||||
generate_release_notes: true
|
||||
body: |
|
||||
Docker Hub 镜像:`${{ vars.ARTEX_DOCKER_IMAGE }}:${{ needs.prepare.outputs.tag }}`,同时提供 `latest`。
|
||||
支持 Linux AMD64 / ARM64,Docker 会自动选择宿主机架构。
|
||||
程序包提供 Linux、macOS 的 AMD64 / ARM64 及 Windows AMD64,并附 SHA256SUMS。
|
||||
部署和在线更新说明见本仓库 README。
|
||||
- name: Publish complete release
|
||||
run: gh release edit "$RELEASE_TAG" --draft=false --latest
|
||||
|
||||
# ④ 多架构镜像 → 推 Docker Hub(复用 binaries 编好的 Linux 二进制,
|
||||
# 镜像里只装工具 + 放二进制;arm64 仅需模拟 apt 层,构建快很多)
|
||||
# ④ 在原生 AMD64 / ARM64 runner 上构建和测试,再推送架构镜像。
|
||||
docker:
|
||||
# 页面更新只需要 Release;镜像发布按需启用,不依赖原作者的账号。
|
||||
if: vars.ARTEX_DOCKER_IMAGE != ''
|
||||
needs: [prepare, binaries]
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- { arch: amd64, runner: ubuntu-24.04 }
|
||||
- { arch: arm64, runner: ubuntu-24.04-arm }
|
||||
runs-on: ${{ matrix.runner }}
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:16-alpine
|
||||
env:
|
||||
POSTGRES_USER: artex
|
||||
POSTGRES_PASSWORD: artex-ci-test
|
||||
POSTGRES_DB: artex
|
||||
ports:
|
||||
- 5432:5432
|
||||
options: >-
|
||||
--health-cmd "pg_isready -U artex -d artex"
|
||||
--health-interval 5s --health-timeout 3s --health-retries 10
|
||||
steps:
|
||||
- uses: actions/checkout@v4 # 取 Dockerfile 与 skills/
|
||||
with:
|
||||
ref: ${{ needs.prepare.outputs.commit }}
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: bin-linux-amd64
|
||||
path: dist/amd64
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: bin-linux-arm64
|
||||
path: dist/arm64
|
||||
- uses: docker/setup-qemu-action@v3
|
||||
name: bin-linux-${{ matrix.arch }}
|
||||
path: dist/${{ matrix.arch }}
|
||||
- uses: docker/setup-buildx-action@v3
|
||||
- uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- uses: docker/metadata-action@v5
|
||||
id: meta
|
||||
with:
|
||||
images: ${{ vars.ARTEX_DOCKER_IMAGE }}
|
||||
tags: |
|
||||
type=raw,value=${{ needs.prepare.outputs.tag }}
|
||||
type=raw,value=latest
|
||||
- uses: docker/build-push-action@v6
|
||||
- name: Build image for native smoke test
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/amd64,linux/arm64
|
||||
platforms: linux/${{ matrix.arch }}
|
||||
load: true
|
||||
tags: artex:smoke
|
||||
cache-from: type=gha,scope=docker-${{ matrix.arch }}
|
||||
cache-to: type=gha,mode=max,scope=docker-${{ matrix.arch }}
|
||||
- name: Test application startup and embedded frontend
|
||||
env:
|
||||
RELEASE_TAG: ${{ needs.prepare.outputs.tag }}
|
||||
run: |
|
||||
docker run --rm --entrypoint /app/artex artex:smoke -h
|
||||
docker run -d --name artex-smoke --network host \
|
||||
-e ARTEX_PG_DSN='postgres://artex:[email protected]:5432/artex?sslmode=disable' artex:smoke
|
||||
trap 'docker logs artex-smoke; docker rm -f artex-smoke' EXIT
|
||||
curl --fail --retry 30 --retry-connrefused --retry-delay 2 --max-time 3 \
|
||||
http://127.0.0.1:8787/api/health > /tmp/artex-health.json
|
||||
jq -e --arg version "${RELEASE_TAG#v}" '.ok == true and .version == $version' /tmp/artex-health.json
|
||||
curl --fail http://127.0.0.1:8787/ > /tmp/artex-index.html
|
||||
grep -qi '<!doctype html' /tmp/artex-index.html
|
||||
- name: Push tested architecture image
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/${{ matrix.arch }}
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
tags: ${{ vars.ARTEX_DOCKER_IMAGE }}:${{ needs.prepare.outputs.tag }}-${{ matrix.arch }}
|
||||
labels: |
|
||||
org.opencontainers.image.source=https://github.com/${{ github.repository }}
|
||||
org.opencontainers.image.version=${{ needs.prepare.outputs.tag }}
|
||||
org.opencontainers.image.revision=${{ needs.prepare.outputs.commit }}
|
||||
org.opencontainers.image.licenses=AGPL-3.0
|
||||
cache-from: type=gha,scope=docker-${{ matrix.arch }}
|
||||
|
||||
# ⑤ 只有两种架构都通过启动验证,才发布正式版本和 latest 镜像。
|
||||
docker-publish:
|
||||
needs: [prepare, docker]
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: docker/setup-buildx-action@v3
|
||||
- uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- name: Publish multi-platform image
|
||||
env:
|
||||
IMAGE: ${{ vars.ARTEX_DOCKER_IMAGE }}
|
||||
RELEASE_TAG: ${{ needs.prepare.outputs.tag }}
|
||||
run: |
|
||||
docker buildx imagetools create \
|
||||
--tag "$IMAGE:$RELEASE_TAG" --tag "$IMAGE:latest" \
|
||||
"$IMAGE:$RELEASE_TAG-amd64" "$IMAGE:$RELEASE_TAG-arm64"
|
||||
docker buildx imagetools inspect "$IMAGE:$RELEASE_TAG" --raw > /tmp/artex-manifest.json
|
||||
jq -e '[.manifests[].platform | select(.os == "linux") | .architecture] | index("amd64") != null and index("arm64") != null' /tmp/artex-manifest.json
|
||||
Reference in new issue
Block a user