Skip to content

Commit

Permalink
fix: build mini
Browse files Browse the repository at this point in the history
  • Loading branch information
storytellerF committed Nov 6, 2024
1 parent 58f4108 commit 09ff315
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 10 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/alpha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
jobs:
build:
runs-on: ubuntu-latest
environment: koyeb
environment: mini
env:
# this will take the entire vars context configured in the repository > environments
# setting and convert it to JSON so we can automatically assign all the values to the
Expand All @@ -25,10 +25,13 @@ jobs:
distribution: 'temurin'
cache: gradle

- name: Build app
run: ./scripts/build_scripts/build-service-on-ci.sh koyeb
- name: Build mini service
run: ./scripts/build_scripts/build-service-on-ci.sh

- name: Build koyeb app
run: ./scripts/build_scripts/build-app-on-ci.sh https://respectable-jobie-anabn-3d54150c.koyeb.app/server/ koyeb

- uses: actions/upload-artifact@v4
with:
name: Signed app bundle
name: Signed A Bundle
path: build/outputs/apk/release/
1 change: 1 addition & 0 deletions deploy/docker-compose.prebuild.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
services:
server:
image: a-server:latest
build: !reset null
ports:
- ${SERVER_PORT}:${SERVER_PORT}
profiles:
Expand Down
3 changes: 2 additions & 1 deletion deploy/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ services:
IS_PROD: ${IS_PROD}
FLAVOR: ${FLAVOR}
IS_HOST: false
BUILD_ON_HOST: ${BUILD_ON_HOST}
BUILD_ON_LOCAL_HOST: ${BUILD_ON_LOCAL_HOST}
BUILD_ON_REMOTE_HOST: ${BUILD_ON_REMOTE_HOST}
BUILD_ON_DOCKER: ${BUILD_ON_DOCKER}
ports:
- ${SERVER_PORT}:${SERVER_PORT}
Expand Down
33 changes: 33 additions & 0 deletions scripts/build_scripts/build-app-on-ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash
URL=$1
FLAVOR=$2
FLAVOR="g-$FLAVOR"
IS_PROD="true"

# 自动根据系统环境设置换行符格式
use_windows_newline=false

# 检测操作系统
if [[ "$(uname -s)" =~ MINGW|CYGWIN|MSYS ]]; then
use_windows_newline=true
fi

# 设置换行符变量
newline="\n"

if [ "$use_windows_newline" = true ]; then
newline="\r\n"
fi

cat > "./$FLAVOR.env" <<EOF
SERVER_URL=${URL}${newline}
WS_SERVER_URL=${URL}${newline}
EOF

./scripts/tool_scripts/modify-flavor.sh "$FLAVOR" "$IS_PROD"

sh gradlew composeApp:build

mkdir -p "build/outputs/apk/release"

mv composeApp/build/outputs/apk/release/*.apk "build/outputs/apk/release/$FLAVOR.apk"
3 changes: 2 additions & 1 deletion scripts/build_scripts/build-server-docker-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ fi

IS_HOST=true \
IS_DOCKER=false \
BUILD_ON_HOST=true \
BUILD_ON_LOCAL_HOST=true \
BUILD_ON_REMOTE_HOST=false \
BUILD_ON_DOCKER=false \
./scripts/build_scripts/build-all-in-flavor.sh alpha true
docker build -t "$DOCKER_IMAGE_NAME" .
2 changes: 1 addition & 1 deletion scripts/service_scripts/build-service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ else
IS_DOCKER=false \
./scripts/build_scripts/build-all-in-flavor.sh "$FLAVOR" true
args=$(grep -v '^#' "$FLAVOR".env | grep -v '^$' | awk -F '=' '{print "--build-arg " $1 "=\"" $2 "\""}' ORS=' ')
./scripts/tool_scripts/exec-until-success.sh docker build "$args" -t "a-server:latest" .
./scripts/tool_scripts/exec-until-success.sh docker build --platform linux/amd64 "$args" -t "a-server:latest" .
./scripts/service_scripts/start-service-on-remote.sh "$PUSH_TO_REMOTE_URI" "$REMOTE_CERT_FILE" "$REMOTE_COMMAND $FLAVOR"
fi
2 changes: 1 addition & 1 deletion scripts/service_scripts/start-mini-compose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if [ "$USE_PREBUILD" = "true" ]; then
docker compose --env-file ../mini.env \
-f docker-compose.yml \
-f docker-compose.d.yml \
-f docker-compose.prebuild.yml
-f docker-compose.prebuild.yml \
up -d --build
else
docker compose --env-file ../mini.env \
Expand Down
2 changes: 1 addition & 1 deletion scripts/service_scripts/start-service-in-flavor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ if [ -z "$FLAVOR" ]; then
exit 1
fi

sh "scripts/service_scripts/build-service.sh $FLAVOR"
"./scripts/service_scripts/build-service.sh $FLAVOR"
1 change: 1 addition & 0 deletions scripts/service_scripts/start-service-on-remote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ fi

# 定义要保存的文件名
FILE="build/images/$FLAVOR.image.tar"
mkdir -p build/images
IMAGE_NAME="a-server:latest"

# 检查文件是否存在
Expand Down
2 changes: 1 addition & 1 deletion scripts/tool_scripts/push-env-to-github.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fi
if [ "$(gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/storytellerF/A/environments/koyeb \
"/repos/storytellerF/A/environments/$FLAVOR" \
-q ".name")" != "$ENVIRONMENT" ]; then

echo "Environment '$ENVIRONMENT' does not exist."
Expand Down

0 comments on commit 09ff315

Please sign in to comment.