Skip to content

Commit

Permalink
🎉 0.2.11
Browse files Browse the repository at this point in the history
  • Loading branch information
Reverier-Xu committed May 29, 2024
1 parent 5c4631a commit 0403ce6
Show file tree
Hide file tree
Showing 14 changed files with 163 additions and 17 deletions.
36 changes: 27 additions & 9 deletions .github/workflows/cli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:

env:
APP_NAME: "WebSocketReflectorX"
APP_VERSION: "0.2.10"
APP_VERSION: "0.2.11"

#-------------------------------------------------------------------------------
# Workflow jobs
Expand All @@ -35,27 +35,45 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: x86_64-unknown-linux-musl

# Build application
- name: Build application
# Build Glibc application
- name: Build Glibc application
run: cargo build --release --features=binary

# Deploy application
- name: Compress Binaries
run: tar --transform='s!.*/!!' -cvf wsrx-cli-${{env.APP_VERSION}}-linux64.tar.gz target/release/wsrx
# Build musl application
- name: Build musl application
run: cargo build --release --features=binary --target x86_64-unknown-linux-musl

# Deploy Glibc application
- name: Compress Glibc Binaries
run: tar --transform='s!.*/!!' -cvf wsrx-cli-${{env.APP_VERSION}}-linux64-gnu.tar.gz target/release/wsrx

# Deploy musl application
- name: Compress musl Binaries
run: tar --transform='s!.*/!!' -cvf wsrx-cli-${{env.APP_VERSION}}-linux64-musl.tar.gz target/x86_64-unknown-linux-musl/release/wsrx

# Upload application ZIP
- name: Upload application ZIP
uses: actions/upload-artifact@v4
with:
name: wsrx-cli-${{env.APP_VERSION}}-linux64-gnu.tar.gz
path: wsrx-cli-${{env.APP_VERSION}}-linux64-gnu.tar.gz

# Upload application ZIP
- name: Upload application ZIP
uses: actions/upload-artifact@v4
with:
name: wsrx-cli-${{env.APP_VERSION}}-linux64.tar.gz
path: wsrx-cli-${{env.APP_VERSION}}-linux64.tar.gz
name: wsrx-cli-${{env.APP_VERSION}}-linux64-musl.tar.gz
path: wsrx-cli-${{env.APP_VERSION}}-linux64-musl.tar.gz

- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: wsrx-cli-${{env.APP_VERSION}}-linux64.tar.gz
files: |
wsrx-cli-${{env.APP_VERSION}}-linux64.tar.gz
wsrx-cli-${{env.APP_VERSION}}-linux64-musl.tar.gz
## macOS build ###############################################################
build-mac:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ on:

env:
APP_NAME: "WebSocketReflectorX"
APP_VERSION: "0.2.10"
APP_VERSION: "0.2.11"
QT_VERSION: "6.7.1"

#-------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:

env:
APP_NAME: "WebSocketReflectorX"
APP_VERSION: "0.2.10"
APP_VERSION: "0.2.11"
QT_VERSION: "6.7.1"

#-------------------------------------------------------------------------------
Expand Down
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
"files.associations": {
"*.qrc": "xml",
"qmldir": "plaintext",
"*.rx": "rune",
"qqmlcomponent": "cpp",
"qnetworkinterface": "cpp",
"chrono": "cpp",
"typeindex": "cpp",
"typeinfo": "cpp"
"typeinfo": "cpp",
"qnetworkreply": "cpp",
"qjsondocument": "cpp"
}
}
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.20)

set(VERSION_MAJOR 0)
set(VERSION_MINOR 2)
set(VERSION_PATCH 10)
set(VERSION_PATCH 11)

execute_process(
COMMAND git describe --always --dirty
Expand All @@ -11,6 +11,7 @@ execute_process(
OUTPUT_STRIP_TRAILING_WHITESPACE
)

set(VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
set(FULL_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.g${GIT_VERSION}")
message(STATUS "Current build version: ${FULL_VERSION}")

Expand Down
2 changes: 1 addition & 1 deletion deploy_linux.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

export APP_NAME="WebSocketReflectorX"
export APP_VERSION=0.2.10
export APP_VERSION=0.2.11
export GIT_VERSION=$(git rev-parse --short HEAD)

echo "> $APP_NAME packager (Linux x86_64) [v$APP_VERSION]"
Expand Down
2 changes: 1 addition & 1 deletion deploy_macos.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

export APP_NAME="WebSocketReflectorX"
export APP_VERSION=0.2.10
export APP_VERSION=0.2.11
export GIT_VERSION=$(git rev-parse --short HEAD)

echo "> $APP_NAME packager (macOS x86_64) [v$APP_VERSION]"
Expand Down
2 changes: 1 addition & 1 deletion deploy_windows.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

export APP_NAME="WebSocketReflectorX"
export APP_VERSION=0.2.10
export APP_VERSION=0.2.11
export GIT_VERSION=$(git rev-parse --short HEAD)

echo "> $APP_NAME packager (Windows x86_64) [v$APP_VERSION]"
Expand Down
2 changes: 2 additions & 0 deletions desktop/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.20)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

string(TIMESTAMP BUILD_TIME UTC)

set(IN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/variables.h.in")
set(GENERATED_FILE_PATH "${CMAKE_BINARY_DIR}/GeneratedFiles")
set(OUT_FILE "${GENERATED_FILE_PATH}/variables.h")
Expand Down
67 changes: 67 additions & 0 deletions desktop/ui.cc
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
#include "ui.h"
#include "variables.h"

#include <QApplication>
#include <QLocale>
#include <QMutex>
#include <QMutexLocker>
#include <QNetworkInterface>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QJsonDocument>
#include <QJsonObject>
#include <QQmlComponent>
#include <QQmlContext>
#include <QQmlEngine>
Expand Down Expand Up @@ -79,6 +84,13 @@ Ui::Ui(QObject* parent) : QObject(parent) {
m_uiComponent = new QQmlComponent(m_uiEngine, this);
m_uiComponent->loadUrl(QUrl(u"qrc:/ui/Main.qml"_qs));
m_window = qobject_cast<QQuickWindow*>(m_uiComponent->create());
m_networkManager = new QNetworkAccessManager(this);
setNewVersion("");
setHasNewVersion(true);
// setUpdateUrl("");
setUpdateUrl("https://github.com//XDSEC/WebSocketReflectorX/releases/latest");
setVersion(VERSION);
// checkUpdates();
}

Ui::~Ui() = default;
Expand Down Expand Up @@ -171,6 +183,61 @@ void Ui::setIsMac(bool isMac) {
emit isMacChanged(isMac);
}

QString Ui::version() const { return m_version; }

void Ui::setVersion(const QString& version) {
if (m_version == version) return;
m_version = version;
emit versionChanged(version);
}

bool Ui::hasNewVersion() const { return m_hasNewVersion; }

void Ui::setHasNewVersion(bool hasNewVersion) {
if (m_hasNewVersion == hasNewVersion) return;
m_hasNewVersion = hasNewVersion;
emit hasNewVersionChanged(hasNewVersion);
}

QString Ui::newVersion() const { return m_newVersion; }

void Ui::setNewVersion(const QString& newVersion) {
if (m_newVersion == newVersion) return;
m_newVersion = newVersion;
emit newVersionChanged(newVersion);
}

QString Ui::updateUrl() const { return m_updateUrl; }

void Ui::setUpdateUrl(const QString& updateUrl) {
if (m_updateUrl == updateUrl) return;
m_updateUrl = updateUrl;
emit updateUrlChanged(updateUrl);
}

void Ui::checkUpdates() {
auto url = QUrl("https://api.github.com/repos/XDSEC/WebSocketReflectorX/releases/latest");
auto request = QNetworkRequest(url);
request.setRawHeader("Accept", "application/vnd.github+json");
request.setRawHeader("X-GitHub-Api-Version", "2022-11-28");
auto reply = m_networkManager->get(request);
connect(reply, &QNetworkReply::finished, this, [=]() {
if (reply->error() != QNetworkReply::NoError) {
qWarning() << reply->errorString();
return;
}
auto data = reply->readAll();
auto json = QJsonDocument::fromJson(data).object();
auto version = json["tag_name"].toString();
auto current = QString(VERSION);
if (version > current) {
setHasNewVersion(true);
setNewVersion(version);
setUpdateUrl(json["html_url"].toString());
}
});
}

#ifdef Q_OS_UNIX
void Ui::sigtermHandler() {
snTerm->setEnabled(false);
Expand Down
37 changes: 37 additions & 0 deletions desktop/ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class QQmlEngine;
class QQmlComponent;
class QQuickWindow;
class QTranslator;
class QNetworkAccessManager;
#ifdef Q_OS_UNIX
class QSocketNotifier;
#endif
Expand All @@ -20,6 +21,10 @@ class Ui : public QObject {
Q_PROPERTY(bool isDark READ isDark WRITE setIsDark NOTIFY isDarkChanged)
Q_PROPERTY(QString language READ language WRITE setLanguage NOTIFY languageChanged)
Q_PROPERTY(bool isMac READ isMac WRITE setIsMac NOTIFY isMacChanged)
Q_PROPERTY(QString version READ version NOTIFY versionChanged)
Q_PROPERTY(bool hasNewVersion READ hasNewVersion NOTIFY hasNewVersionChanged)
Q_PROPERTY(QString newVersion READ newVersion NOTIFY newVersionChanged)
Q_PROPERTY(QString updateUrl READ updateUrl NOTIFY updateUrlChanged)
private:
static Ui* m_instance;
QQmlEngine* m_uiEngine;
Expand All @@ -33,6 +38,12 @@ class Ui : public QObject {
bool m_isDark = false;
QString m_language = "zh_CN";
bool m_isMac = false;
QNetworkAccessManager* m_networkManager;
QString m_version;
QString m_newVersion;
QString m_updateUrl;
bool m_hasNewVersion = false;

#ifdef Q_OS_UNIX
static int sighupFd[2];
static int sigtermFd[2];
Expand Down Expand Up @@ -71,6 +82,22 @@ class Ui : public QObject {

void setIsMac(bool isMac);

[[nodiscard]] QString version() const;

void setVersion(const QString& version);

[[nodiscard]] bool hasNewVersion() const;

void setHasNewVersion(bool hasNewVersion);

[[nodiscard]] QString newVersion() const;

void setNewVersion(const QString& newVersion);

[[nodiscard]] QString updateUrl() const;

void setUpdateUrl(const QString& updateUrl);

#ifdef Q_OS_UNIX

static void sigtermSigHandler(int);
Expand Down Expand Up @@ -101,6 +128,8 @@ class Ui : public QObject {

Q_INVOKABLE void onSecondaryInstanceStarted();

Q_INVOKABLE void checkUpdates();

signals:
void pageChanged(quint8 page);

Expand All @@ -111,4 +140,12 @@ class Ui : public QObject {
void languageChanged(const QString& language);

void isMacChanged(bool isMac);

void versionChanged(const QString& version);

void hasNewVersionChanged(bool hasNewVersion);

void newVersionChanged(const QString& newVersion);

void updateUrlChanged(const QString& updateUrl);
};
15 changes: 15 additions & 0 deletions desktop/ui/GetStartedView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@ Item {
sourceSize: Qt.size(160, 160)
}

Button {
id: updatesButton
anchors.bottom: parent.bottom
anchors.right: parent.right
anchors.margins: 6
visible: ui.hasNewVersion
display: AbstractButton.TextBesideIcon
text: qsTr("Updates Available")
icon.source: "qrc:/resources/assets/wand.svg"
icon.color: Style.palette.warning
onClicked: {
Qt.openUrlExternally(ui.updateUrl);
}
}

Label {
id: logoTitle

Expand Down
3 changes: 3 additions & 0 deletions desktop/variables.h.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#pragma once

#define FULL_VERSION "@FULL_VERSION@"
#define VERSION "@VERSION@"

#define BUILD_TIME "@BUILD_TIME@"
2 changes: 1 addition & 1 deletion wsrx/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "wsrx"
version = "0.2.10"
version = "0.2.11"
edition = "2021"
authors = ["Reverier-Xu <[email protected]>"]
description = "Controlled TCP-over-WebSocket forwarding tunnel."
Expand Down

0 comments on commit 0403ce6

Please sign in to comment.