Skip to content

Commit

Permalink
Finish Windows PTB releases (#3506)
Browse files Browse the repository at this point in the history
* Print folder structures with file listings

* Change . to a - in filename as expected

* Remove test echo

* Use latest dblsqd...

* Embed sha1 in Mudlet version for Windows

* Quote the arguments

* Use a consistent file path

* Remove repetition and add a debug echo

* Print contents of squirrel-packaging-prep as well

* Use correct .nupkg filename

* Wild guess at location of squirrel's releasify log

* Workaround squirrel's lack of 2.0.0 semver support

* Correct nupkg path for the semver workaround

* Remove content print echo

* Ensure the right commit ID is used in all places

* Use latest dblsqd

* Use currentRelease with a timestamp always

* Update to latest dblsqd

* Remove stray brace

* Update copyright (force rebuild)

* Echo deployurl to see if there's a space at the end

* Trim trailing newline

* Force rebuild

* Check release name when comparing dates as well

* Re-build to get a new version

* Try another way of ignoring current release

* Rebuild again to have a 2nd update

* Add more debug echoes to version comparison

* Perform case-insensitive comparison...

* Trim debug echoes

* Update tooltip text to be more explanatory

* Don't clobber 'mudlet' in the start menu

* Try another way of finding generated mudlet.exe

* Add a debug echo to show contents of folder

* Better 'no changelog available' message

* Lowercase version everywhere for consistency

* Another take at unique the Windows start menu

* Revert "Another take at unique the Windows start menu"

This reverts commit de2115b.

* Declare nuspec not only for PTB

This would have been a release-breaking bug.

* Try setting the product name

* Fix contains check in .pro

* Fingers crossed contains check is now doing its job

* Still not working - add a debug echo.

* And another one.

* Use a regex for contains

* Remove debug echoes

* Add a thanks message

* Add a few more emojis.

* Improve code quality

* Clarify %1 for translators

* Update to latest dblsqd - trim debug echoes

* Remove debug echoes

* Apply suggestions from code review

Co-Authored-By: Kebap <leckerkebap@gmx.li>

Co-authored-by: Kebap <leckerkebap@gmx.li>
  • Loading branch information
vadi2 and Kebap committed Mar 27, 2020
1 parent 0d6bdf2 commit d6e75ca
Show file tree
Hide file tree
Showing 11 changed files with 79 additions and 47 deletions.
2 changes: 1 addition & 1 deletion 3rdparty/dblsqd
58 changes: 39 additions & 19 deletions CI/appveyor.after_success.ps1
Expand Up @@ -8,10 +8,19 @@ windeployqt.exe --release mudlet.exe

Remove-Item * -include *.cpp, *.o

$public_test_build = if ($Env:MUDLET_VERSION_BUILD) { $Env:MUDLET_VERSION_BUILD.StartsWith('-public-test-build') } else { $FALSE }
$Script:PublicTestBuild = if ($Env:MUDLET_VERSION_BUILD) { $Env:MUDLET_VERSION_BUILD.StartsWith('-public-test-build') } else { $FALSE }

if ("$Env:APPVEYOR_REPO_TAG" -eq "false" -and -Not $public_test_build) {
if (Test-Path Env:APPVEYOR_PULL_REQUEST_NUMBER) {
$Script:Commit = git rev-parse --short $Env:APPVEYOR_PULL_REQUEST_HEAD_COMMIT
} else {
$Script:Commit = git rev-parse --short HEAD
}
# ensure sha part always starts with a character due to https://github.com/Squirrel/Squirrel.Windows/issues/1394
$Script:VersionAndSha = "$Env:VERSION-ptb$Script:Commit"

if ("$Env:APPVEYOR_REPO_TAG" -eq "false" -and -Not $Script:PublicTestBuild) {
Write-Output "=== Creating a snapshot build ==="
Rename-Item -Path "$Env:APPVEYOR_BUILD_FOLDER\src\release\mudlet.exe" -NewName "Mudlet.exe"
cmd /c 7z a Mudlet-%VERSION%%MUDLET_VERSION_BUILD%-windows.zip "%APPVEYOR_BUILD_FOLDER%\src\release\*"

Set-Variable -Name "uri" -Value "https://make.mudlet.org/snapshots/Mudlet-$env:VERSION$env:MUDLET_VERSION_BUILD-windows.zip";
Expand All @@ -21,10 +30,13 @@ if ("$Env:APPVEYOR_REPO_TAG" -eq "false" -and -Not $public_test_build) {

$DEPLOY_URL = Get-Content -Path $outFile -Raw
} else {
if ($public_test_build) {
if ($Script:PublicTestBuild) {
Write-Output "=== Creating a public test build ==="
# Squirrel takes Start menu name from the binary
Rename-Item -Path "$Env:APPVEYOR_BUILD_FOLDER\src\release\mudlet.exe" -NewName "Mudlet PTB.exe"
} else {
Write-Output "=== Creating a release build ==="
Rename-Item -Path "$Env:APPVEYOR_BUILD_FOLDER\src\release\mudlet.exe" -NewName "Mudlet.exe"
}

Write-Output "=== Cloning installer project ==="
Expand All @@ -40,52 +52,60 @@ if ("$Env:APPVEYOR_REPO_TAG" -eq "false" -and -Not $public_test_build) {
$SQUIRRELWINBIN = "$SQUIRRELWIN\lib\net45\"

if (-not $(Test-Path "$SQUIRRELWINBIN")) {
New-Item "$SQUIRRELWINBIN" -ItemType "directory"
New-Item "$SQUIRRELWINBIN" -ItemType "directory"
}

Write-Output "=== Moving things to where Squirel expects them ==="
# move everything into src\release\squirrel.windows\lib\net45\ as that's where Squirrel would like to see it
Move-Item $Env:APPVEYOR_BUILD_FOLDER\src\release\* $SQUIRRELWINBIN

$Script:NuSpec = "C:\projects\installers\windows\mudlet.nuspec"
Write-Output "=== Creating Nuget package ==="
if ($public_test_build) {
if ($Script:PublicTestBuild) {
# allow public test builds to be installed side by side with the release builds by renaming the app
# no dots in the <id>: https://github.com/Squirrel/Squirrel.Windows/blob/master/docs/using/naming.md
(Get-Content C:\projects\installers\windows\mudlet.nuspec).replace('<id>Mudlet</id>', '<id>Mudlet-PublicTestBuild</id>') | Set-Content C:\projects\installers\windows\mudlet.nuspec
(Get-Content C:\projects\installers\windows\mudlet.nuspec).replace('<title>Mudlet</title>', '<title>Mudlet (Public Test Build)</title>') | Set-Content C:\projects\installers\windows\mudlet.nuspec
(Get-Content "$Script:NuSpec").replace('<id>Mudlet</id>', '<id>Mudlet-PublicTestBuild</id>') | Set-Content "$Script:NuSpec"
(Get-Content "$Script:NuSpec").replace('<title>Mudlet</title>', '<title>Mudlet (Public Test Build)</title>') | Set-Content "$Script:NuSpec"
}
nuget pack C:\projects\installers\windows\mudlet.nuspec -Version $($Env:VERSION) -BasePath $SQUIRRELWIN -OutputDirectory $SQUIRRELWIN
nuget pack "$Script:NuSpec" -Version "$Script:VersionAndSha" -BasePath $SQUIRRELWIN -OutputDirectory $SQUIRRELWIN

Write-Output "=== Creating installers from Nuget package ==="
if ($public_test_build) {
$TestBuildString = ".PublicTestBuild"
if ($Script:PublicTestBuild) {
$TestBuildString = "-PublicTestBuild"
} else {
$TestBuildString = ""
}
.\squirrel.windows\tools\Squirrel --releasify C:\projects\squirrel-packaging-prep\Mudlet$($TestBuildString).$($Env:VERSION).nupkg --releaseDir C:\projects\squirreloutput --loadingGif C:\projects\installers\windows\splash-installing-2x.png --no-msi --setupIcon C:\projects\installers\windows\mudlet_main_48px.ico -n "/a /f C:\projects\installers\windows\code-signing-certificate.p12 /p $Env:signing_password /fd sha256 /tr http://timestamp.digicert.com /td sha256"

$nupkg_path = "C:\projects\squirrel-packaging-prep\Mudlet$TestBuildString.$Script:VersionAndSha.nupkg"
if (-not (Test-Path -Path $nupkg_path -PathType Leaf)) {
Write-Output "=== ERROR: nupkg doesn't exist as expected! Build aborted."
exit 1
}

# fails silently if the nupkg file is not found
.\squirrel.windows\tools\Squirrel --releasify $nupkg_path --releaseDir C:\projects\squirreloutput --loadingGif C:\projects\installers\windows\splash-installing-2x.png --no-msi --setupIcon C:\projects\installers\windows\mudlet_main_48px.ico -n "/a /f C:\projects\installers\windows\code-signing-certificate.p12 /p $Env:signing_password /fd sha256 /tr http://timestamp.digicert.com /td sha256"

Write-Output "=== Removing old directory content of release folder ==="
Remove-Item -Recurse -Force $Env:APPVEYOR_BUILD_FOLDER\src\release\*
Write-Output "=== Copying installer over for appveyor ==="
Move-Item C:\projects\squirreloutput\* $Env:APPVEYOR_BUILD_FOLDER\src\release

Write-Output "=== Printing contents of $Env:APPVEYOR_BUILD_FOLDER\src ==="
Tree $Env:APPVEYOR_BUILD_FOLDER\src
Write-Output "=== Done printing ==="

if (-not (Test-Path -Path "${Env:APPVEYOR_BUILD_FOLDER}\src\release\Setup.exe" -PathType Leaf)) {
Write-Output "=== ERROR: Setup.exe doesn't exist as expected! Build aborted."
Write-Output "=== ERROR: Squirrel failed to generate the installer! Build aborted. Squirrel log is:"
Get-Content -Path .\squirrel.windows\tools\SquirrelSetup.log
exit 1
}

if ($public_test_build) {
if ($Script:PublicTestBuild) {
Write-Output "=== Uploading public test build to make.mudlet.org ==="
Set-Variable -Name "uri" -Value "https://make.mudlet.org/snapshots/Mudlet-$env:VERSION$env:MUDLET_VERSION_BUILD-windows.exe";
Set-Variable -Name "inFile" -Value "${Env:APPVEYOR_BUILD_FOLDER}\src\release\Setup.exe";
Set-Variable -Name "outFile" -Value "upload-location.txt";
Invoke-RestMethod -Uri $uri -Method PUT -InFile $inFile -OutFile $outFile;

$DEPLOY_URL = Get-Content -Path $outFile -Raw
$DEPLOY_URL = $DEPLOY_URL.Trim()
echo "Deployed Mudlet to '$DEPLOY_URL'"
} else {
# get winscp .NET dll for uploads
# activate higher TLS version. Seems PS only uses 1.0 by default
Expand Down Expand Up @@ -121,9 +141,9 @@ if ("$Env:APPVEYOR_REPO_TAG" -eq "false" -and -Not $public_test_build) {
npm install -g dblsqd-cli
dblsqd login -e "https://api.dblsqd.com/v1/jsonrpc" -u "${Env:DBLSQD_USER}" -p "${Env:DBLSQD_PASS}"

if ($public_test_build) {
if ($Script:PublicTestBuild) {
Write-Output "=== Creating release in Dblsqd ==="
dblsqd release -a mudlet -c public-test-build -m "(test release message here)" "${Env:VERSION}${Env:MUDLET_VERSION_BUILD}".ToLower()
dblsqd release -a mudlet -c public-test-build -m "(changelogs for public test builds are not yet available)" "${Env:VERSION}${Env:MUDLET_VERSION_BUILD}".ToLower()

Write-Output "=== Registering release with Dblsqd ==="
dblsqd push -a mudlet -c public-test-build -r "${Env:VERSION}${Env:MUDLET_VERSION_BUILD}".ToLower() -s mudlet --type "standalone" --attach win:x86 "${DEPLOY_URL}"
Expand Down
3 changes: 3 additions & 0 deletions CI/appveyor.set-build-info.ps1
Expand Up @@ -16,6 +16,9 @@ if ($Env:APPVEYOR_REPO_TAG -eq "false") {
}
}

# not all systems we deal with allow uppercase ascii characters
$Env:MUDLET_VERSION_BUILD = "$Env:MUDLET_VERSION_BUILD".ToLower()

$VersionLine = Select-String -Pattern "Version =" $Env:APPVEYOR_BUILD_FOLDER/src/mudlet.pro
$VersionRegex = [regex]'= {1}(.+)$'
$Env:VERSION = $VersionRegex.Match($VersionLine).Groups[1].Value
Expand Down
3 changes: 3 additions & 0 deletions CI/travis.set-build-info.sh
Expand Up @@ -18,6 +18,9 @@ if [ -z "${TRAVIS_TAG}" ]; then
fi
fi

# not all systems we deal with allow uppercase ascii characters
MUDLET_VERSION_BUILD="${MUDLET_VERSION_BUILD,,}"

VERSION=""

if [ "${Q_OR_C_MAKE}" = "cmake" ]; then
Expand Down
13 changes: 13 additions & 0 deletions src/Host.cpp
Expand Up @@ -429,6 +429,10 @@ Host::Host(int port, const QString& hostname, const QString& login, const QStrin
}

loadSecuredPassword();

if (mudlet::scmIsPublicTestVersion) {
thankForUsingPTB();
}
}

Host::~Host()
Expand Down Expand Up @@ -757,6 +761,15 @@ void Host::updateConsolesFont()
}
}

// a little message to make the player feel special for helping us find bugs
void Host::thankForUsingPTB()
{
const QStringList happyIcons {"😀", "😃", "😄", "😁", "🙂", "🙃", "🤩", "🎉", "🚀", "🤟", "✌️", "👊"};
const auto randomIcon = happyIcons.at(QRandomGenerator::global()->bounded(happyIcons.size()));
postMessage(tr(R"([ OK ] - %1 Thanks a lot for using the Public Test Build!)", "%1 will be a random happy emoji").arg(randomIcon));
postMessage(tr(R"([ OK ] - %1 Help us make Mudlet better by reporting any problems.)", "%1 will be a random happy emoji").arg(randomIcon));
}

void Host::setMediaLocationGMCP(const QString& mediaUrl)
{
QUrl url = QUrl(mediaUrl);
Expand Down
1 change: 1 addition & 0 deletions src/Host.h
Expand Up @@ -565,6 +565,7 @@ private slots:
void loadSecuredPassword();
void removeAllNonPersistentStopWatches();
void updateConsolesFont();
void thankForUsingPTB();

QFont mDisplayFont;
QStringList mModulesToSync;
Expand Down
2 changes: 1 addition & 1 deletion src/mudlet.cpp
Expand Up @@ -412,7 +412,7 @@ mudlet::mudlet()
QStringList issueReportIcons {"face-uncertain.png", "face-surprise.png", "face-smile.png", "face-sad.png", "face-plain.png"};
auto randomIcon = QRandomGenerator::global()->bounded(issueReportIcons.size());
mpActionReportIssue->setIcon(QIcon(QStringLiteral(":/icons/%1").arg(issueReportIcons.at(randomIcon))));
mpActionReportIssue->setToolTip(tr("Report an issue about the Mudlet Public Test Build"));
mpActionReportIssue->setToolTip(tr("The public test build gets newer features to you quicker, and you help us find issues in them quicker. Spotted something odd? Let us know asap!"));
mpMainToolBar->addAction(mpActionReportIssue);
mpActionReportIssue->setObjectName(QStringLiteral("reportissue_action"));
mpMainToolBar->widgetForAction(mpActionReportIssue)->setObjectName(mpActionReportIssue->objectName());
Expand Down
7 changes: 7 additions & 0 deletions src/mudlet.pro
Expand Up @@ -1286,6 +1286,13 @@ win32 {
# specify some windows information about the binary
QMAKE_TARGET_COMPANY = "Mudlet makers"
QMAKE_TARGET_DESCRIPTION = "Mudlet the MUD client"

# Product name determines the Windows Start Menu shortcut name
contains(BUILD, "-public-test-build.+") {
QMAKE_TARGET_PRODUCT = "Mudlet PTB"
} else {
QMAKE_TARGET_PRODUCT = "Mudlet"
}
}

# Pull the docs and lua files into the project so they show up in the Qt Creator project files list
Expand Down
2 changes: 1 addition & 1 deletion src/ui/main_window.ui
Expand Up @@ -314,7 +314,7 @@
<string>Report an issue</string>
</property>
<property name="toolTip">
<string>Report an issue about the public test build</string>
<string>The public test build gets newer features to you quicker, and you help us find issues in them quicker. Spotted something odd? Let us know asap!</string>
</property>
</action>
</widget>
Expand Down
32 changes: 9 additions & 23 deletions src/updater.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (C) 2017 by Vadim Peretokin - vperetokin@gmail.com *
* Copyright (C) 2017-2020 by Vadim Peretokin - vperetokin@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
Expand Down Expand Up @@ -39,9 +39,9 @@
// mac: handled completely outside of Mudlet by Sparkle

Updater::Updater(QObject* parent, QSettings* settings) : QObject(parent)
, mUpdateInstalled(false)
, mpInstallOrRestart(new QPushButton(tr("Update")))
, updateDialog(nullptr)
, mpInstallOrRestart(new QPushButton(tr("Update")))
, mUpdateInstalled(false)
{
Q_ASSERT_X(settings, "updater", "QSettings object is required for the updater to work");
this->settings = settings;
Expand Down Expand Up @@ -108,9 +108,9 @@ void Updater::showChangelog() const
void Updater::finishSetup()
{
#if defined(Q_OS_LINUX)
qWarning() << "Successfully updated Mudlet to" << feed->getUpdates(getCurrentRelease()).constFirst().getVersion();
qWarning() << "Successfully updated Mudlet to" << feed->getUpdates(dblsqd::Release::getCurrentRelease()).constFirst().getVersion();
#elif defined(Q_OS_WIN32)
qWarning() << "Mudlet prepped to update to" << feed->getUpdates(getCurrentRelease()).first().getVersion() << "on restart";
qWarning() << "Mudlet prepped to update to" << feed->getUpdates(dblsqd::Release::getCurrentRelease()).first().getVersion() << "on restart";
#endif
recordUpdateTime();
recordUpdatedVersion();
Expand All @@ -130,15 +130,14 @@ void Updater::setupOnMacOS()
#if defined(Q_OS_WIN32)
void Updater::setupOnWindows()
{
QObject::connect(feed, &dblsqd::Feed::ready, [=]() { qWarning() << "Checked for updates:" << feed->getUpdates(getCurrentRelease()).size() << "update(s) available"; });

// Setup to automatically download the new release when an update is available
QObject::connect(feed, &dblsqd::Feed::ready, [=]() {
if (mudlet::scmIsDevelopmentVersion) {
return;
}

auto updates = feed->getUpdates(getCurrentRelease());
auto updates = feed->getUpdates(dblsqd::Release::getCurrentRelease());
qWarning() << "Checked for updates:" << updates.size() << "update(s) available";
if (updates.isEmpty()) {
return;
} else if (!updateAutomatically()) {
Expand Down Expand Up @@ -189,34 +188,21 @@ void Updater::prepareSetupOnWindows(const QString& downloadedSetupName)
}
#endif // Q_OS_WIN

dblsqd::Release Updater::getCurrentRelease()
{
// embed build time so public test releases, which cannot be compared via semver, can be compared via datetime
QString buildDateTime = QString(__DATE__) + QString(__TIME__);
QDateTime date = QDateTime::fromString(buildDateTime.simplified(), "MMM d yyyyhh:mm:ss");

return dblsqd::Release(QCoreApplication::applicationVersion(), date);
}

#if defined(Q_OS_LINUX)
void Updater::setupOnLinux()
{
QObject::connect(feed, &dblsqd::Feed::ready, this, [=]() {
qWarning() << "Checked for updates:" << feed->getUpdates(getCurrentRelease()).size() << "update(s) available";
});

// Setup to automatically download the new release when an update is
// available or wave a flag when it is to be done manually
// Setup to automatically download the new release when an update is available
QObject::connect(feed, &dblsqd::Feed::ready, this, [=]() {

// don't update development builds to prevent auto-update from overwriting your
// compiled binary while in development
if (mudlet::scmIsDevelopmentVersion) {
return;
}

auto updates = feed->getUpdates(getCurrentRelease());
auto updates = feed->getUpdates(dblsqd::Release::getCurrentRelease());
qWarning() << "Checked for updates:" << updates.size() << "update(s) available";
if (updates.isEmpty()) {
return;
} else if (!updateAutomatically()) {
Expand Down
3 changes: 1 addition & 2 deletions src/updater.h
@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (C) 2017 by Vadim Peretokin - vperetokin@gmail.com *
* Copyright (C) 2017-2020 by Vadim Peretokin - vperetokin@gmail.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
Expand Down Expand Up @@ -71,7 +71,6 @@ class Updater : public QObject
void recordUpdatedVersion() const;
QString getPreviousVersion() const;
void finishSetup();
dblsqd::Release getCurrentRelease();

#if defined(Q_OS_LINUX)
QString unzippedBinaryName;
Expand Down

0 comments on commit d6e75ca

Please sign in to comment.