Compare commits
20 Commits
1.3.1
...
release/gt
| Author | SHA1 | Date | |
|---|---|---|---|
| 6c3e61e261 | |||
| 78f29907cc | |||
| 4ab4dc8f16 | |||
| 6013f47441 | |||
| 89beb3ff2c | |||
| f9798a41e9 | |||
| 2f70440834 | |||
| cfeb38cb51 | |||
| 803018dacf | |||
| a852f233ee | |||
| d946e1256e | |||
| 7264cce5b8 | |||
| 6d098c9f76 | |||
| 2101aa7b14 | |||
| 65b3b9013a | |||
| 7056a7f836 | |||
| fd3660858e | |||
| 45285892de | |||
| 64d7394ffa | |||
| 69892a4d08 |
61
.gitea/scripts/prepare-rpm-release-assets.sh
Executable file
61
.gitea/scripts/prepare-rpm-release-assets.sh
Executable file
@@ -0,0 +1,61 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
: "${RELEASE_TAG:?Missing RELEASE_TAG}"
|
||||||
|
: "${TAG_PREFIX:?Missing TAG_PREFIX}"
|
||||||
|
: "${ASSETS_DIR:?Missing ASSETS_DIR}"
|
||||||
|
: "${RPM_BINARY_DIR:?Missing RPM_BINARY_DIR}"
|
||||||
|
: "${RPM_BINARY_PATTERN_PREFIX:?Missing RPM_BINARY_PATTERN_PREFIX}"
|
||||||
|
: "${RPM_DISTRO_NAME:?Missing RPM_DISTRO_NAME}"
|
||||||
|
: "${RPM_DISTRO_VERSION:?Missing RPM_DISTRO_VERSION}"
|
||||||
|
: "${GITHUB_ENV:?Missing GITHUB_ENV}"
|
||||||
|
|
||||||
|
version="${RELEASE_TAG#${TAG_PREFIX}}"
|
||||||
|
if [[ -z "$version" || "$version" == "$RELEASE_TAG" ]]; then
|
||||||
|
echo "Expected tag in the form ${TAG_PREFIX}{version}, got: $RELEASE_TAG" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "${EXPECTED_VERSION:-}" && "$EXPECTED_VERSION" != "$version" ]]; then
|
||||||
|
echo "Release tag version ($version) does not match expected package version ($EXPECTED_VERSION)." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -rf "$ASSETS_DIR"
|
||||||
|
mkdir -p "$ASSETS_DIR"
|
||||||
|
|
||||||
|
found=0
|
||||||
|
binary_pattern="${RPM_BINARY_PATTERN_PREFIX}${version}-*.rpm"
|
||||||
|
if [[ -d "$RPM_BINARY_DIR" ]]; then
|
||||||
|
find_cmd=(
|
||||||
|
find "$RPM_BINARY_DIR" -type f -name "$binary_pattern"
|
||||||
|
)
|
||||||
|
while IFS= read -r exclude; do
|
||||||
|
[[ -n "$exclude" ]] || continue
|
||||||
|
find_cmd+=( ! -name "$exclude" )
|
||||||
|
done <<< "${RPM_BINARY_EXCLUDE_PATTERNS:-}"
|
||||||
|
find_cmd+=( -exec cp '{}' "$ASSETS_DIR/" ';' )
|
||||||
|
"${find_cmd[@]}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if find "$ASSETS_DIR" -maxdepth 1 -type f -name '*.rpm' | grep -q .; then
|
||||||
|
found=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "${RPM_SOURCE_DIR:-}" && -n "${RPM_SOURCE_PATTERN_PREFIX:-}" && -d "$RPM_SOURCE_DIR" ]]; then
|
||||||
|
source_pattern="${RPM_SOURCE_PATTERN_PREFIX}${version}-*.src.rpm"
|
||||||
|
find "$RPM_SOURCE_DIR" -type f -name "$source_pattern" -exec cp '{}' "$ASSETS_DIR/" ';'
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$found" -ne 1 ]]; then
|
||||||
|
echo "No RPM artifacts were produced." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
package_group="${RPM_PACKAGE_GROUP:-${RPM_DISTRO_NAME}/${RPM_DISTRO_VERSION}}"
|
||||||
|
|
||||||
|
{
|
||||||
|
printf 'RELEASE_VERSION=%s\n' "$version"
|
||||||
|
printf 'RELEASE_ASSETS_DIR=%s\n' "$ASSETS_DIR"
|
||||||
|
printf 'RPM_PACKAGE_GROUP=%s\n' "$package_group"
|
||||||
|
} >> "$GITHUB_ENV"
|
||||||
65
.gitea/scripts/upload-rpm-packages.sh
Executable file
65
.gitea/scripts/upload-rpm-packages.sh
Executable file
@@ -0,0 +1,65 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
: "${GITEA_SERVER_URL:?Missing GITEA_SERVER_URL}"
|
||||||
|
: "${GITEA_REPOSITORY_OWNER:?Missing GITEA_REPOSITORY_OWNER}"
|
||||||
|
: "${RELEASE_ASSETS_DIR:?Missing RELEASE_ASSETS_DIR}"
|
||||||
|
|
||||||
|
owner="${GITEA_REPOSITORY_OWNER}"
|
||||||
|
package_user="${RPM_PACKAGE_USERNAME:-${GITEA_REPOSITORY_OWNER}}"
|
||||||
|
token="${RPM_PACKAGE_TOKEN:-}"
|
||||||
|
group="${RPM_PACKAGE_GROUP:-}"
|
||||||
|
|
||||||
|
if [[ -z "$package_user" ]]; then
|
||||||
|
echo "Missing package upload username. Set repository or organization variable RPM_PACKAGE_USERNAME." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "$token" ]]; then
|
||||||
|
echo "Missing package upload token. Set repository or organization secret RPM_PACKAGE_TOKEN." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
upload_url="${GITEA_SERVER_URL%/}/api/packages/${owner}/rpm"
|
||||||
|
if [[ -n "$group" ]]; then
|
||||||
|
upload_url="${upload_url}/${group}"
|
||||||
|
fi
|
||||||
|
upload_url="${upload_url}/upload"
|
||||||
|
|
||||||
|
shopt -s nullglob
|
||||||
|
found_rpm=0
|
||||||
|
for rpm in "$RELEASE_ASSETS_DIR"/*.rpm; do
|
||||||
|
case "$rpm" in
|
||||||
|
*.src.rpm)
|
||||||
|
continue
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
found_rpm=1
|
||||||
|
http_code="$(curl --silent --show-error \
|
||||||
|
--write-out '%{http_code}' \
|
||||||
|
--output /tmp/package-upload-response \
|
||||||
|
--user "${package_user}:${token}" \
|
||||||
|
--upload-file "$rpm" \
|
||||||
|
"$upload_url")"
|
||||||
|
|
||||||
|
case "$http_code" in
|
||||||
|
201)
|
||||||
|
echo "Uploaded $(basename "$rpm") to the RPM package registry."
|
||||||
|
;;
|
||||||
|
409)
|
||||||
|
echo "Package already exists for $(basename "$rpm"); skipping duplicate upload."
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Failed to upload $(basename "$rpm") to $upload_url (HTTP $http_code)." >&2
|
||||||
|
cat /tmp/package-upload-response >&2 || true
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
shopt -u nullglob
|
||||||
|
|
||||||
|
if [[ "$found_rpm" -ne 1 ]]; then
|
||||||
|
echo "No binary RPM artifacts were found to upload." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
141
.gitea/workflows/android-release.yaml
Normal file
141
.gitea/workflows/android-release.yaml
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
name: Android Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'release/android/*'
|
||||||
|
|
||||||
|
env:
|
||||||
|
ANDROID_SDK_ROOT: ${{ gitea.workspace }}/android-sdk
|
||||||
|
ANDROID_HOME: ${{ gitea.workspace }}/android-sdk
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-android-release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
# Gitea's default act_runner labels map ubuntu-latest to node:16-bullseye,
|
||||||
|
# so keep the GitHub-hosted actions on their Node 16-compatible v3 line.
|
||||||
|
- name: Install system dependencies
|
||||||
|
run: |
|
||||||
|
set -eu
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y ca-certificates git openjdk-17-jdk unzip wget
|
||||||
|
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Install Android SDK components
|
||||||
|
run: |
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
wget -q https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip -O /tmp/android-commandlinetools.zip
|
||||||
|
|
||||||
|
rm -rf "$ANDROID_SDK_ROOT"
|
||||||
|
mkdir -p "$ANDROID_SDK_ROOT/cmdline-tools"
|
||||||
|
|
||||||
|
unzip -q /tmp/android-commandlinetools.zip -d /tmp/android-commandlinetools
|
||||||
|
mv /tmp/android-commandlinetools/cmdline-tools "$ANDROID_SDK_ROOT/cmdline-tools/latest"
|
||||||
|
|
||||||
|
# sdkmanager exits successfully once it has consumed all input, which
|
||||||
|
# causes `yes` to receive SIGPIPE and return 141 under `pipefail`.
|
||||||
|
set +o pipefail
|
||||||
|
yes | "$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager" --sdk_root="$ANDROID_SDK_ROOT" --licenses
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
"$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager" --sdk_root="$ANDROID_SDK_ROOT" \
|
||||||
|
"platform-tools" \
|
||||||
|
"build-tools;33.0.1" \
|
||||||
|
"platforms;android-33"
|
||||||
|
|
||||||
|
- name: Prepare Android signing config
|
||||||
|
env:
|
||||||
|
ANDROID_RELEASE_KEYSTORE_B64: ${{ secrets.ANDROID_RELEASE_KEYSTORE_B64 }}
|
||||||
|
ORG_GRADLE_PROJECT_RELEASE_STORE_PASSWORD: ${{ secrets.ANDROID_RELEASE_STORE_PASSWORD }}
|
||||||
|
ORG_GRADLE_PROJECT_RELEASE_KEY_ALIAS: ${{ secrets.ANDROID_RELEASE_KEY_ALIAS }}
|
||||||
|
ORG_GRADLE_PROJECT_RELEASE_KEY_PASSWORD: ${{ secrets.ANDROID_RELEASE_KEY_PASSWORD }}
|
||||||
|
run: |
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
: "${ANDROID_RELEASE_KEYSTORE_B64:?Missing secret ANDROID_RELEASE_KEYSTORE_B64}"
|
||||||
|
: "${ORG_GRADLE_PROJECT_RELEASE_STORE_PASSWORD:?Missing secret ANDROID_RELEASE_STORE_PASSWORD}"
|
||||||
|
: "${ORG_GRADLE_PROJECT_RELEASE_KEY_ALIAS:?Missing secret ANDROID_RELEASE_KEY_ALIAS}"
|
||||||
|
: "${ORG_GRADLE_PROJECT_RELEASE_KEY_PASSWORD:?Missing secret ANDROID_RELEASE_KEY_PASSWORD}"
|
||||||
|
|
||||||
|
keystore_path="${{ gitea.workspace }}/android-release.keystore"
|
||||||
|
printf '%s' "$ANDROID_RELEASE_KEYSTORE_B64" | base64 -d > "$keystore_path"
|
||||||
|
chmod 600 "$keystore_path"
|
||||||
|
|
||||||
|
printf 'ORG_GRADLE_PROJECT_RELEASE_STORE_FILE=%s\n' "$keystore_path" >> "$GITHUB_ENV"
|
||||||
|
printf 'ORG_GRADLE_PROJECT_RELEASE_STORE_PASSWORD=%s\n' "$ORG_GRADLE_PROJECT_RELEASE_STORE_PASSWORD" >> "$GITHUB_ENV"
|
||||||
|
printf 'ORG_GRADLE_PROJECT_RELEASE_KEY_ALIAS=%s\n' "$ORG_GRADLE_PROJECT_RELEASE_KEY_ALIAS" >> "$GITHUB_ENV"
|
||||||
|
printf 'ORG_GRADLE_PROJECT_RELEASE_KEY_PASSWORD=%s\n' "$ORG_GRADLE_PROJECT_RELEASE_KEY_PASSWORD" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
|
- name: Build Android release APKs
|
||||||
|
working-directory: android
|
||||||
|
run: ./gradlew assembleRelease
|
||||||
|
|
||||||
|
- name: Prepare release assets
|
||||||
|
env:
|
||||||
|
RELEASE_TAG: ${{ github.ref_name }}
|
||||||
|
run: |
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
version="${RELEASE_TAG#release/android/}"
|
||||||
|
if [ -z "$version" ] || [ "$version" = "$RELEASE_TAG" ]; then
|
||||||
|
echo "Expected tag in the form release/android/{version}, got: $RELEASE_TAG" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
assets_dir="${{ gitea.workspace }}/release-assets/android"
|
||||||
|
rm -rf "$assets_dir"
|
||||||
|
mkdir -p "$assets_dir"
|
||||||
|
|
||||||
|
found_apk=0
|
||||||
|
for apk in android/app/build/outputs/apk/release/*.apk; do
|
||||||
|
if [ ! -e "$apk" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
found_apk=1
|
||||||
|
base="$(basename "$apk")"
|
||||||
|
|
||||||
|
case "$base" in
|
||||||
|
app-*-release*.apk)
|
||||||
|
arch="${base#app-}"
|
||||||
|
arch="${arch%%-release*}"
|
||||||
|
;;
|
||||||
|
app-release*.apk)
|
||||||
|
arch="universal"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unexpected APK filename: $base" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
cp "$apk" "$assets_dir/kordophone-${arch}-${version}.apk"
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$found_apk" -ne 1 ]; then
|
||||||
|
echo "No release APKs were produced." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
{
|
||||||
|
printf 'RELEASE_VERSION=%s\n' "$version"
|
||||||
|
printf 'RELEASE_ASSETS_DIR=%s\n' "$assets_dir"
|
||||||
|
} >> "$GITHUB_ENV"
|
||||||
|
|
||||||
|
- name: Create Gitea release
|
||||||
|
uses: https://gitea.com/actions/gitea-release-action@v1
|
||||||
|
with:
|
||||||
|
name: Kordophone Android ${{ env.RELEASE_VERSION }}
|
||||||
|
tag_name: ${{ github.ref_name }}
|
||||||
|
target_commitish: ${{ github.sha }}
|
||||||
|
files: |
|
||||||
|
${{ env.RELEASE_ASSETS_DIR }}/*.apk
|
||||||
|
|
||||||
|
- name: Clean up signing material
|
||||||
|
if: ${{ always() }}
|
||||||
|
run: rm -f "${{ gitea.workspace }}/android-release.keystore"
|
||||||
112
.gitea/workflows/core-rpm-release.yaml
Normal file
112
.gitea/workflows/core-rpm-release.yaml
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
name: Core RPM Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'release/core/*'
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
code: read
|
||||||
|
releases: write
|
||||||
|
packages: write
|
||||||
|
|
||||||
|
env:
|
||||||
|
RPM_DISTRO_NAME: fedora
|
||||||
|
RPM_DISTRO_VERSION: '43'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-core-rpm-release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: fedora:43
|
||||||
|
|
||||||
|
steps:
|
||||||
|
# Build inside Fedora so the RPM package repository grouping matches the
|
||||||
|
# Fedora release we publish to.
|
||||||
|
- name: Install system dependencies
|
||||||
|
run: |
|
||||||
|
set -eu
|
||||||
|
dnf install -y \
|
||||||
|
ca-certificates \
|
||||||
|
curl \
|
||||||
|
gcc \
|
||||||
|
gcc-c++ \
|
||||||
|
git \
|
||||||
|
make \
|
||||||
|
nodejs \
|
||||||
|
openssl-devel \
|
||||||
|
pkg-config \
|
||||||
|
python3 \
|
||||||
|
rpm-build \
|
||||||
|
sqlite-devel \
|
||||||
|
dbus-devel \
|
||||||
|
systemd-devel
|
||||||
|
dnf clean all
|
||||||
|
|
||||||
|
- name: Install Rust toolchain
|
||||||
|
run: |
|
||||||
|
set -eu
|
||||||
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
||||||
|
echo "/root/.cargo/bin" >> "$GITHUB_PATH"
|
||||||
|
|
||||||
|
- name: Install cargo-generate-rpm
|
||||||
|
run: cargo install cargo-generate-rpm
|
||||||
|
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Build Core RPM
|
||||||
|
working-directory: core
|
||||||
|
run: make rpm
|
||||||
|
|
||||||
|
- name: Read Core Package Version
|
||||||
|
run: |
|
||||||
|
set -eu
|
||||||
|
version="$(awk -F ' = ' '
|
||||||
|
$0 == "[package]" { in_pkg = 1; next }
|
||||||
|
/^\[/ { in_pkg = 0 }
|
||||||
|
in_pkg && $1 == "version" {
|
||||||
|
gsub(/"/, "", $2)
|
||||||
|
print $2
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
' core/kordophoned/Cargo.toml)"
|
||||||
|
if [ -z "$version" ]; then
|
||||||
|
echo "Could not determine kordophoned package version from core/kordophoned/Cargo.toml." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
printf 'CORE_PACKAGE_VERSION=%s\n' "$version" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
|
- name: Prepare release assets
|
||||||
|
env:
|
||||||
|
RELEASE_TAG: ${{ github.ref_name }}
|
||||||
|
TAG_PREFIX: release/core/
|
||||||
|
ASSETS_DIR: ${{ gitea.workspace }}/release-assets/core
|
||||||
|
RPM_BINARY_DIR: ${{ gitea.workspace }}/core/target/generate-rpm
|
||||||
|
RPM_BINARY_PATTERN_PREFIX: kordophoned-
|
||||||
|
RPM_PACKAGE_GROUP: ${{ vars.RPM_PACKAGE_GROUP }}
|
||||||
|
RPM_DISTRO_NAME: ${{ env.RPM_DISTRO_NAME }}
|
||||||
|
RPM_DISTRO_VERSION: ${{ env.RPM_DISTRO_VERSION }}
|
||||||
|
EXPECTED_VERSION: ${{ env.CORE_PACKAGE_VERSION }}
|
||||||
|
run: ./.gitea/scripts/prepare-rpm-release-assets.sh
|
||||||
|
|
||||||
|
- name: Upload RPMs to Gitea package registry
|
||||||
|
env:
|
||||||
|
GITEA_SERVER_URL: ${{ gitea.server_url }}
|
||||||
|
GITEA_REPOSITORY_OWNER: ${{ gitea.repository_owner }}
|
||||||
|
RPM_PACKAGE_GROUP: ${{ env.RPM_PACKAGE_GROUP }}
|
||||||
|
RPM_PACKAGE_TOKEN: ${{ secrets.RPM_PACKAGE_TOKEN }}
|
||||||
|
RPM_PACKAGE_USERNAME: ${{ vars.RPM_PACKAGE_USERNAME }}
|
||||||
|
RELEASE_ASSETS_DIR: ${{ env.RELEASE_ASSETS_DIR }}
|
||||||
|
run: ./.gitea/scripts/upload-rpm-packages.sh
|
||||||
|
|
||||||
|
- name: Create Gitea release
|
||||||
|
uses: https://gitea.com/actions/gitea-release-action@v1
|
||||||
|
with:
|
||||||
|
name: Kordophoned Core ${{ env.RELEASE_VERSION }}
|
||||||
|
tag_name: ${{ github.ref_name }}
|
||||||
|
target_commitish: ${{ github.sha }}
|
||||||
|
files: |
|
||||||
|
${{ env.RELEASE_ASSETS_DIR }}/*.rpm
|
||||||
97
.gitea/workflows/gtk-rpm-release.yaml
Normal file
97
.gitea/workflows/gtk-rpm-release.yaml
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
name: GTK RPM Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'release/gtk/*'
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
code: read
|
||||||
|
releases: write
|
||||||
|
packages: write
|
||||||
|
|
||||||
|
env:
|
||||||
|
RPM_DISTRO_NAME: fedora
|
||||||
|
RPM_DISTRO_VERSION: '43'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-gtk-rpm-release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: fedora:43
|
||||||
|
|
||||||
|
steps:
|
||||||
|
# The default Gitea runner image is Debian-based. Build the GTK RPM in a
|
||||||
|
# Fedora container so rpmbuild and the RPM build dependencies match the
|
||||||
|
# existing local packaging environment.
|
||||||
|
- name: Install system dependencies
|
||||||
|
run: |
|
||||||
|
set -eu
|
||||||
|
dnf install -y \
|
||||||
|
ca-certificates \
|
||||||
|
curl \
|
||||||
|
gcc \
|
||||||
|
git \
|
||||||
|
ImageMagick \
|
||||||
|
libadwaita-devel \
|
||||||
|
libgee-devel \
|
||||||
|
libsecret-devel \
|
||||||
|
make \
|
||||||
|
meson \
|
||||||
|
ninja-build \
|
||||||
|
nodejs \
|
||||||
|
pkgconfig \
|
||||||
|
python3 \
|
||||||
|
redhat-rpm-config \
|
||||||
|
rpm-build \
|
||||||
|
rpmdevtools \
|
||||||
|
gtk4-devel \
|
||||||
|
glib2-devel \
|
||||||
|
vala
|
||||||
|
dnf clean all
|
||||||
|
rpmdev-setuptree
|
||||||
|
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Build GTK RPMs
|
||||||
|
working-directory: gtk
|
||||||
|
run: make rpm
|
||||||
|
|
||||||
|
- name: Prepare release assets
|
||||||
|
env:
|
||||||
|
RELEASE_TAG: ${{ github.ref_name }}
|
||||||
|
TAG_PREFIX: release/gtk/
|
||||||
|
ASSETS_DIR: ${{ gitea.workspace }}/release-assets/gtk
|
||||||
|
RPM_BINARY_DIR: /root/rpmbuild/RPMS
|
||||||
|
RPM_BINARY_PATTERN_PREFIX: kordophone-
|
||||||
|
RPM_BINARY_EXCLUDE_PATTERNS: |
|
||||||
|
*-debuginfo-*
|
||||||
|
*-debugsource-*
|
||||||
|
RPM_PACKAGE_GROUP: ${{ vars.RPM_PACKAGE_GROUP }}
|
||||||
|
RPM_SOURCE_DIR: /root/rpmbuild/SRPMS
|
||||||
|
RPM_SOURCE_PATTERN_PREFIX: kordophone-
|
||||||
|
RPM_DISTRO_NAME: ${{ env.RPM_DISTRO_NAME }}
|
||||||
|
RPM_DISTRO_VERSION: ${{ env.RPM_DISTRO_VERSION }}
|
||||||
|
run: ./.gitea/scripts/prepare-rpm-release-assets.sh
|
||||||
|
|
||||||
|
- name: Upload RPMs to Gitea package registry
|
||||||
|
env:
|
||||||
|
GITEA_SERVER_URL: ${{ gitea.server_url }}
|
||||||
|
GITEA_REPOSITORY_OWNER: ${{ gitea.repository_owner }}
|
||||||
|
RPM_PACKAGE_GROUP: ${{ env.RPM_PACKAGE_GROUP }}
|
||||||
|
RPM_PACKAGE_TOKEN: ${{ secrets.RPM_PACKAGE_TOKEN }}
|
||||||
|
RPM_PACKAGE_USERNAME: ${{ vars.RPM_PACKAGE_USERNAME }}
|
||||||
|
RELEASE_ASSETS_DIR: ${{ env.RELEASE_ASSETS_DIR }}
|
||||||
|
run: ./.gitea/scripts/upload-rpm-packages.sh
|
||||||
|
|
||||||
|
- name: Create Gitea release
|
||||||
|
uses: https://gitea.com/actions/gitea-release-action@v1
|
||||||
|
with:
|
||||||
|
name: Kordophone GTK ${{ env.RELEASE_VERSION }}
|
||||||
|
tag_name: ${{ github.ref_name }}
|
||||||
|
target_commitish: ${{ github.sha }}
|
||||||
|
files: |
|
||||||
|
${{ env.RELEASE_ASSETS_DIR }}/*.rpm
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1 +1,3 @@
|
|||||||
|
.codex
|
||||||
|
ext/
|
||||||
target/
|
target/
|
||||||
|
|||||||
2
server/.gitmodules → .gitmodules
vendored
2
server/.gitmodules → .gitmodules
vendored
@@ -1,3 +1,3 @@
|
|||||||
[submodule "CocoaHTTPServer"]
|
[submodule "CocoaHTTPServer"]
|
||||||
path = CocoaHTTPServer
|
path = server/CocoaHTTPServer
|
||||||
url = https://github.com/robbiehanson/CocoaHTTPServer.git
|
url = https://github.com/robbiehanson/CocoaHTTPServer.git
|
||||||
2
android/.idea/gradle.xml
generated
2
android/.idea/gradle.xml
generated
@@ -5,7 +5,7 @@
|
|||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="gradleJvm" value="jbr-17" />
|
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
<set>
|
<set>
|
||||||
<option value="$PROJECT_DIR$" />
|
<option value="$PROJECT_DIR$" />
|
||||||
|
|||||||
1
android/.idea/vcs.xml
generated
1
android/.idea/vcs.xml
generated
@@ -1,6 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="VcsDirectoryMappings">
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@@ -24,7 +24,7 @@ data class ServerConfig(
|
|||||||
fun loadFromSettings(context: Context): ServerConfig {
|
fun loadFromSettings(context: Context): ServerConfig {
|
||||||
val prefs = getSharedPreferences(context)
|
val prefs = getSharedPreferences(context)
|
||||||
return ServerConfig(
|
return ServerConfig(
|
||||||
serverName = prefs.getString("serverName", null),
|
serverName = prefs.getString("serverName", null).normalizedBaseUrl(),
|
||||||
authentication = ServerAuthentication.loadFromEncryptedSettings(context)
|
authentication = ServerAuthentication.loadFromEncryptedSettings(context)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -37,7 +37,7 @@ data class ServerConfig(
|
|||||||
fun saveToSettings(context: Context) {
|
fun saveToSettings(context: Context) {
|
||||||
val prefs = getSharedPreferences(context)
|
val prefs = getSharedPreferences(context)
|
||||||
prefs.edit {
|
prefs.edit {
|
||||||
putString("serverName", serverName)
|
putString("serverName", serverName.normalizedBaseUrl())
|
||||||
apply()
|
apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,6 +45,11 @@ data class ServerConfig(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun String?.normalizedBaseUrl(): String? {
|
||||||
|
val value = this?.trim()?.takeIf { it.isNotEmpty() } ?: return null
|
||||||
|
return if (value.endsWith("/")) value else "$value/"
|
||||||
|
}
|
||||||
|
|
||||||
data class ServerAuthentication(
|
data class ServerAuthentication(
|
||||||
val username: String,
|
val username: String,
|
||||||
val password: String,
|
val password: String,
|
||||||
@@ -101,7 +106,9 @@ class ServerConfigRepository @Inject constructor(
|
|||||||
|
|
||||||
fun applyConfig(applicator: ServerConfig.() -> Unit) {
|
fun applyConfig(applicator: ServerConfig.() -> Unit) {
|
||||||
val config = _serverConfig.value.copy()
|
val config = _serverConfig.value.copy()
|
||||||
_serverConfig.value = config.apply(applicator)
|
_serverConfig.value = config.apply(applicator).also {
|
||||||
|
it.serverName = it.serverName.normalizedBaseUrl()
|
||||||
|
}
|
||||||
_serverConfig.value.saveToSettings(context)
|
_serverConfig.value.saveToSettings(context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,8 +104,10 @@ class APIClientFactory {
|
|||||||
return InvalidConfigurationAPIClient(InvalidConfigurationAPIClient.Issue.NOT_CONFIGURED)
|
return InvalidConfigurationAPIClient(InvalidConfigurationAPIClient.Issue.NOT_CONFIGURED)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val normalizedServerString = serverString.ensureTrailingSlash()
|
||||||
|
|
||||||
// Try to parse server string
|
// Try to parse server string
|
||||||
val serverURL = HttpUrl.parse(serverString)
|
val serverURL = HttpUrl.parse(normalizedServerString)
|
||||||
?: return InvalidConfigurationAPIClient(InvalidConfigurationAPIClient.Issue.INVALID_HOST_URL)
|
?: return InvalidConfigurationAPIClient(InvalidConfigurationAPIClient.Issue.INVALID_HOST_URL)
|
||||||
|
|
||||||
return RetrofitAPIClient(serverURL.url(), authentication)
|
return RetrofitAPIClient(serverURL.url(), authentication)
|
||||||
@@ -113,6 +115,10 @@ class APIClientFactory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun String.ensureTrailingSlash(): String {
|
||||||
|
return if (endsWith("/")) this else "$this/"
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Is this a dumb idea?
|
// TODO: Is this a dumb idea?
|
||||||
class InvalidConfigurationAPIClient(val issue: Issue): APIClient {
|
class InvalidConfigurationAPIClient(val issue: Issue): APIClient {
|
||||||
enum class Issue {
|
enum class Issue {
|
||||||
|
|||||||
@@ -55,13 +55,13 @@ data class UploadAttachmentResponse(
|
|||||||
)
|
)
|
||||||
|
|
||||||
interface APIInterface {
|
interface APIInterface {
|
||||||
@GET("/version")
|
@GET("version")
|
||||||
suspend fun getVersion(): ResponseBody
|
suspend fun getVersion(): ResponseBody
|
||||||
|
|
||||||
@GET("/conversations")
|
@GET("conversations")
|
||||||
suspend fun getConversations(): Response<List<Conversation>>
|
suspend fun getConversations(): Response<List<Conversation>>
|
||||||
|
|
||||||
@GET("/messages")
|
@GET("messages")
|
||||||
suspend fun getMessages(
|
suspend fun getMessages(
|
||||||
@Query("guid") conversationGUID: String,
|
@Query("guid") conversationGUID: String,
|
||||||
@Query("limit") limit: Int? = null,
|
@Query("limit") limit: Int? = null,
|
||||||
@@ -69,19 +69,19 @@ interface APIInterface {
|
|||||||
@Query("afterMessageGUID") afterMessageGUID: GUID? = null,
|
@Query("afterMessageGUID") afterMessageGUID: GUID? = null,
|
||||||
): Response<List<Message>>
|
): Response<List<Message>>
|
||||||
|
|
||||||
@POST("/sendMessage")
|
@POST("sendMessage")
|
||||||
suspend fun sendMessage(@Body request: SendMessageRequest): Response<SendMessageResponse>
|
suspend fun sendMessage(@Body request: SendMessageRequest): Response<SendMessageResponse>
|
||||||
|
|
||||||
@POST("/markConversation")
|
@POST("markConversation")
|
||||||
suspend fun markConversation(@Query("guid") conversationGUID: String): Response<Void>
|
suspend fun markConversation(@Query("guid") conversationGUID: String): Response<Void>
|
||||||
|
|
||||||
@GET("/attachment")
|
@GET("attachment")
|
||||||
suspend fun fetchAttachment(@Query("guid") guid: String, @Query("preview") preview: Boolean = false): ResponseBody
|
suspend fun fetchAttachment(@Query("guid") guid: String, @Query("preview") preview: Boolean = false): ResponseBody
|
||||||
|
|
||||||
@POST("/uploadAttachment")
|
@POST("uploadAttachment")
|
||||||
suspend fun uploadAttachment(@Query("filename") filename: String, @Body body: RequestBody): Response<UploadAttachmentResponse>
|
suspend fun uploadAttachment(@Query("filename") filename: String, @Body body: RequestBody): Response<UploadAttachmentResponse>
|
||||||
|
|
||||||
@POST("/authenticate")
|
@POST("authenticate")
|
||||||
suspend fun authenticate(@Body request: AuthenticationRequest): Response<AuthenticationResponse>
|
suspend fun authenticate(@Body request: AuthenticationRequest): Response<AuthenticationResponse>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import net.buzzert.kordophone.backend.db.CachedChatDatabase
|
|||||||
import net.buzzert.kordophone.backend.model.Message
|
import net.buzzert.kordophone.backend.model.Message
|
||||||
import net.buzzert.kordophone.backend.model.OutgoingMessage
|
import net.buzzert.kordophone.backend.model.OutgoingMessage
|
||||||
import net.buzzert.kordophone.backend.server.APIClient
|
import net.buzzert.kordophone.backend.server.APIClient
|
||||||
|
import net.buzzert.kordophone.backend.server.APIClientFactory
|
||||||
import net.buzzert.kordophone.backend.server.APIInterface
|
import net.buzzert.kordophone.backend.server.APIInterface
|
||||||
import net.buzzert.kordophone.backend.server.Authentication
|
import net.buzzert.kordophone.backend.server.Authentication
|
||||||
import net.buzzert.kordophone.backend.server.ChatRepository
|
import net.buzzert.kordophone.backend.server.ChatRepository
|
||||||
@@ -38,6 +39,16 @@ class BackendTests {
|
|||||||
return Pair(repository, mockServer)
|
return Pair(repository, mockServer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testCreateClientAcceptsBaseUrlWithoutTrailingSlash() {
|
||||||
|
val client = APIClientFactory.createClient(
|
||||||
|
"https://example.com/api",
|
||||||
|
Authentication("test", "test")
|
||||||
|
)
|
||||||
|
|
||||||
|
assertTrue(client.isConfigured)
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testGetVersion() = runBlocking {
|
fun testGetVersion() = runBlocking {
|
||||||
val (repository, mockServer) = mockRepository()
|
val (repository, mockServer) = mockRepository()
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
FROM fedora:40
|
FROM fedora:43
|
||||||
|
|
||||||
RUN dnf update -y && \
|
RUN dnf update -y && \
|
||||||
dnf install -y \
|
dnf install -y \
|
||||||
@@ -23,4 +23,3 @@ WORKDIR /workspace
|
|||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
CMD ["make", "rpm"]
|
CMD ["make", "rpm"]
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "kordophoned"
|
name = "kordophoned"
|
||||||
version = "1.3.0"
|
version = "1.3.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "GPL-3.0"
|
license = "GPL-3.0"
|
||||||
description = "Client daemon for the Kordophone chat protocol"
|
description = "Client daemon for the Kordophone chat protocol"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
FROM fedora:40
|
FROM fedora:43
|
||||||
|
|
||||||
# Install RPM build tools and dependencies
|
# Install RPM build tools and dependencies
|
||||||
RUN dnf update -y && dnf install -y \
|
RUN dnf update -y && dnf install -y \
|
||||||
|
|||||||
16
gtk/Makefile
16
gtk/Makefile
@@ -5,14 +5,20 @@ all: setup
|
|||||||
setup: build/
|
setup: build/
|
||||||
meson build
|
meson build
|
||||||
|
|
||||||
VER_RAW := $(shell git -C .. describe --tags --abbrev=0 2>/dev/null || git -C .. describe --tags 2>/dev/null || printf '0.0.0')
|
VER_RAW := $(shell git -C .. describe --tags --match 'release/gtk/*' --abbrev=0 2>/dev/null || true)
|
||||||
VER := $(patsubst v%,%,$(VER_RAW))
|
VER := $(patsubst release/gtk/%,%,$(VER_RAW))
|
||||||
TMP := $(shell mktemp -d)
|
TMP := $(shell mktemp -d)
|
||||||
rpm:
|
RPM_SOURCE := $(TMP)/$(VER).tar.gz
|
||||||
git -C .. archive --format=tar.gz --prefix=kordophone/ -o $(TMP)/v$(VER).tar.gz HEAD
|
.PHONY: check-version
|
||||||
|
check-version:
|
||||||
|
@test -n "$(VER_RAW)" || { echo "Could not determine GTK release version from git tags." >&2; echo "Expected a tag reachable from HEAD matching release/gtk/<version>." >&2; exit 1; }
|
||||||
|
@test "$(VER)" != "$(VER_RAW)" || { echo "Invalid GTK release tag: $(VER_RAW)" >&2; echo "Expected format: release/gtk/<version>." >&2; exit 1; }
|
||||||
|
|
||||||
|
rpm: check-version
|
||||||
|
git -C .. archive --format=tar.gz --prefix=kordophone/ -o $(RPM_SOURCE) HEAD
|
||||||
rpmbuild -ba dist/rpm/kordophone.spec --define "_sourcedir $(TMP)" --define "app_version $(VER)"
|
rpmbuild -ba dist/rpm/kordophone.spec --define "_sourcedir $(TMP)" --define "app_version $(VER)"
|
||||||
|
|
||||||
deb:
|
deb: check-version
|
||||||
./dist/deb/build-deb.sh $(VER)
|
./dist/deb/build-deb.sh $(VER)
|
||||||
|
|
||||||
.PHONY: flatpak
|
.PHONY: flatpak
|
||||||
|
|||||||
5
gtk/dist/rpm/kordophone.spec
vendored
5
gtk/dist/rpm/kordophone.spec
vendored
@@ -1,12 +1,11 @@
|
|||||||
%global app_version %{!?app_version:1.3.0}
|
|
||||||
Name: kordophone
|
Name: kordophone
|
||||||
Version: %{app_version}
|
Version: %{?app_version}%{!?app_version:1.3.0}
|
||||||
Release: 1%{?dist}
|
Release: 1%{?dist}
|
||||||
Summary: GTK4/Libadwaita client for Kordophone
|
Summary: GTK4/Libadwaita client for Kordophone
|
||||||
|
|
||||||
License: GPL
|
License: GPL
|
||||||
URL: https://code.buzzert.dev/buzzert/Kordophone
|
URL: https://code.buzzert.dev/buzzert/Kordophone
|
||||||
Source0: %{url}/archive/v%{version}.tar.gz
|
Source0: %{url}/archive/release/gtk/%{version}.tar.gz
|
||||||
|
|
||||||
BuildRequires: meson >= 0.56.0
|
BuildRequires: meson >= 0.56.0
|
||||||
BuildRequires: vala
|
BuildRequires: vala
|
||||||
|
|||||||
@@ -327,8 +327,8 @@ private class TranscriptDrawingArea : Widget
|
|||||||
|
|
||||||
private void recompute_message_layouts() {
|
private void recompute_message_layouts() {
|
||||||
var container_width = get_width();
|
var container_width = get_width();
|
||||||
float max_width = container_width * 0.90f;
|
float max_width = container_width * 0.80f;
|
||||||
float image_max_width = max_width * 0.75f;
|
float image_max_width = max_width * 0.70f;
|
||||||
|
|
||||||
DateTime? last_date = null;
|
DateTime? last_date = null;
|
||||||
string? last_sender = null;
|
string? last_sender = null;
|
||||||
@@ -383,6 +383,10 @@ private class TranscriptDrawingArea : Widget
|
|||||||
items.add(image_layout);
|
items.add(image_layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// New-message animation is a one-shot effect. Clear the flag after
|
||||||
|
// scheduling bubble animations so later relayouts do not replay it.
|
||||||
|
message.should_animate = false;
|
||||||
|
|
||||||
last_sender = message.sender;
|
last_sender = message.sender;
|
||||||
last_date = date;
|
last_date = date;
|
||||||
|
|
||||||
|
|||||||
@@ -159,7 +159,6 @@ public class TranscriptView : Adw.Bin
|
|||||||
}
|
}
|
||||||
|
|
||||||
delegate void OpenPath(string path);
|
delegate void OpenPath(string path);
|
||||||
private ulong attachment_downloaded_handler_id = 0;
|
|
||||||
private void open_attachment(string attachment_guid) {
|
private void open_attachment(string attachment_guid) {
|
||||||
OpenPath open_path = (path) => {
|
OpenPath open_path = (path) => {
|
||||||
try {
|
try {
|
||||||
@@ -180,10 +179,17 @@ public class TranscriptView : Adw.Bin
|
|||||||
|
|
||||||
// TODO: Should probably indicate progress here.
|
// TODO: Should probably indicate progress here.
|
||||||
|
|
||||||
attachment_downloaded_handler_id = Repository.get_instance().attachment_downloaded.connect((guid) => {
|
ulong handler_id = 0;
|
||||||
|
handler_id = Repository.get_instance().attachment_downloaded.connect((guid) => {
|
||||||
if (guid == attachment_guid) {
|
if (guid == attachment_guid) {
|
||||||
open_path(attachment_info.path);
|
try {
|
||||||
Repository.get_instance().disconnect(attachment_downloaded_handler_id);
|
var updated_attachment_info = Repository.get_instance().get_attachment_info(attachment_guid);
|
||||||
|
open_path(updated_attachment_info.path);
|
||||||
|
} catch (GLib.Error e) {
|
||||||
|
warning("Failed to get attachment info after download: %s", e.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
Repository.get_instance().disconnect(handler_id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user