mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-10-14 03:52:26 +08:00
39 lines
1.6 KiB
Bash
39 lines
1.6 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
: "${RELEASE_VERSION:?}" "${RELEASE_SHA:?}" "${GITHUB_REPOSITORY:?}" "${RUNNER_TEMP:?}"
|
|
owner=${GITHUB_REPOSITORY%%/*}
|
|
registries=("ghcr.io/${owner,,}/sub2api")
|
|
if [[ ${SIMPLE_RELEASE:-false} != true && ${DOCKERHUB_USERNAME:-skip} != skip ]]; then
|
|
registries+=("${DOCKERHUB_USERNAME}/sub2api")
|
|
fi
|
|
arches=(amd64 arm64)
|
|
if [[ ${SIMPLE_RELEASE:-false} == true ]]; then arches=(amd64); fi
|
|
for arch in "${arches[@]}"; do
|
|
args=(--platform "linux/$arch" --file ".release-context/$arch/Dockerfile"
|
|
--label "org.opencontainers.image.version=$RELEASE_VERSION"
|
|
--label "org.opencontainers.image.revision=$RELEASE_SHA"
|
|
--label "org.opencontainers.image.source=https://github.com/$GITHUB_REPOSITORY")
|
|
for registry in "${registries[@]}"; do
|
|
args+=(--tag "$registry:$RELEASE_VERSION-$arch")
|
|
if [[ ${SIMPLE_RELEASE:-false} == true ]]; then
|
|
args+=(--tag "$registry:$RELEASE_VERSION" --tag "$registry:latest")
|
|
fi
|
|
done
|
|
if [[ ${DRY_RUN:-false} == true ]]; then
|
|
args+=(--output "type=oci,dest=$RUNNER_TEMP/sub2api-$arch.oci.tar")
|
|
else
|
|
args+=(--push)
|
|
fi
|
|
docker buildx build "${args[@]}" ".release-context/$arch"
|
|
done
|
|
if [[ ${DRY_RUN:-false} != true && ${SIMPLE_RELEASE:-false} != true ]]; then
|
|
major=${RELEASE_VERSION%%.*}
|
|
minor=${RELEASE_VERSION#*.}; minor=${minor%%.*}
|
|
for registry in "${registries[@]}"; do
|
|
docker buildx imagetools create \
|
|
--tag "$registry:$RELEASE_VERSION" --tag "$registry:latest" \
|
|
--tag "$registry:$major.$minor" --tag "$registry:$major" \
|
|
"$registry:$RELEASE_VERSION-amd64" "$registry:$RELEASE_VERSION-arm64"
|
|
done
|
|
fi
|