mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-08 08:36:37 +08:00
[功能] 添加可选版本输入以支持自定义 Docker 镜像和发布版本
This commit is contained in:
@@ -2,6 +2,11 @@ name: Docker image builds
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
version:
|
||||||
|
description: "Image version/tag to publish, for example v1.0.0-beta"
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
push:
|
push:
|
||||||
tags: ["v*"]
|
tags: ["v*"]
|
||||||
|
|
||||||
@@ -35,9 +40,25 @@ jobs:
|
|||||||
|
|
||||||
- name: Set image metadata
|
- name: Set image metadata
|
||||||
shell: bash
|
shell: bash
|
||||||
|
env:
|
||||||
|
INPUT_VERSION: ${{ github.event.inputs.version }}
|
||||||
run: |
|
run: |
|
||||||
|
POINTED_TAG="$(git tag --points-at HEAD --list 'v*' | sort -V | tail -n1)"
|
||||||
|
INPUT_VERSION="${INPUT_VERSION//[[:space:]]/}"
|
||||||
|
|
||||||
echo "IMAGE=ghcr.io/${GITHUB_REPOSITORY,,}" >> "$GITHUB_ENV"
|
echo "IMAGE=ghcr.io/${GITHUB_REPOSITORY,,}" >> "$GITHUB_ENV"
|
||||||
echo "VERSION=$(git describe --tags)" >> "$GITHUB_ENV"
|
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
|
||||||
|
VERSION="${GITHUB_REF_NAME}"
|
||||||
|
elif [[ -n "$INPUT_VERSION" ]]; then
|
||||||
|
VERSION="$INPUT_VERSION"
|
||||||
|
elif [[ -n "$POINTED_TAG" ]]; then
|
||||||
|
VERSION="$POINTED_TAG"
|
||||||
|
else
|
||||||
|
echo "workflow_dispatch requires an explicit version input when HEAD is not tagged" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -99,9 +120,25 @@ jobs:
|
|||||||
|
|
||||||
- name: Set image metadata
|
- name: Set image metadata
|
||||||
shell: bash
|
shell: bash
|
||||||
|
env:
|
||||||
|
INPUT_VERSION: ${{ github.event.inputs.version }}
|
||||||
run: |
|
run: |
|
||||||
|
POINTED_TAG="$(git tag --points-at HEAD --list 'v*' | sort -V | tail -n1)"
|
||||||
|
INPUT_VERSION="${INPUT_VERSION//[[:space:]]/}"
|
||||||
|
|
||||||
echo "IMAGE=ghcr.io/${GITHUB_REPOSITORY,,}" >> "$GITHUB_ENV"
|
echo "IMAGE=ghcr.io/${GITHUB_REPOSITORY,,}" >> "$GITHUB_ENV"
|
||||||
echo "VERSION=$(git describe --tags)" >> "$GITHUB_ENV"
|
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
|
||||||
|
VERSION="${GITHUB_REF_NAME}"
|
||||||
|
elif [[ -n "$INPUT_VERSION" ]]; then
|
||||||
|
VERSION="$INPUT_VERSION"
|
||||||
|
elif [[ -n "$POINTED_TAG" ]]; then
|
||||||
|
VERSION="$POINTED_TAG"
|
||||||
|
else
|
||||||
|
echo "workflow_dispatch requires an explicit version input when HEAD is not tagged" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
- name: Download digests
|
- name: Download digests
|
||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@v4
|
||||||
|
|||||||
@@ -2,10 +2,15 @@ name: Release
|
|||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
push:
|
inputs:
|
||||||
tags: ["v*"]
|
version:
|
||||||
|
description: "Release version/tag to publish, for example v1.0.0-beta"
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
push:
|
||||||
|
tags: ["v*"]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
prepare:
|
prepare:
|
||||||
@@ -20,22 +25,33 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Resolve version metadata
|
- name: Resolve version metadata
|
||||||
id: version
|
id: version
|
||||||
run: |
|
env:
|
||||||
SHOULD_RUN=true
|
INPUT_VERSION: ${{ github.event.inputs.version }}
|
||||||
POINTED_TAG="$(git tag --points-at HEAD --list 'v*' | sort -V | tail -n1)"
|
run: |
|
||||||
|
SHOULD_RUN=true
|
||||||
if [[ "${GITHUB_REF}" == refs/heads/main ]] && [[ -n "$POINTED_TAG" ]]; then
|
POINTED_TAG="$(git tag --points-at HEAD --list 'v*' | sort -V | tail -n1)"
|
||||||
SHOULD_RUN=true
|
INPUT_VERSION="${INPUT_VERSION//[[:space:]]/}"
|
||||||
VERSION="$POINTED_TAG"
|
|
||||||
elif [[ "${GITHUB_REF}" == refs/tags/* ]]; then
|
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
|
||||||
VERSION="${GITHUB_REF_NAME}"
|
VERSION="${GITHUB_REF_NAME}"
|
||||||
else
|
elif [[ -n "$INPUT_VERSION" ]]; then
|
||||||
VERSION="$(git describe --tags)"
|
VERSION="$INPUT_VERSION"
|
||||||
fi
|
elif [[ -n "$POINTED_TAG" ]]; then
|
||||||
|
VERSION="$POINTED_TAG"
|
||||||
echo "should_run=$SHOULD_RUN" >> "$GITHUB_OUTPUT"
|
elif [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]]; then
|
||||||
|
echo "workflow_dispatch requires an explicit version input when HEAD is not tagged" >&2
|
||||||
|
exit 1
|
||||||
|
elif [[ "${GITHUB_REF}" == refs/heads/main ]]; then
|
||||||
|
echo "main branch release requires the current commit to be tagged" >&2
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "unable to resolve release version from the current ref" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "should_run=$SHOULD_RUN" >> "$GITHUB_OUTPUT"
|
||||||
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
||||||
if [[ "$VERSION" =~ ^v[0-9]+(\.[0-9]+)*$ ]]; then
|
if [[ "$VERSION" =~ ^v[0-9]+(\.[0-9]+)*$ ]]; then
|
||||||
echo "is_prerelease=false" >> "$GITHUB_OUTPUT"
|
echo "is_prerelease=false" >> "$GITHUB_OUTPUT"
|
||||||
|
|||||||
Reference in New Issue
Block a user