mirror of
https://github.com/eiblog/eiblog.git
synced 2026-02-10 08:32:26 +08:00
chore: renew github flow
This commit is contained in:
27
scripts/dist_tar.sh
Executable file
27
scripts/dist_tar.sh
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
set -e
|
||||
|
||||
_tag="$1"
|
||||
_arch=$(go env GOARCH)
|
||||
|
||||
# prepare dir ./bin
|
||||
mkdir -p ./bin
|
||||
|
||||
for file in pkg/core/*; do
|
||||
app="$(basename $file)";
|
||||
# tar platform
|
||||
for os in linux darwin windows; do
|
||||
_target="$app-$_tag.$os-$_arch.tar.gz"
|
||||
CGO_ENABLED=0 GOOS=$os GOARCH=$_arch \
|
||||
go build -o bin/backend "./cmd/$app"
|
||||
if [ "$app" == "blog" ]; then
|
||||
tar czf $_target conf website assets bin/backend
|
||||
else
|
||||
tar czf $_target conf bin/backend
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
# clean dir ./bin
|
||||
rm -rf ./bin
|
||||
@@ -4,6 +4,7 @@ set -e
|
||||
|
||||
_registry="$1"
|
||||
_tag="$2"
|
||||
_platform="linux/amd64,linux/arm64,linux/386"
|
||||
|
||||
if [ -z "$_registry" ] || [ -z "$_tag" ]; then
|
||||
echo "Please specify image repository and tag."
|
||||
@@ -12,12 +13,18 @@ fi
|
||||
|
||||
# prepare dir ./bin
|
||||
mkdir -p ./bin
|
||||
# create builder
|
||||
docker buildx create --use --name builder
|
||||
|
||||
# build demo app
|
||||
for file in pkg/core/*; do
|
||||
app="$(basename $file)";
|
||||
GOOS=linux GOARCH=amd64 go build -o bin/backend "./cmd/$app"
|
||||
docker build -f "build/package/$app.Dockerfile" -t "$_registry/$app:$_tag" .
|
||||
CGO_ENABLED=0 go build -o bin/backend "./cmd/$app"
|
||||
# docker image
|
||||
docker buildx build --platform "$_platform" \
|
||||
-t "$_registry/$app:latest" \
|
||||
-t "$_registry/$app:$_tag" \
|
||||
--push .
|
||||
done
|
||||
|
||||
# clean dir ./bin
|
||||
|
||||
Reference in New Issue
Block a user