Include git based version
Some checks failed
Build and deploy / Build container and manifests (push) Failing after 4m26s
Some checks failed
Build and deploy / Build container and manifests (push) Failing after 4m26s
This commit is contained in:
parent
d602220c4b
commit
1776dbda16
2
.cargo/config.toml
Normal file
2
.cargo/config.toml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[env]
|
||||||
|
RUSTC_BOOTSTRAP = "1"
|
|
@ -17,17 +17,13 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
fetch-tags: true
|
|
||||||
|
|
||||||
# TODO: Actually set an env variable and use it in the application
|
- name: Set timestamp and release version
|
||||||
- name: Set version string
|
|
||||||
run: |
|
run: |
|
||||||
git describe --always --dirty="-modified"
|
echo "TIMESTAMP=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV
|
||||||
|
git fetch --prune --unshallow --tags --force
|
||||||
- name: Get Git commit timestamps
|
echo "RELEASE_VERSION=$(git describe --always --dirty='--modified')" >> $GITHUB_ENV
|
||||||
run: echo "TIMESTAMP=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV
|
cat $GITHUB_ENV
|
||||||
|
|
||||||
- name: Login to registry
|
- name: Login to registry
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
|
@ -72,6 +68,8 @@ jobs:
|
||||||
annotations: ${{ steps.meta.outputs.annotations }}
|
annotations: ${{ steps.meta.outputs.annotations }}
|
||||||
cache-from: type=gha
|
cache-from: type=gha
|
||||||
cache-to: type=gha,mode=max
|
cache-to: type=gha,mode=max
|
||||||
|
build-args: |
|
||||||
|
"RELEASE_VERSION=${{ env.RELEASE_VERSION }}"
|
||||||
env:
|
env:
|
||||||
SOURCE_DATE_EPOCH: ${{ env.TIMESTAMP }}
|
SOURCE_DATE_EPOCH: ${{ env.TIMESTAMP }}
|
||||||
|
|
||||||
|
|
21
Cargo.lock
generated
21
Cargo.lock
generated
|
@ -97,6 +97,7 @@ dependencies = [
|
||||||
"color-eyre",
|
"color-eyre",
|
||||||
"dotenvy",
|
"dotenvy",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
|
"git-version",
|
||||||
"k8s-openapi",
|
"k8s-openapi",
|
||||||
"kube",
|
"kube",
|
||||||
"schemars",
|
"schemars",
|
||||||
|
@ -555,6 +556,26 @@ version = "0.28.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253"
|
checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "git-version"
|
||||||
|
version = "0.3.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1ad568aa3db0fcbc81f2f116137f263d7304f512a1209b35b85150d3ef88ad19"
|
||||||
|
dependencies = [
|
||||||
|
"git-version-macro",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "git-version-macro"
|
||||||
|
version = "0.3.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "53010ccb100b96a67bc32c0175f0ed1426b31b655d562898e57325f81c023ac0"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gloo-timers"
|
name = "gloo-timers"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
|
|
|
@ -8,6 +8,7 @@ default-run = "authelia-controller"
|
||||||
color-eyre = "0.6.3"
|
color-eyre = "0.6.3"
|
||||||
dotenvy = "0.15.7"
|
dotenvy = "0.15.7"
|
||||||
futures-util = "0.3.31"
|
futures-util = "0.3.31"
|
||||||
|
git-version = "0.3.9"
|
||||||
k8s-openapi = { version = "0.24.0", features = ["v1_31"] }
|
k8s-openapi = { version = "0.24.0", features = ["v1_31"] }
|
||||||
kube = { version = "0.99.0", features = ["derive", "runtime"] }
|
kube = { version = "0.99.0", features = ["derive", "runtime"] }
|
||||||
schemars = "0.8.22"
|
schemars = "0.8.22"
|
||||||
|
|
|
@ -13,7 +13,8 @@ COPY --from=planner /app/recipe.json recipe.json
|
||||||
RUN cargo chef cook --release --recipe-path recipe.json
|
RUN cargo chef cook --release --recipe-path recipe.json
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
ENV RUSTC_BOOTSTRAP=1
|
ARG RELEASE_VERSION
|
||||||
|
ENV RELEASE_VERSION=${RELEASE_VERSION}
|
||||||
RUN cargo auditable build --release
|
RUN cargo auditable build --release
|
||||||
|
|
||||||
FROM gcr.io/distroless/cc-debian12:nonroot AS runtime
|
FROM gcr.io/distroless/cc-debian12:nonroot AS runtime
|
||||||
|
|
|
@ -1,2 +1,6 @@
|
||||||
|
#![feature(let_chains)]
|
||||||
pub mod context;
|
pub mod context;
|
||||||
pub mod resources;
|
pub mod resources;
|
||||||
|
mod version;
|
||||||
|
|
||||||
|
pub use version::VERSION;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
|
use authelia_controller::VERSION;
|
||||||
use authelia_controller::context::Context;
|
use authelia_controller::context::Context;
|
||||||
use authelia_controller::resources::AccessControlRule;
|
use authelia_controller::resources::AccessControlRule;
|
||||||
use color_eyre::eyre::Context as _;
|
use color_eyre::eyre::Context as _;
|
||||||
|
@ -39,7 +40,7 @@ async fn main() -> color_eyre::Result<()> {
|
||||||
})
|
})
|
||||||
.unwrap_or(Ok(15))?;
|
.unwrap_or(Ok(15))?;
|
||||||
|
|
||||||
info!("Starting");
|
info!(version = VERSION, "Starting");
|
||||||
|
|
||||||
let client = Client::try_default().await?;
|
let client = Client::try_default().await?;
|
||||||
let access_control_rules = Api::<AccessControlRule>::all(client.clone());
|
let access_control_rules = Api::<AccessControlRule>::all(client.clone());
|
||||||
|
|
11
src/version.rs
Normal file
11
src/version.rs
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
pub const VERSION: &str = get_version();
|
||||||
|
|
||||||
|
const fn get_version() -> &'static str {
|
||||||
|
if let Some(version) = std::option_env!("RELEASE_VERSION")
|
||||||
|
&& !version.is_empty()
|
||||||
|
{
|
||||||
|
version
|
||||||
|
} else {
|
||||||
|
git_version::git_version!(fallback = "unknown")
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user