Skip to content

refactor: create-release 优先读 tag annotation 作为 release notes #53

refactor: create-release 优先读 tag annotation 作为 release notes

refactor: create-release 优先读 tag annotation 作为 release notes #53

Workflow file for this run

name: build-and-push
on:
workflow_dispatch:
inputs:
dockerImageTag:
description: 'Image Tag'
default: 'v0.0.1'
required: true
dockerImageTagWithLatest:
description: '是否发布latest tag(正式发版时选择)'
default: false
type: boolean
architecture:
description: 'Architecture'
required: true
default: 'linux/amd64'
type: choice
options:
- linux/amd64
- linux/arm64
- linux/amd64,linux/arm64
push:
tags:
- 'v*'
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- run: rm -rf -- ./* ./.??*
- uses: actions/checkout@v6
with:
ref: ${{ github.ref_name }}
- id: prepare
run: |
if [ "${{ github.event_name }}" = "push" ]; then
TAG="${{ github.ref_name }}"
ARCH="linux/amd64,linux/arm64"
WITH_LATEST=$(echo "$TAG" | grep -qE '^v[0-9]+\.[0-9]+\.[0-9]+$' && echo true || echo false)
else
TAG="${{ github.event.inputs.dockerImageTag }}"
ARCH="${{ github.event.inputs.architecture }}"
WITH_LATEST="${{ github.event.inputs.dockerImageTagWithLatest }}"
fi
IMAGE=1panel/ai-portal
TAGS="--tag ${IMAGE}:${TAG}"
[ "$WITH_LATEST" = "true" ] && TAGS="${TAGS} --tag ${IMAGE}:${TAG%%.*} --tag ${IMAGE}:latest"
echo "buildx_args=--platform $ARCH \
--cache-from type=gha --cache-to type=gha,mode=max \
--build-arg DOCKER_IMAGE_TAG=${TAG} \
--build-arg BUILD_AT=$(TZ=Asia/Shanghai date +'%Y-%m-%dT%H:%M') \
--build-arg GITHUB_COMMIT=${GITHUB_SHA::8} \
${TAGS} ." >> "$GITHUB_OUTPUT"
- uses: docker/setup-qemu-action@v4
with:
cache-image: true
- uses: docker/setup-buildx-action@v4
- uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- run: docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }}
- name: Create git tag
if: github.event_name == 'workflow_dispatch'
run: |
TAG="${{ github.event.inputs.dockerImageTag }}"
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "Tag $TAG already exists, skipping"
else
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "$TAG" -m "Release $TAG"
git push origin "$TAG"
echo "✅ Git tag $TAG created and pushed"
fi