Skip to content

Commit de5656e

Browse files
authored
Merge pull request #39 from scratchcpp/windows_workflow
Add Windows workflow
2 parents dd4da23 + b21299c commit de5656e

File tree

22 files changed

+1050
-9
lines changed

22 files changed

+1050
-9
lines changed

.ci/common/build.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ PLATFORM=$2
99
# 4: build failed
1010

1111
mkdir -p "$BUILD_DIR"
12-
cmake -B "$BUILD_DIR" -DCMAKE_BUILD_TYPE=Release -DSCRATCHCPP_PLAYER_BUILD_UNIT_TESTS=OFF || exit 3
12+
13+
if [[ "$PLATFORM" == "win64" ]] || [[ "$PLATFORM" == "win32" ]]; then
14+
cmake -B "$BUILD_DIR" -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DSCRATCHCPP_PLAYER_BUILD_UNIT_TESTS=OFF -DLIBSCRATCHCPP_AUDIO_SUPPORT=OFF || exit 3
15+
else
16+
cmake -B "$BUILD_DIR" -DCMAKE_BUILD_TYPE=Release -DSCRATCHCPP_PLAYER_BUILD_UNIT_TESTS=OFF || exit 3
17+
fi
1318

1419
if [[ "$PLATFORM" == "win32" ]]; then
1520
cmake --build "$BUILD_DIR" -j4 || exit 4

.ci/windows_installer.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
3+
### This script generates an installer and a Qt Installer Framework repository and uploads it
4+
git config --global user.name "GitHub Actions Bot"
5+
git config --global user.email "<>"
6+
7+
REPO="$1"
8+
part1='/<Version>/c\\t<Version>'
9+
VERSION=${previous_tag//v}
10+
part2='<\/Version>'
11+
part3='/<ReleaseDate>/c\\t<ReleaseDate>'
12+
part4='<\/ReleaseDate>'
13+
sed -i -e "${part1}${VERSION}${part2}" release/win_installer/config/config.xml
14+
sed -i -e "${part1}${VERSION}${part2}" release/win_installer/packages/${windows_app_name}/meta/package.xml
15+
sed -i -e "${part3}$(date +'%Y-%m-%d')${part4}" release/win_installer/packages/${windows_app_name}/meta/package.xml
16+
17+
mv win_release/* "release/win_installer/packages/${windows_app_name}/data/${app_name}"
18+
cd release/win_installer
19+
curl -L https://aka.ms/vs/16/release/VC_redist.x64.exe > packages/com.microsoft.vcredist/data/VC_redist.x64.exe || exit $?
20+
./build.sh $(echo ../../../Tools/QtInstallerFramework/*/bin/binarycreator.exe) || exit $?
21+
mv *installer.exe ../..
22+
23+
if (( $update_windows_repository == 1 )); then
24+
./update_repo.sh $(echo ../../../Tools/QtInstallerFramework/*/bin/repogen.exe) || exit $?
25+
old_dir="$(pwd)"
26+
cd "$REPO"
27+
git checkout -b tmp
28+
git branch -D master &&
29+
git switch --orphan master &&
30+
mv $old_dir/repository/* ./ &&
31+
rm -rf "$old_dir/repository" &&
32+
git add -A &&
33+
git commit -m "Generate repository" || exit $?
34+
git push -f --set-upstream origin master
35+
fi

.github/config.env

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@ create_windows_installer=1
2626
# App name used by the installer for Windows (must be same as in the installer configuration)
2727
windows_app_name=com.scratchcpp.player
2828

29-
# Whether to update version and release date in the Windows installer configuration (requires create_windows_installer=1)
30-
# Needs a PUSH_TOKEN secret with a personal access token
31-
update_windows_installer=1
29+
# Installer repository GitHub account name
30+
installer_repo_github=scratchcpp
31+
32+
# Installer repository name
33+
installer_repo_name=installer-repo
3234

3335
# Whether to upload new release to the Windows release repository (requires create_windows_installer=1)
3436
# Needs a PUSH_TOKEN secret with a personal access token

.github/workflows/linux-build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
branches: '*'
66
tags: '*'
77
pull_request:
8-
types: [opened, reopened, synchronize, edited]
8+
branches: [ "master" ]
99

1010
jobs:
1111
build:
@@ -14,7 +14,7 @@ jobs:
1414
matrix:
1515
qt-version: ['6.6']
1616
qt-target: ['desktop']
17-
qt-modules: ['qtshadertools']
17+
qt-modules: ['']
1818
arch: ['amd64']
1919
ubuntu-version: ['20.04']
2020
steps:

.github/workflows/windows-build.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Windows build
2+
3+
on:
4+
push:
5+
branches: '*'
6+
tags: '*'
7+
pull_request:
8+
branches: [ "master" ]
9+
10+
jobs:
11+
build:
12+
runs-on: windows-latest
13+
strategy:
14+
matrix:
15+
qt-version: ['6.6']
16+
qt-target: ['desktop']
17+
qt-modules: ['']
18+
mingw-version: ['11.2.0']
19+
steps:
20+
- uses: actions/checkout@v3
21+
with:
22+
fetch-depth: 0
23+
submodules: 'recursive'
24+
- name: Setup environment
25+
run: |
26+
sed -i -e '/^#/d' .github/config.env
27+
sed -i -e '/^$/d' .github/config.env
28+
cat .github/config.env >> "${GITHUB_ENV}"
29+
shell: bash
30+
- name: Get version
31+
run: |
32+
version=$(LC_ALL=en_US.utf8 grep -oP 'project\([^)]*\s+VERSION\s+\K[0-9]+\.[0-9]+\.[0-9]+' CMakeLists.txt)
33+
echo "Project version: $version"
34+
echo previous_tag=$version >> "${GITHUB_ENV}"
35+
shell: bash
36+
## Install Qt
37+
- name: Install Qt
38+
uses: jurplel/install-qt-action@v3
39+
with:
40+
version: ${{ matrix.qt-version }}
41+
host: 'windows'
42+
arch: 'win64_mingw'
43+
target: ${{ matrix.qt-target }}
44+
modules: ${{ matrix.qt-modules }}
45+
- name: Install Qt IFW
46+
run: |
47+
curl -o aqt.exe -L https://github.com/miurahr/aqtinstall/releases/download/v2.2.1/aqt.exe
48+
./aqt.exe install-tool windows desktop tools_ifw
49+
mv Tools ..
50+
echo ${pwd}/../Tools/QtInstallerFramework/*/bin >> "${GITHUB_PATH}"
51+
shell: bash
52+
- name: Install MinGW
53+
uses: egor-tensin/setup-mingw@v2
54+
with:
55+
platform: x64
56+
static: 0
57+
version: ${{ matrix.mingw-version }}
58+
## Build
59+
- name: Windows build
60+
run: .ci/common/build.sh win_build win64
61+
shell: bash
62+
- name: Deploy
63+
run: |
64+
mkdir win_release
65+
for /r win_build %%f in (${{ env.executable_name }}.exe) do @move "%%f" win_release
66+
for /r win_build %%f in (*.dll) do @move "%%f" win_release
67+
cd win_release
68+
windeployqt ${{ env.executable_name }}.exe --qmldir ..\win_build\src || exit 5
69+
shell: cmd
70+
## Upload
71+
- name: Upload artifacts
72+
uses: actions/upload-artifact@v3
73+
with:
74+
name: build-Qt-${{ matrix.qt-version }}
75+
path: win_release/
76+
## Build installer
77+
- if: env.create_windows_installer == 1
78+
name: Disable repository update
79+
run: echo "update_windows_repository=0" >> "${GITHUB_ENV}"
80+
shell: bash
81+
- if: env.create_windows_installer == 1
82+
name: Get installer repository
83+
uses: actions/checkout@v4
84+
with:
85+
repository: ${{ env.installer_repo_github }}/${{ env.installer_repo_name }}
86+
fetch-depth: 0
87+
path: win_repo
88+
token: ${{ secrets.PUSH_TOKEN }}
89+
- if: env.create_windows_installer == 1
90+
name: Build installer
91+
run: .ci/windows_installer.sh "${GITHUB_WORKSPACE}/win_repo"
92+
shell: bash
93+
# Upload installer
94+
- name: Upload installer
95+
uses: actions/upload-artifact@v3
96+
with:
97+
name: installer-Qt-${{ matrix.qt-version }}
98+
path: '*installer.exe'

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
77

88
option(SCRATCHCPP_PLAYER_BUILD_UNIT_TESTS "Build unit tests" ON)
99

10-
find_package(Qt6 6.6 COMPONENTS Quick QuickControls2 Widgets REQUIRED)
11-
set(QT_LIBS Qt6::Quick Qt6::QuickControls2 Qt6::Widgets)
10+
find_package(Qt6 6.6 COMPONENTS Quick QuickControls2 Widgets OpenGLWidgets REQUIRED)
11+
set(QT_LIBS Qt6::Quick Qt6::QuickControls2 Qt6::Widgets Qt6::OpenGLWidgets)
1212

1313
if (SCRATCHCPP_PLAYER_BUILD_UNIT_TESTS)
1414
set(GTEST_DIR thirdparty/googletest)

release/win_installer/build.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
4+
BINARYCREATOR=$1
5+
source "$SCRIPT_DIR/env.sh"
6+
7+
if [[ "$BINARYCREATOR" == "" ]]; then
8+
if [[ `command -v binarycreator` != "" ]]; then
9+
BINARYCREATOR=binarycreator
10+
else
11+
echo "No binarycreator executable path specified!"
12+
exit 1
13+
fi
14+
fi
15+
16+
echo "D: binarycreator: $BINARYCREATOR"
17+
echo "Creating installer binary..."
18+
$BINARYCREATOR --offline-only -c config/config.xml -p packages "$FILE_NAME" || exit $?
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Installer>
3+
<Name>ScratchCPP Player</Name>
4+
<Version></Version>
5+
<Title>ScratchCPP Player</Title>
6+
<Publisher>adazem009</Publisher>
7+
<StartMenuDir>ScratchCPP</StartMenuDir>
8+
<TargetDir>@ApplicationsDir@/ScratchCPP</TargetDir>
9+
<!-- <InstallerWindowIcon>windowicon.png</InstallerWindowIcon>
10+
<InstallerApplicationIcon>appicon</InstallerApplicationIcon> -->
11+
<WizardStyle>Modern</WizardStyle>
12+
<StyleSheet>style.qss</StyleSheet>
13+
<ControlScript>controller.qs</ControlScript>
14+
<RemoteRepositories>
15+
<Repository>
16+
<Url>http://scratchcpp.github.io/installer-repo</Url>
17+
<Enabled>1</Enabled>
18+
<DisplayName>ScratchCPP official repository</DisplayName>
19+
</Repository>
20+
</RemoteRepositories>
21+
</Installer>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
function Controller() {
2+
installer.setMessageBoxAutomaticAnswer("installationErrorWithRetry", QMessageBox.Ignore);
3+
installer.setMessageBoxAutomaticAnswer("installationError", QMessageBox.Ignore);
4+
}
5+
6+
Controller.prototype.IntroductionPageCallback = function() {
7+
if(installer.isUpdater())
8+
gui.clickButton(buttons.NextButton);
9+
}
10+
11+
Controller.prototype.ComponentSelectionPageCallback = function() {
12+
if(installer.isUpdater())
13+
gui.clickButton(buttons.NextButton);
14+
}
15+
16+
Controller.prototype.ReadyForInstallationPageCallback = function() {
17+
if(installer.isUpdater()) {
18+
gui.clickButton(buttons.NextButton);
19+
installer.setDefaultPageVisible(QInstaller.Introduction, false);
20+
installer.setDefaultPageVisible(QInstaller.TargetDirectory, false);
21+
installer.setDefaultPageVisible(QInstaller.ReadyForInstallation, false);
22+
installer.setDefaultPageVisible(QInstaller.ComponentSelection, false);
23+
installer.setDefaultPageVisible(QInstaller.StartMenuSelection, false);
24+
installer.setDefaultPageVisible(QInstaller.LicenseCheck, false);
25+
}
26+
}
27+
28+
Controller.prototype.FinishedPageCallback = function() {
29+
if(installer.isUpdater()) {
30+
var execName = installer.value("updateSource");
31+
if(execName != "") {
32+
installer.executeDetached(execName);
33+
gui.clickButton(buttons.FinishButton);
34+
gui.clickButton(buttons.QuitButton);
35+
}
36+
}
37+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
QWidget
2+
{
3+
color: white;
4+
background-color: rgb(61, 56, 56);
5+
}
6+
7+
QPushButton
8+
{
9+
background-color: rgb(50, 130, 172);
10+
border-style: solid;
11+
border-width: 1px;
12+
border-color: rgb(61, 56, 56);
13+
border-radius: 5px;
14+
min-height: 25px;
15+
max-height: 25px;
16+
min-width: 60px;
17+
padding-left: 15px;
18+
padding-right: 15px;
19+
}
20+
21+
QPushButton:disabled
22+
{
23+
background-color: rgb(30, 77, 102);
24+
}
25+
26+
QPushButton:pressed, QPushButton:checked
27+
{
28+
background: qlineargradient(x1:0, y1:1, x2:0, y2:0, stop:0 rgba(50, 130, 172, 60%), stop:1 rgba(30, 77, 102, 60%));
29+
}
30+
31+
QProgressBar
32+
{
33+
text-align: center;
34+
}
35+
36+
QProgressBar::chunk
37+
{
38+
background-color: qlineargradient(x1:0, y1:0, x2:1, y2:0, stop:0 rgba(50, 130, 172, 60%), stop:1 rgba(30, 77, 102, 60%));
39+
}

0 commit comments

Comments
 (0)