ci: use `upend --version` for AppImage, move get_version.sh logic to cli

Tomáš Mládek 2023-08-21 16:12:21 +02:00
parent 5188336c7e
commit 39db638cbd
6 changed files with 81 additions and 19 deletions

65
Cargo.lock generated
View File

@ -659,6 +659,7 @@ dependencies = [
"anstyle",
"bitflags 1.3.2",
"clap_lex",
"once_cell",
"strsim",
]
@ -702,6 +703,12 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
[[package]]
name = "const_fn"
version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fbdcdcb6d86f71c5e97409ad45898af11cbc995b4ee8112d59095a28d376c935"
[[package]]
name = "const_format"
version = "0.2.30"
@ -1258,6 +1265,19 @@ dependencies = [
"weezl",
]
[[package]]
name = "git2"
version = "0.17.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b989d6a7ca95a362cf2cfc5ad688b3a467be1f87e480b8dad07fee8c79b0044"
dependencies = [
"bitflags 1.3.2",
"libc",
"libgit2-sys",
"log",
"url",
]
[[package]]
name = "h2"
version = "0.3.18"
@ -1648,6 +1668,18 @@ version = "0.2.144"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1"
[[package]]
name = "libgit2-sys"
version = "0.15.2+1.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a80df2e11fb4a61f4ba2ab42dbe7f74468da143f1a75c74e11dee7c813f694fa"
dependencies = [
"cc",
"libc",
"libz-sys",
"pkg-config",
]
[[package]]
name = "libsqlite3-sys"
version = "0.22.2"
@ -1668,6 +1700,18 @@ dependencies = [
"cc",
]
[[package]]
name = "libz-sys"
version = "1.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d97137b25e321a73eef1418d1d5d2eda4d77e12813f8e6dead84bc52c5870a7b"
dependencies = [
"cc",
"libc",
"pkg-config",
"vcpkg",
]
[[package]]
name = "link-cplusplus"
version = "1.0.8"
@ -2741,8 +2785,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "970538704756fd0bb4ec8cb89f80674afb661e7c0fe716f9ba5be57717742300"
dependencies = [
"const_format",
"git2",
"is_debug",
"time 0.3.20",
"tzdb",
]
[[package]]
@ -3170,6 +3216,25 @@ version = "1.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba"
[[package]]
name = "tz-rs"
version = "0.6.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33851b15c848fad2cf4b105c6bb66eb9512b6f6c44a4b13f57c53c73c707e2b4"
dependencies = [
"const_fn",
]
[[package]]
name = "tzdb"
version = "0.5.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec758958f2fb5069cd7fae385be95cc8eceb8cdfd270c7d14de6034f0108d99e"
dependencies = [
"iana-time-zone",
"tz-rs",
]
[[package]]
name = "unicase"
version = "2.6.0"

View File

@ -5,14 +5,12 @@ appimage:
RUN apt-get update && \
apt-get -y install wget pipx binutils coreutils desktop-file-utils fakeroot fuse libgdk-pixbuf2.0-dev patchelf python3-pip python3-setuptools squashfs-tools strace util-linux zsync && \
pipx ensurepath && \
pipx install appimage-builder
COPY build/AppImageBuilder.yml .
pipx install appimage-builder
COPY +upend-cli/bin AppDir/usr/bin/upend
COPY --dir +webui/dist AppDir/usr/share/upend/webui
COPY assets/upend.png AppDir/usr/share/icons/upend.png
# COPY +get-version/version.txt .
# RUN export LINUXDEPLOY_OUTPUT_VERSION="$(cat version.txt)" ;\
# linuxdeploy-x86_64.AppImage --appdir appdir -d build/upend.desktop --output appimage
COPY build/AppImageBuilder.yml .
RUN sed -e "s/latest/$(./AppDir/usr/bin/upend --version | cut -d ' ' -f 2)/" -i AppImageBuilder.yml
RUN pipx run appimage-builder
SAVE ARTIFACT UpEnd* AS LOCAL dist/

View File

@ -1,9 +0,0 @@
#!/bin/sh
git_tag=$(git describe --tags --exact-match HEAD 2>/dev/null)
if [ -z "$git_tag" ]; then
echo "dev_$(git rev-parse --short HEAD)"
else
echo "$git_tag" | sed -e 's/^v//g'
fi

View File

@ -7,7 +7,7 @@ edition = "2021"
[dependencies]
upend-base = { path = "../base" }
upend-db = { path = "../db" }
clap = { version = "4.2.4", features = ["derive", "env", "color"] }
clap = { version = "4.2.4", features = ["derive", "env", "color", "string", "cargo"] }
log = "0.4"
tracing = "0.1"
@ -87,7 +87,7 @@ bytes = "1.4.0"
signal-hook = "0.3.15"
[build-dependencies]
shadow-rs = { version = "0.23", default-features = false }
shadow-rs = { version = "0.23" }
[features]
default = [

View File

@ -1,3 +1,4 @@
fn main() -> shadow_rs::SdResult<()> {
println!("cargo:rustc-env=GIT_TAG={}", shadow_rs::tag());
shadow_rs::new()
}

View File

@ -5,7 +5,7 @@ use crate::common::{get_static_dir, REQWEST_ASYNC_CLIENT};
use crate::config::UpEndConfig;
use actix_web::HttpServer;
use anyhow::Result;
use clap::{Args, Parser, Subcommand, ValueEnum};
use clap::{Args, CommandFactory, FromArgMatches, Parser, Subcommand, ValueEnum};
use filebuffer::FileBuffer;
use rand::{thread_rng, Rng};
use regex::Captures;
@ -40,7 +40,7 @@ mod extractors;
mod previews;
#[derive(Debug, Parser)]
#[command(name = "upend", author, version)]
#[command(name = "upend", author)]
struct Cli {
#[command(subcommand)]
command: Commands,
@ -179,7 +179,14 @@ struct ServeArgs {
#[actix_web::main]
async fn main() -> Result<()> {
let args = Cli::parse();
let upend_version = if env!("GIT_TAG").is_empty() {
format!("dev-{}", common::build::SHORT_COMMIT)
} else {
env!("GIT_TAG")[1..].to_string() // Remove the leading 'v'
};
let command = Cli::command().version(upend_version);
let args = Cli::from_arg_matches(&command.get_matches())?;
tracing_subscriber::fmt()
.with_env_filter(