Fix update notice for versioned releases
Some checks failed
Release App / release-app (push) Has been cancelled
Some checks failed
Release App / release-app (push) Has been cancelled
This commit is contained in:
@@ -1,180 +0,0 @@
|
||||
name: Build TDLib
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tdlib_ref:
|
||||
description: Optional TDLib tag or commit to build
|
||||
required: false
|
||||
type: string
|
||||
schedule:
|
||||
- cron: "0 3 * * 1"
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
jobs:
|
||||
build-tdlib:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
PACKAGE_NAME: tdlib
|
||||
TDLIB_REPO: https://github.com/tdlib/td.git
|
||||
steps:
|
||||
- name: Check out repository
|
||||
uses: https://github.com/actions/checkout@v4
|
||||
|
||||
- name: Install build dependencies
|
||||
run: |
|
||||
if command -v sudo >/dev/null 2>&1; then
|
||||
SUDO=sudo
|
||||
else
|
||||
SUDO=
|
||||
fi
|
||||
|
||||
$SUDO apt-get update
|
||||
$SUDO apt-get install -y \
|
||||
build-essential \
|
||||
ca-certificates \
|
||||
cmake \
|
||||
curl \
|
||||
git \
|
||||
gperf \
|
||||
libssl-dev \
|
||||
pkg-config \
|
||||
zlib1g-dev
|
||||
|
||||
- name: Resolve TDLib ref
|
||||
id: tdlib
|
||||
run: |
|
||||
set -euo pipefail
|
||||
ref="${{ inputs.tdlib_ref }}"
|
||||
if [ -z "$ref" ]; then
|
||||
ref="$(git ls-remote --tags --refs --sort='version:refname' "$TDLIB_REPO" 'v*' | tail -n1 | awk -F/ '{print $3}')"
|
||||
fi
|
||||
if [ -z "$ref" ]; then
|
||||
echo "Failed to resolve TDLib ref" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
version="$ref"
|
||||
version="${version#v}"
|
||||
version="${version//\//-}"
|
||||
archive="tdlib-${version}-linux-x86_64.tar.gz"
|
||||
|
||||
{
|
||||
echo "ref=$ref"
|
||||
echo "version=$version"
|
||||
echo "archive=$archive"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Build TDLib bundle
|
||||
run: |
|
||||
set -euo pipefail
|
||||
ref="${{ steps.tdlib.outputs.ref }}"
|
||||
version="${{ steps.tdlib.outputs.version }}"
|
||||
archive="${{ steps.tdlib.outputs.archive }}"
|
||||
|
||||
rm -rf tdlib-src tdlib-build dist
|
||||
git init tdlib-src
|
||||
cd tdlib-src
|
||||
git remote add origin "$TDLIB_REPO"
|
||||
git fetch --depth 1 origin \
|
||||
"refs/tags/${ref}:refs/tags/${ref}" \
|
||||
"refs/heads/${ref}:refs/remotes/origin/${ref}" || true
|
||||
|
||||
if git rev-parse --verify --quiet "refs/tags/${ref}" >/dev/null; then
|
||||
git checkout --detach "refs/tags/${ref}"
|
||||
elif git rev-parse --verify --quiet "refs/remotes/origin/${ref}" >/dev/null; then
|
||||
git checkout --detach "refs/remotes/origin/${ref}"
|
||||
else
|
||||
git fetch --depth 1 origin "$ref"
|
||||
git checkout --detach FETCH_HEAD
|
||||
fi
|
||||
cd ..
|
||||
|
||||
cmake -S tdlib-src -B tdlib-build \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_INSTALL_PREFIX="$PWD/dist/tdlib" \
|
||||
-DTD_ENABLE_INSTALL=ON \
|
||||
-DTD_ENABLE_JNI=OFF \
|
||||
-DTD_ENABLE_DOTNET=OFF \
|
||||
-DTD_ENABLE_TESTS=OFF \
|
||||
-DTD_ENABLE_BENCHMARKS=OFF
|
||||
cmake --build tdlib-build -j"$(nproc)"
|
||||
cmake --install tdlib-build
|
||||
|
||||
tar -C dist -czf "$archive" tdlib
|
||||
sha256sum "$archive" > "${archive}.sha256"
|
||||
|
||||
- name: Publish TDLib package
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
version="${{ steps.tdlib.outputs.version }}"
|
||||
archive="${{ steps.tdlib.outputs.archive }}"
|
||||
base="${{ gitea.server_url }}/api/packages/${{ gitea.repository_owner }}/generic/${PACKAGE_NAME}"
|
||||
|
||||
status="$(curl --silent --show-error \
|
||||
--output /dev/null \
|
||||
--write-out "%{http_code}" \
|
||||
--user "${{ gitea.actor }}:${GITEA_TOKEN}" \
|
||||
-X DELETE \
|
||||
"$base/$version")"
|
||||
case "$status" in
|
||||
204|404) ;;
|
||||
*)
|
||||
echo "Unexpected response deleting existing package version: $status" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
curl --fail-with-body \
|
||||
--user "${{ gitea.actor }}:${GITEA_TOKEN}" \
|
||||
--upload-file "$archive" \
|
||||
"$base/$version/$archive"
|
||||
|
||||
curl --fail-with-body \
|
||||
--user "${{ gitea.actor }}:${GITEA_TOKEN}" \
|
||||
--upload-file "${archive}.sha256" \
|
||||
"$base/$version/${archive}.sha256"
|
||||
|
||||
- name: Publish latest metadata
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
version="${{ steps.tdlib.outputs.version }}"
|
||||
archive="${{ steps.tdlib.outputs.archive }}"
|
||||
base="${{ gitea.server_url }}/api/packages/${{ gitea.repository_owner }}/generic/${PACKAGE_NAME}"
|
||||
latest_manifest="tdlib-latest.json"
|
||||
|
||||
cat > "$latest_manifest" <<EOF
|
||||
{
|
||||
"ref": "${{ steps.tdlib.outputs.ref }}",
|
||||
"version": "$version",
|
||||
"archive": "$archive",
|
||||
"url": "$base/$version/$archive",
|
||||
"sha256_url": "$base/$version/${archive}.sha256"
|
||||
}
|
||||
EOF
|
||||
|
||||
status="$(curl --silent --show-error \
|
||||
--output /dev/null \
|
||||
--write-out "%{http_code}" \
|
||||
--user "${{ gitea.actor }}:${GITEA_TOKEN}" \
|
||||
-X DELETE \
|
||||
"$base/latest")"
|
||||
case "$status" in
|
||||
204|404) ;;
|
||||
*)
|
||||
echo "Unexpected response deleting latest package version: $status" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
curl --fail-with-body \
|
||||
--user "${{ gitea.actor }}:${GITEA_TOKEN}" \
|
||||
--upload-file "$latest_manifest" \
|
||||
"$base/latest/$latest_manifest"
|
||||
@@ -1,37 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
if [ "$#" -lt 1 ] || [ "$#" -gt 2 ]; then
|
||||
echo "usage: $0 <tdlib-root> [output-tar.gz]" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
tdlib_root="$(realpath "$1")"
|
||||
output_path="${2:-tdlib-linux-x86_64.tar.gz}"
|
||||
output_path="$(realpath -m "$output_path")"
|
||||
|
||||
include_dir="$tdlib_root/include"
|
||||
lib_dir="$tdlib_root/lib"
|
||||
|
||||
if [ ! -f "$include_dir/td/telegram/td_json_client.h" ]; then
|
||||
echo "missing TDLib header: $include_dir/td/telegram/td_json_client.h" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! compgen -G "$lib_dir/libtdjson.so*" >/dev/null; then
|
||||
echo "missing TDLib shared library under: $lib_dir" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
workdir="$(mktemp -d)"
|
||||
trap 'rm -rf "$workdir"' EXIT
|
||||
|
||||
mkdir -p "$workdir/tdlib"
|
||||
cp -a "$include_dir" "$workdir/tdlib/include"
|
||||
cp -a "$lib_dir" "$workdir/tdlib/lib"
|
||||
|
||||
tar -C "$workdir" -czf "$output_path" tdlib
|
||||
sha256sum "$output_path" > "${output_path}.sha256"
|
||||
|
||||
echo "wrote $output_path"
|
||||
echo "wrote ${output_path}.sha256"
|
||||
14
src/app.cpp
14
src/app.cpp
@@ -13,6 +13,13 @@ namespace telegram_tui {
|
||||
|
||||
namespace {
|
||||
|
||||
std::string trim_release_tag_prefix(const std::string &value) {
|
||||
if (!value.empty() && (value[0] == 'v' || value[0] == 'V')) {
|
||||
return value.substr(1);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
bool is_truthy_env_value(const std::string &value) {
|
||||
return value == "1" || value == "true" || value == "TRUE" || value == "yes" ||
|
||||
value == "YES" || value == "on" || value == "ON";
|
||||
@@ -50,7 +57,7 @@ std::string run_command_capture(const std::string &command) {
|
||||
|
||||
std::optional<std::string> fetch_update_notice() {
|
||||
static constexpr const char *kLatestReleaseApiUrl =
|
||||
"https://git.mshq.dev/api/v1/repos/AxiFisk/shinoa/releases/tags/latest";
|
||||
"https://git.mshq.dev/api/v1/repos/AxiFisk/shinoa/releases/latest";
|
||||
|
||||
if (std::string(TELEGRAM_TUI_BUILD_COMMIT).empty()) {
|
||||
return std::nullopt;
|
||||
@@ -64,6 +71,11 @@ std::optional<std::string> fetch_update_notice() {
|
||||
|
||||
try {
|
||||
const json release = json::parse(response, nullptr, true, true);
|
||||
const std::string latest_tag = trim_release_tag_prefix(safe_string(release, "tag_name"));
|
||||
if (!latest_tag.empty() && latest_tag == TELEGRAM_TUI_PROJECT_VERSION) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
const std::string target_commit = safe_string(release, "target_commitish");
|
||||
if (target_commit.empty()) {
|
||||
return std::nullopt;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#define TELEGRAM_TUI_PROJECT_VERSION "@PROJECT_VERSION@"
|
||||
#define TELEGRAM_TUI_BUILD_COMMIT "@TELEGRAM_TUI_BUILD_COMMIT@"
|
||||
#define TELEGRAM_TUI_BUILD_VERSION "@TELEGRAM_TUI_BUILD_VERSION@"
|
||||
#define TELEGRAM_TUI_BUILD_API_ID "@TELEGRAM_TUI_BUILD_API_ID@"
|
||||
|
||||
Reference in New Issue
Block a user