Skip to content

Commit d24a49f

Browse files
committed
Minor fixes (#876)
* fix(backend): lowercase all headers * ci: supply app version as env variable * build(backend): add `dotenvy_macro` deps * build: change to common version * feat(backend): handle version variable correctly * ci: exit early if env variable does not exist
1 parent 18f1a82 commit d24a49f

File tree

9 files changed

+32
-8
lines changed

9 files changed

+32
-8
lines changed

.github/workflows/release.yml

+4
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ jobs:
9595
script: |
9696
const repoName = context.payload.repository.name;
9797
const refName = context.ref.replace('refs/tags/', '');
98+
core.setOutput('APP_VERSION', refName);
99+
98100
const dockerHubActor = process.env.DOCKER_USERNAME;
99101
const ghcrRegistry = process.env.GHCR_REGISTRY;
100102
const ghcrActor = context.actor;
@@ -125,6 +127,8 @@ jobs:
125127
platforms: linux/amd64,linux/arm64
126128
push: true
127129
tags: ${{ steps.required_args.outputs.image_names }}
130+
build-args: |
131+
APP_VERSION=${{ steps.required_args.outputs.APP_VERSION }}
128132
129133
upload-kodi-plugin:
130134
runs-on: ubuntu-20.04

Cargo.lock

+15-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,16 @@ RUN cargo chef prepare --recipe-path recipe.json
3232

3333
FROM backend-chef AS backend-builder
3434
ARG TARGETARCH
35+
ARG APP_VERSION
3536
ARG BUILD_PROFILE=release
3637
ENV RUST_TARGET_TRIPLE_arm64="aarch64-unknown-linux-gnu"
3738
ENV RUST_TARGET_TRIPLE_amd64="x86_64-unknown-linux-gnu"
3839
ENV TARGET_CC="clang"
3940
ENV TARGET_AR="llvm-ar"
4041
ENV CFLAGS_aarch64_unknown_linux_gnu="--sysroot=/usr/aarch64-linux-gnu"
4142
ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
43+
ENV APP_VERSION=$APP_VERSION
44+
RUN test -n "$APP_VERSION"
4245
COPY --from=backend-planner /app/recipe.json recipe.json
4346
RUN rustup target add $(eval "echo \$RUST_TARGET_TRIPLE_$TARGETARCH")
4447
RUN cargo chef cook --profile $BUILD_PROFILE --target $(eval "echo \$RUST_TARGET_TRIPLE_$TARGETARCH") --recipe-path recipe.json

apps/backend/Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ryot"
3-
version = "6.2.3"
3+
version = "0.1.0"
44
edition = "2021"
55
repository = "https://github.com/IgnisDa/ryot"
66
license = "GPL-3.0"
@@ -30,6 +30,7 @@ derive_more = { version = "=1.0.0-beta.6", features = [
3030
"add_assign",
3131
], default-features = false }
3232
dotenvy = "=0.15.7"
33+
dotenvy_macro = "=0.15.7"
3334
enum_meta = "=0.7.0"
3435
flate2 = "=1.0.30"
3536
futures = "=0.3.30"

apps/backend/src/providers/igdb.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ async fn get_client(config: &config::VideoGameConfig) -> Client {
650650
URL,
651651
Some(vec![
652652
(
653-
HeaderName::from_static("Client-ID"),
653+
HeaderName::from_static("client-id"),
654654
HeaderValue::from_str(&config.twitch.client_id).unwrap(),
655655
),
656656
(

apps/backend/src/providers/listennotes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ async fn get_client_config(url: &str, api_token: &str) -> (Client, Settings) {
272272
let client = get_base_http_client(
273273
url,
274274
Some(vec![(
275-
HeaderName::from_static("X-ListenAPI-Key"),
275+
HeaderName::from_static("x-listenapi-key"),
276276
HeaderValue::from_str(api_token).unwrap(),
277277
)]),
278278
);

apps/backend/src/providers/mal.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ async fn get_client_config(url: &str, client_id: &str) -> Client {
133133
get_base_http_client(
134134
url,
135135
Some(vec![(
136-
HeaderName::from_static("X-MAL-CLIENT-ID"),
136+
HeaderName::from_static("x-mal-client-id"),
137137
HeaderValue::from_str(client_id).unwrap(),
138138
)]),
139139
)

apps/backend/src/utils.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ use crate::{
4343
};
4444

4545
pub static BASE_DIR: &str = env!("CARGO_MANIFEST_DIR");
46-
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
46+
#[cfg(debug_assertions)]
47+
pub const VERSION: &str = dotenvy_macro::dotenv!("APP_VERSION");
48+
#[cfg(not(debug_assertions))]
49+
pub const VERSION: &str = env!("APP_VERSION");
4750
pub const AUTHOR: &str = "ignisda";
4851
pub const AUTHOR_EMAIL: &str = "ignisda2001@gmail.com";
4952
pub const USER_AGENT_STR: &str = const_str::concat!(

libs/rs-utils/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rs-utils"
3-
version = "0.0.0"
3+
version = "0.1.0"
44
edition = "2021"
55

66
[dependencies]

0 commit comments

Comments
 (0)