Skip to content

Commit

Permalink
chore: try to fix Windows CI
Browse files Browse the repository at this point in the history
  • Loading branch information
w568w committed Mar 7, 2024
1 parent 4357d0d commit a814c6c
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci_android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- name: Build APK
run: |
./run_build.sh android
./run_build.sh android dummy
- if: github.event_name == 'workflow_dispatch' && github.event.inputs.tag_name != 'nightly'
name: Release
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ci_ios.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: Automated-CI-iOS-Beta

# fixme(2024-3-7): this CI action does not inject GIT_HASH into the build command, so it should not be used for releases.

on:
workflow_dispatch:

Expand Down
8 changes: 1 addition & 7 deletions .github/workflows/ci_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ jobs:
with:
channel: 'stable'

# - name: Install MSVC Build Tools
# uses: microsoft/setup-msbuild@v1.0.2
# with:
# vs-version: '16.0'
# architecture: 'x64'

- name: Prepare Flutter Dependencies
run: |
flutter pub get
Expand All @@ -34,7 +28,7 @@ jobs:
- name: Build Executable
run: |
flutter build windows --release
.\run_build.bat windows dummy
- name: Package Executable
run: 7z a -r -sse ..\..\..\..\build\app\app-release.zip *
Expand Down
30 changes: 24 additions & 6 deletions run_build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ echo Warning: Before building task, ensure that you have uncommented
echo the line "signingConfig signingConfigs.release" in android/app/build.gradle,
echo and choose your signing key in android/key.properties.
echo.
set /P version_code=Input your version name to continue:
if "%~2"=="" (
set /p version_code=Input your version name to continue:
) else (
set version_code=%~2
)
echo Start building...

for /f %%i in ('git rev-parse --short HEAD') do set GIT_HASH=%%i
Expand All @@ -16,15 +20,27 @@ echo Executing build runner...
echo.
start /WAIT cmd /C dart run build_runner build --delete-conflicting-outputs

if "%~1"=="android" (
goto build_android
) else if "%~1"=="windows" (
goto build_windows
) else if "%~1"=="aab" (
goto build_app_bundle
) else (
printf "A valid target is required: android, windows, aab\n"
exit /b 1
)

:build_android
echo Build for Android...
echo.
echo Clean old files...
del /Q build\app\DanXi-%version_code%-release.android.apk
start /WAIT cmd /C flutter build apk --release --dart-define=GIT_HASH=!GIT_HASH!
echo Move file...
move build\app\outputs\flutter-apk\app-release.apk build\app\DanXi-%version_code%-release.android.apk
echo Copy file...
copy build\app\outputs\flutter-apk\app-release.apk build\app\DanXi-%version_code%-release.android.apk
echo.
goto end_success

:build_windows
echo Build for Windows...
Expand All @@ -33,19 +49,21 @@ start /WAIT cmd /C flutter build windows --release --dart-define=GIT_HASH=!GIT_H
echo Clean old files...
del /Q build\app\DanXi-%version_code%-release.windows-x64.zip
cd build\windows\runner\Release\
echo Move file...
echo Copy file...
7z a -r -sse ..\..\..\..\build\app\DanXi-%version_code%-release.windows-x64.zip *
cd ..\..\..\..\
echo.
goto end_success

:build_app_bundle
echo Build for App Bundle (Google Play Distribution)...
echo.
echo Clean old files...
del /Q build\app\DanXi-%version_code%-release.android.aab
start /WAIT cmd /C flutter build appbundle --release --dart-define=GIT_HASH=!GIT_HASH!
echo Move file...
move build\app\outputs\bundle\release\app-release.aab build\app\DanXi-%version_code%-release.android.aab
echo Copy file...
copy build\app\outputs\bundle\release\app-release.aab build\app\DanXi-%version_code%-release.android.aab
goto end_success

:end_success
echo Build success.
11 changes: 7 additions & 4 deletions run_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#

# if the 2nd argument is provided, it will be used as the version code
echo "Warning: Before building task, ensure that you have uncommented"
echo "the line \"signingConfig signingConfigs.release\" in android/app/build.gradle,"
echo "and choose your signing key in android/key.properties."
echo
read -p "Input your version name to continue: " version_code
if [ -z "$2" ]; then
read -p "Input your version name to continue: " version_code
else
version_code=$2
fi
echo "Start building..."

# get current hash
Expand Down Expand Up @@ -75,7 +80,5 @@ elif [ "$1" == "windows" ]; then
elif [ "$1" == "aab" ]; then
build_bundle
else
build_android
build_windows
build_bundle
printf "A valid target is required: android, windows, aab\n"
fi

0 comments on commit a814c6c

Please sign in to comment.