Skip to content

Commit c3fc7e0

Browse files
committed
Add Windows installer configuration
1 parent 1cf5342 commit c3fc7e0

File tree

17 files changed

+938
-37
lines changed

17 files changed

+938
-37
lines changed

.ci/windows_installer.sh

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,32 @@
44
git config --global user.name "GitHub Actions Bot"
55
git config --global user.email "<>"
66

7+
REPO="$1"
78
part1='/<Version>/c\\t<Version>'
89
VERSION=${previous_tag//v}
910
part2='<\/Version>'
1011
part3='/<ReleaseDate>/c\\t<ReleaseDate>'
1112
part4='<\/ReleaseDate>'
12-
sed -i -e "${part1}${VERSION}${part2}" config/config.xml
13-
sed -i -e "${part1}${VERSION}${part2}" packages/${windows_app_name}/meta/package.xml
14-
sed -i -e "${part3}$(date +'%Y-%m-%d')${part4}" packages/${windows_app_name}/meta/package.xml
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
1516

16-
if (( $update_windows_installer == 1 )); then
17-
git add config/config.xml
18-
git add packages/${windows_app_name}/meta/package.xml
19-
git diff --quiet HEAD || git commit -m "Release ${app_name} v${VERSION}"
20-
git push
21-
fi
22-
23-
mv ../release/* packages/${windows_app_name}/data/${app_name}
24-
curl -L https://aka.ms/vs/16/release/VC_redist.x64.exe > packages/com.microsoft.vcredist/data/VC_redist.x64.exe
25-
./build.sh $(echo ../Tools/QtInstallerFramework/*/bin/binarycreator.exe) $(echo ../Tools/QtInstallerFramework/*/bin/repogen.exe)
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 ../..
2622

2723
if (( $update_windows_repository == 1 )); then
28-
git push -f --set-upstream origin repository
29-
fi
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/windows-build.yml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ jobs:
5656
static: 0
5757
version: ${{ matrix.mingw-version }}
5858
## Build
59-
#- name: Build
60-
# run: .ci/windows_build.sh
61-
# shell: bash
6259
- name: Windows build
6360
run: .ci/common/build.sh win_build win64
6461
shell: bash
@@ -70,9 +67,6 @@ jobs:
7067
cd win_release
7168
windeployqt ${{ env.executable_name }}.exe --qmldir ..\win_build\src || exit 5
7269
shell: cmd
73-
#- name: Finalize Windows build
74-
# run: .ci/windows_build.sh 1
75-
# shell: bash
7670
## Upload
7771
- name: Upload artifacts
7872
uses: actions/upload-artifact@v3
@@ -82,17 +76,23 @@ jobs:
8276
## Build installer
8377
#- if: env.create_windows_installer == 1
8478
# name: Disable repository update
85-
# run: |
86-
# echo "update_windows_installer=0" >> "${GITHUB_ENV}"
87-
# echo "update_windows_repository=0" >> "${GITHUB_ENV}"
79+
# run: echo "update_windows_repository=0" >> "${GITHUB_ENV}"
8880
# shell: bash
89-
#- if: env.create_windows_installer == 1
90-
# name: Build installer
91-
# run: .ci/windows-repo.sh
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: '*.exe'
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'

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+
}

release/win_installer/env.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
export FILE_NAME="ScratchCPP_Player_installer"

release/win_installer/packages/com.microsoft.vcredist/data/.keep

Whitespace-only changes.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
function Component(){}
2+
3+
Component.prototype.createOperations = function()
4+
{
5+
try {
6+
component.createOperations();
7+
if (installer.value("os") === "win") {
8+
component.addElevatedOperation("Execute", "{0,1638}", "@TargetDir@/VC_redist.x64.exe", "/norestart", "/quiet");
9+
}
10+
} catch (e) {
11+
print(e);
12+
}
13+
}

0 commit comments

Comments
 (0)