mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-02 14:56:38 +08:00
ci: canary
This commit is contained in:
@@ -9,6 +9,12 @@ on:
|
||||
type: string
|
||||
push:
|
||||
tags: ["v*"]
|
||||
branches: ["canary"]
|
||||
|
||||
# One active run per ref (e.g. canary); newer runs cancel older in-progress builds.
|
||||
concurrency:
|
||||
group: build-image-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
@@ -52,7 +58,9 @@ jobs:
|
||||
|
||||
OWNER="${GITHUB_REPOSITORY_OWNER,,}"
|
||||
|
||||
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
|
||||
if [[ "${GITHUB_REF}" == refs/heads/canary ]]; then
|
||||
VERSION="canary"
|
||||
elif [[ "${GITHUB_REF}" == refs/tags/* ]]; then
|
||||
VERSION="${GITHUB_REF_NAME}"
|
||||
elif [[ -n "$INPUT_VERSION" ]]; then
|
||||
VERSION="$INPUT_VERSION"
|
||||
@@ -135,7 +143,9 @@ jobs:
|
||||
|
||||
OWNER="${GITHUB_REPOSITORY_OWNER,,}"
|
||||
|
||||
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
|
||||
if [[ "${GITHUB_REF}" == refs/heads/canary ]]; then
|
||||
VERSION="canary"
|
||||
elif [[ "${GITHUB_REF}" == refs/tags/* ]]; then
|
||||
VERSION="${GITHUB_REF_NAME}"
|
||||
elif [[ -n "$INPUT_VERSION" ]]; then
|
||||
VERSION="$INPUT_VERSION"
|
||||
@@ -181,16 +191,23 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "${VERSION}" =~ (alpha|beta|rc) ]]; then
|
||||
FLOATING_TAG="beta"
|
||||
# canary builds only publish the movable :canary tag (not latest/beta)
|
||||
if [[ "${VERSION}" == "canary" ]]; then
|
||||
docker buildx imagetools create \
|
||||
-t "${IMAGE}:canary" \
|
||||
"${references[@]}"
|
||||
else
|
||||
FLOATING_TAG="latest"
|
||||
fi
|
||||
if [[ "${VERSION}" =~ (alpha|beta|rc) ]]; then
|
||||
FLOATING_TAG="beta"
|
||||
else
|
||||
FLOATING_TAG="latest"
|
||||
fi
|
||||
|
||||
docker buildx imagetools create \
|
||||
-t "${IMAGE}:${VERSION}" \
|
||||
-t "${IMAGE}:${FLOATING_TAG}" \
|
||||
"${references[@]}"
|
||||
docker buildx imagetools create \
|
||||
-t "${IMAGE}:${VERSION}" \
|
||||
-t "${IMAGE}:${FLOATING_TAG}" \
|
||||
"${references[@]}"
|
||||
fi
|
||||
env:
|
||||
IMAGE: ${{ env.IMAGE }}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.PHONY: swagger license license-check build-embedded build-test cross-build code-check format
|
||||
.PHONY: swagger license license-check build-embedded build-test cross-build code-check format canary
|
||||
|
||||
VERSION ?= dev
|
||||
BUILD_DATE ?= $(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
|
||||
@@ -108,3 +108,38 @@ dev:
|
||||
echo "==> Development servers exited with errors." >&2; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
# Merge the current branch into canary and push, triggering Build Image (:canary).
|
||||
canary:
|
||||
@set -e; \
|
||||
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then \
|
||||
echo "error: not a git repository" >&2; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
if [ -n "$$(git status --porcelain)" ]; then \
|
||||
echo "error: working tree is dirty; commit or stash changes first" >&2; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
CURRENT_BRANCH=$$(git rev-parse --abbrev-ref HEAD); \
|
||||
if [ "$$CURRENT_BRANCH" = "HEAD" ]; then \
|
||||
echo "error: detached HEAD; checkout a branch first" >&2; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
echo "==> Publishing $$CURRENT_BRANCH to canary..."; \
|
||||
git fetch origin; \
|
||||
if git show-ref --verify --quiet refs/remotes/origin/canary; then \
|
||||
git checkout -B canary origin/canary; \
|
||||
else \
|
||||
git checkout -B canary; \
|
||||
fi; \
|
||||
if [ "$$CURRENT_BRANCH" != "canary" ]; then \
|
||||
if ! git merge --no-edit "$$CURRENT_BRANCH"; then \
|
||||
echo "error: merge failed; resolve conflicts on canary, then: git push -u origin canary" >&2; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
fi; \
|
||||
git push -u origin canary; \
|
||||
if [ "$$CURRENT_BRANCH" != "canary" ]; then \
|
||||
git checkout "$$CURRENT_BRANCH"; \
|
||||
fi; \
|
||||
echo "==> canary updated and pushed (image tag: canary)"
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
allowBuilds:
|
||||
'@parcel/watcher': true
|
||||
'@swc/core': true
|
||||
core-js: true
|
||||
sharp: true
|
||||
unrs-resolver: true
|
||||
|
||||
Reference in New Issue
Block a user