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
Add Windows installer configuration
  • Loading branch information
adazem009 committed Mar 4, 2024
commit b21299ca97ad72533642c63a027b164638414394
36 changes: 21 additions & 15 deletions .ci/windows_installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,32 @@
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}" 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
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

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)
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
git push -f --set-upstream origin repository
fi
./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
44 changes: 22 additions & 22 deletions .github/workflows/windows-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ jobs:
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
Expand All @@ -70,29 +67,32 @@ jobs:
cd win_release
windeployqt ${{ env.executable_name }}.exe --qmldir ..\win_build\src || 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'
- 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'
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