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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 -DLIBSCRATCHCPP_AUDIO_SUPPORT=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
35 changes: 35 additions & 0 deletions .ci/windows_installer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/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 "<>"

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

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

if (( $update_windows_repository == 1 )); then
./update_repo.sh $(echo ../../../Tools/QtInstallerFramework/*/bin/repogen.exe) || exit $?
old_dir="$(pwd)"
cd "$REPO"
git checkout -b tmp
git branch -D master &&
git switch --orphan master &&
mv $old_dir/repository/* ./ &&
rm -rf "$old_dir/repository" &&
git add -A &&
git commit -m "Generate repository" || exit $?
git push -f --set-upstream origin master
fi
8 changes: 5 additions & 3 deletions .github/config.env
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ create_windows_installer=1
# App name used by the installer for Windows (must be same as in the installer configuration)
windows_app_name=com.scratchcpp.player

# Whether to update version and release date in the Windows installer configuration (requires create_windows_installer=1)
# Needs a PUSH_TOKEN secret with a personal access token
update_windows_installer=1
# Installer repository GitHub account name
installer_repo_github=scratchcpp

# Installer repository name
installer_repo_name=installer-repo

# Whether to upload new release to the Windows release repository (requires create_windows_installer=1)
# Needs a PUSH_TOKEN secret with a personal access token
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/linux-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches: '*'
tags: '*'
pull_request:
types: [opened, reopened, synchronize, edited]
branches: [ "master" ]

jobs:
build:
Expand All @@ -14,7 +14,7 @@ jobs:
matrix:
qt-version: ['6.6']
qt-target: ['desktop']
qt-modules: ['qtshadertools']
qt-modules: ['']
arch: ['amd64']
ubuntu-version: ['20.04']
steps:
Expand Down
98 changes: 98 additions & 0 deletions .github/workflows/windows-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
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: Windows build
run: .ci/common/build.sh win_build win64
shell: bash
- name: Deploy
run: |
mkdir win_release
for /r win_build %%f in (${{ env.executable_name }}.exe) do @move "%%f" win_release
for /r win_build %%f in (*.dll) do @move "%%f" win_release
cd win_release
windeployqt ${{ env.executable_name }}.exe --qmldir ..\win_build\src || exit 5
shell: cmd
## 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_repository=0" >> "${GITHUB_ENV}"
shell: bash
- if: env.create_windows_installer == 1
name: Get installer repository
uses: actions/checkout@v4
with:
repository: ${{ env.installer_repo_github }}/${{ env.installer_repo_name }}
fetch-depth: 0
path: win_repo
token: ${{ secrets.PUSH_TOKEN }}
- if: env.create_windows_installer == 1
name: Build installer
run: .ci/windows_installer.sh "${GITHUB_WORKSPACE}/win_repo"
shell: bash
# Upload installer
- name: Upload installer
uses: actions/upload-artifact@v3
with:
name: installer-Qt-${{ matrix.qt-version }}
path: '*installer.exe'
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)

option(SCRATCHCPP_PLAYER_BUILD_UNIT_TESTS "Build unit tests" ON)

find_package(Qt6 6.6 COMPONENTS Quick QuickControls2 Widgets REQUIRED)
set(QT_LIBS Qt6::Quick Qt6::QuickControls2 Qt6::Widgets)
find_package(Qt6 6.6 COMPONENTS Quick QuickControls2 Widgets OpenGLWidgets REQUIRED)
set(QT_LIBS Qt6::Quick Qt6::QuickControls2 Qt6::Widgets Qt6::OpenGLWidgets)

if (SCRATCHCPP_PLAYER_BUILD_UNIT_TESTS)
set(GTEST_DIR thirdparty/googletest)
Expand Down
18 changes: 18 additions & 0 deletions release/win_installer/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
BINARYCREATOR=$1
source "$SCRIPT_DIR/env.sh"

if [[ "$BINARYCREATOR" == "" ]]; then
if [[ `command -v binarycreator` != "" ]]; then
BINARYCREATOR=binarycreator
else
echo "No binarycreator executable path specified!"
exit 1
fi
fi

echo "D: binarycreator: $BINARYCREATOR"
echo "Creating installer binary..."
$BINARYCREATOR --offline-only -c config/config.xml -p packages "$FILE_NAME" || exit $?
21 changes: 21 additions & 0 deletions release/win_installer/config/config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<Installer>
<Name>ScratchCPP Player</Name>
<Version></Version>
<Title>ScratchCPP Player</Title>
<Publisher>adazem009</Publisher>
<StartMenuDir>ScratchCPP</StartMenuDir>
<TargetDir>@ApplicationsDir@/ScratchCPP</TargetDir>
<!-- <InstallerWindowIcon>windowicon.png</InstallerWindowIcon>
<InstallerApplicationIcon>appicon</InstallerApplicationIcon> -->
<WizardStyle>Modern</WizardStyle>
<StyleSheet>style.qss</StyleSheet>
<ControlScript>controller.qs</ControlScript>
<RemoteRepositories>
<Repository>
<Url>http://scratchcpp.github.io/installer-repo</Url>
<Enabled>1</Enabled>
<DisplayName>ScratchCPP official repository</DisplayName>
</Repository>
</RemoteRepositories>
</Installer>
37 changes: 37 additions & 0 deletions release/win_installer/config/controller.qs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
function Controller() {
installer.setMessageBoxAutomaticAnswer("installationErrorWithRetry", QMessageBox.Ignore);
installer.setMessageBoxAutomaticAnswer("installationError", QMessageBox.Ignore);
}

Controller.prototype.IntroductionPageCallback = function() {
if(installer.isUpdater())
gui.clickButton(buttons.NextButton);
}

Controller.prototype.ComponentSelectionPageCallback = function() {
if(installer.isUpdater())
gui.clickButton(buttons.NextButton);
}

Controller.prototype.ReadyForInstallationPageCallback = function() {
if(installer.isUpdater()) {
gui.clickButton(buttons.NextButton);
installer.setDefaultPageVisible(QInstaller.Introduction, false);
installer.setDefaultPageVisible(QInstaller.TargetDirectory, false);
installer.setDefaultPageVisible(QInstaller.ReadyForInstallation, false);
installer.setDefaultPageVisible(QInstaller.ComponentSelection, false);
installer.setDefaultPageVisible(QInstaller.StartMenuSelection, false);
installer.setDefaultPageVisible(QInstaller.LicenseCheck, false);
}
}

Controller.prototype.FinishedPageCallback = function() {
if(installer.isUpdater()) {
var execName = installer.value("updateSource");
if(execName != "") {
installer.executeDetached(execName);
gui.clickButton(buttons.FinishButton);
gui.clickButton(buttons.QuitButton);
}
}
}
39 changes: 39 additions & 0 deletions release/win_installer/config/style.qss
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
QWidget
{
color: white;
background-color: rgb(61, 56, 56);
}

QPushButton
{
background-color: rgb(50, 130, 172);
border-style: solid;
border-width: 1px;
border-color: rgb(61, 56, 56);
border-radius: 5px;
min-height: 25px;
max-height: 25px;
min-width: 60px;
padding-left: 15px;
padding-right: 15px;
}

QPushButton:disabled
{
background-color: rgb(30, 77, 102);
}

QPushButton:pressed, QPushButton:checked
{
background: qlineargradient(x1:0, y1:1, x2:0, y2:0, stop:0 rgba(50, 130, 172, 60%), stop:1 rgba(30, 77, 102, 60%));
}

QProgressBar
{
text-align: center;
}

QProgressBar::chunk
{
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%));
}
3 changes: 3 additions & 0 deletions release/win_installer/env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

export FILE_NAME="ScratchCPP_Player_installer"
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
function Component(){}

Component.prototype.createOperations = function()
{
try {
component.createOperations();
if (installer.value("os") === "win") {
component.addElevatedOperation("Execute", "{0,1638}", "@TargetDir@/VC_redist.x64.exe", "/norestart", "/quiet");
}
} catch (e) {
print(e);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<Package>
<DisplayName>Microsoft Visual C++ Redistributable</DisplayName>
<Description>Installs the Visual C++ redistributables</Description>
<Version>14.29.30139</Version>
<ReleaseDate>2019-04-02</ReleaseDate>
<Virtual>true</Virtual>
<Script>installscript.qs</Script>
<UserInterfaces>
<UserInterface>page.ui</UserInterface>
</UserInterfaces>
</Package>
28 changes: 28 additions & 0 deletions release/win_installer/packages/com.microsoft.vcredist/meta/page.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Page</class>
<widget class="QWidget" name="Page">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Dynamic page example</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="m_pageLabel">
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
function Component() { }

Component.prototype.createOperations = function()
{
component.createOperations();
programName = "ScratchCPP Player";
execName = "scratchcpp-player";
programDescription = "C++-based Scratch project player";
if (systemInfo.productType === "windows") {
component.addOperation("CreateShortcut", "@TargetDir@/" + programName + "/" + execName + ".exe", "@StartMenuDir@/" + programName + ".lnk",
"workingDirectory=@TargetDir@/" + programName, "iconPath=@TargetDir@/" + programName + "/" + execName + ".exe",
"iconId=0", "description=" + programDescription);
component.addOperation("CreateShortcut", "@TargetDir@/" + programName + "/" + execName + ".exe", "@DesktopDir@/" + programName + ".lnk",
"workingDirectory=@TargetDir@/" + programName, "iconPath=@TargetDir@/" + programName + "/" + execName + ".exe",
"iconId=0", "description=" + programDescription);
}
}
Loading
Loading