Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Windows workflow #39

Merged
merged 11 commits into from
Mar 4, 2024
Prev Previous commit
Next Next commit
Add initial Windows workflow
  • Loading branch information
adazem009 committed Mar 2, 2024
commit f2379db846bbe331d519109260cfd022bb51777b
7 changes: 6 additions & 1 deletion .ci/common/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ PLATFORM=$2
# 4: build failed

mkdir -p "$BUILD_DIR"
cmake -B "$BUILD_DIR" -DCMAKE_BUILD_TYPE=Release -DSCRATCHCPP_PLAYER_BUILD_UNIT_TESTS=OFF || exit 3

if [[ "$PLATFORM" == "win64" ]] || [[ "$PLATFORM" == "win32" ]]; then
cmake -B "$BUILD_DIR" -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DSCRATCHCPP_PLAYER_BUILD_UNIT_TESTS=OFF || exit 3
else
cmake -B "$BUILD_DIR" -DCMAKE_BUILD_TYPE=Release -DSCRATCHCPP_PLAYER_BUILD_UNIT_TESTS=OFF || exit 3
fi

if [[ "$PLATFORM" == "win32" ]]; then
cmake --build "$BUILD_DIR" -j4 || exit 4
Expand Down
29 changes: 29 additions & 0 deletions .ci/windows_installer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

### This script generates an installer and a Qt Installer Framework repository and uploads it
git config --global user.name "GitHub Actions Bot"
git config --global user.email "<>"

part1='/<Version>/c\\t<Version>'
VERSION=${previous_tag//v}
part2='<\/Version>'
part3='/<ReleaseDate>/c\\t<ReleaseDate>'
part4='<\/ReleaseDate>'
sed -i -e "${part1}${VERSION}${part2}" config/config.xml
sed -i -e "${part1}${VERSION}${part2}" packages/${windows_app_name}/meta/package.xml
sed -i -e "${part3}$(date +'%Y-%m-%d')${part4}" packages/${windows_app_name}/meta/package.xml

if (( $update_windows_installer == 1 )); then
git add config/config.xml
git add packages/${windows_app_name}/meta/package.xml
git diff --quiet HEAD || git commit -m "Release ${app_name} v${VERSION}"
git push
fi

mv ../release/* packages/${windows_app_name}/data/${app_name}
curl -L https://aka.ms/vs/16/release/VC_redist.x64.exe > packages/com.microsoft.vcredist/data/VC_redist.x64.exe
./build.sh $(echo ../Tools/QtInstallerFramework/*/bin/binarycreator.exe) $(echo ../Tools/QtInstallerFramework/*/bin/repogen.exe)

if (( $update_windows_repository == 1 )); then
git push -f --set-upstream origin repository
fi
99 changes: 99 additions & 0 deletions .github/workflows/windows-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Windows build

on:
push:
branches: '*'
tags: '*'
pull_request:
branches: [ "master" ]

jobs:
build:
runs-on: windows-latest
strategy:
matrix:
qt-version: ['6.6']
qt-target: ['desktop']
qt-modules: ['']
mingw-version: ['11.2.0']
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: 'recursive'
- name: Setup environment
run: |
sed -i -e '/^#/d' .github/config.env
sed -i -e '/^$/d' .github/config.env
cat .github/config.env >> "${GITHUB_ENV}"
shell: bash
- name: Get version
run: |
version=$(LC_ALL=en_US.utf8 grep -oP 'project\([^)]*\s+VERSION\s+\K[0-9]+\.[0-9]+\.[0-9]+' CMakeLists.txt)
echo "Project version: $version"
echo previous_tag=$version >> "${GITHUB_ENV}"
shell: bash
## Install Qt
- name: Install Qt
uses: jurplel/install-qt-action@v3
with:
version: ${{ matrix.qt-version }}
host: 'windows'
arch: 'win64_mingw'
target: ${{ matrix.qt-target }}
modules: ${{ matrix.qt-modules }}
- name: Install Qt IFW
run: |
curl -o aqt.exe -L https://github.com/miurahr/aqtinstall/releases/download/v2.2.1/aqt.exe
./aqt.exe install-tool windows desktop tools_ifw
mv Tools ..
echo ${pwd}/../Tools/QtInstallerFramework/*/bin >> "${GITHUB_PATH}"
shell: bash
- name: Install MinGW
uses: egor-tensin/setup-mingw@v2
with:
platform: x64
static: 0
version: ${{ matrix.mingw-version }}
## Build
#- name: Build
# run: .ci/windows_build.sh
# shell: bash
- name: Windows build
run: .ci/common/build.sh win_build win64
shell: bash
- name: Copy files
run: |
mkdir win_release
robocopy win_build release *.exe /S /MOV
robocopy win_build release *.dll /S /MOV
cd win_release
windeployqt ${{ env.executable_name }}.exe --qmldir ..\win_build\src || exit 5
for %%v in (*.dll) do windeployqt "%%v" || exit 5
shell: cmd
#- name: Finalize Windows build
# run: .ci/windows_build.sh 1
# shell: bash
## Upload
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: build-Qt-${{ matrix.qt-version }}
path: win_release/
## Build installer
#- if: env.create_windows_installer == 1
# name: Disable repository update
# run: |
# echo "update_windows_installer=0" >> "${GITHUB_ENV}"
# echo "update_windows_repository=0" >> "${GITHUB_ENV}"
# shell: bash
#- if: env.create_windows_installer == 1
# name: Build installer
# run: .ci/windows-repo.sh
# shell: bash
## Upload installer
#- name: Upload installer
# uses: actions/upload-artifact@v3
# with:
# name: installer-Qt-${{ matrix.qt-version }}
# path: '*.exe'
Loading