Skip to content

Commit

Permalink
refactor: use tag as version
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrpdev committed Sep 10, 2024
1 parent 5fbaf71 commit 33a7a42
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 42 deletions.
31 changes: 23 additions & 8 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,38 @@ jobs:
DRY_RUN: true

- name: Static build (ARM64)
run: RUSTFLAGS='-C target-feature=+crt-static' cargo build --locked --release --target=aarch64-unknown-linux-gnu
run: cargo build --locked --release --target=aarch64-unknown-linux-gnu
env:
RUSTFLAGS: "-C target-feature=+crt-static"
RSPI_BIOS_VERSION: ${{ steps.tag-dry.outputs.new_tag }}

- name: Static build (ARMv7)
run: RUSTFLAGS='-C target-feature=+crt-static' cargo build --locked --release --target=armv7-unknown-linux-gnueabihf
run: cargo build --locked --release --target=armv7-unknown-linux-gnueabihf
env:
RUSTFLAGS: "-C target-feature=+crt-static"
RSPI_BIOS_VERSION: ${{ steps.tag-dry.outputs.new_tag }}

- name: Static deb build (ARM64)
run: RUSTFLAGS='-C target-feature=+crt-static' cargo deb --deb-version ${{ steps.tag-dry.outputs.new_tag }} --locked --target=aarch64-unknown-linux-gnu
run: cargo deb --deb-version $RSPI_BIOS_VERSION --locked --target=aarch64-unknown-linux-gnu
env:
RUSTFLAGS: "-C target-feature=+crt-static"
RSPI_BIOS_VERSION: ${{ steps.tag-dry.outputs.new_tag }}

- name: Static deb build (ARMv7)
run: RUSTFLAGS='-C target-feature=+crt-static' cargo deb --deb-version ${{ steps.tag-dry.outputs.new_tag }} --locked --target=armv7-unknown-linux-gnueabihf
run: cargo deb --deb-version $RSPI_BIOS_VERSION --locked --target=armv7-unknown-linux-gnueabihf
env:
RUSTFLAGS: "-C target-feature=+crt-static"
RSPI_BIOS_VERSION: ${{ steps.tag-dry.outputs.new_tag }}

- name: Rename binaries
run: |
cp target/aarch64-unknown-linux-gnu/release/rspi-bios ./rspi-bios_${{ steps.tag-dry.outputs.new_tag }}_aarch64-unknown-linux-gnu
cp target/armv7-unknown-linux-gnueabihf/release/rspi-bios ./rspi-bios_${{ steps.tag-dry.outputs.new_tag }}_armv7-unknown-linux-gnueabihf
cp target/aarch64-unknown-linux-gnu/debian/rspi-bios_${{ steps.tag-dry.outputs.new_tag }}_arm64.deb ./rspi-bios_${{ steps.tag-dry.outputs.new_tag }}_arm64.deb
cp target/armv7-unknown-linux-gnueabihf/debian/rspi-bios_${{ steps.tag-dry.outputs.new_tag }}_armhf.deb ./rspi-bios_${{ steps.tag-dry.outputs.new_tag }}_armhf.deb
cp target/aarch64-unknown-linux-gnu/release/rspi-bios ./rspi-bios_$RSPI_BIOS_VERSION_aarch64-unknown-linux-gnu
cp target/armv7-unknown-linux-gnueabihf/release/rspi-bios ./rspi-bios_$RSPI_BIOS_VERSION_armv7-unknown-linux-gnueabihf
cp target/aarch64-unknown-linux-gnu/debian/rspi-bios_$RSPI_BIOS_VERSION_arm64.deb ./rspi-bios_$RSPI_BIOS_VERSION_arm64.deb
cp target/armv7-unknown-linux-gnueabihf/debian/rspi-bios_$RSPI_BIOS_VERSION_armhf.deb ./rspi-bios_$RSPI_BIOS_VERSION_armhf.deb
env:
RSPI_BIOS_VERSION: ${{ steps.tag-dry.outputs.new_tag }}


- name: Tag (Real run)
id: tag-real
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rspi-bios"
version = "1.0.0"
version = "1.0.0-dev"
authors = ["Piotr Placzek <[email protected]>"]
edition = "2021"
rust-version = "1.74"
Expand Down
28 changes: 2 additions & 26 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,4 @@
use std::process::Command;

// https://stackoverflow.com/a/44407625/19020549

#[allow(clippy::unnecessary_wraps)]
fn try_main() -> Result<(), Box<dyn std::error::Error>> {
let Ok(output) = Command::new("git")
.args(["rev-parse", "--short", "HEAD"])
.output()
else {
return Err("Failed to get current Git commit using command".into());
};

let Ok(git_hash) = String::from_utf8(output.stdout) else {
return Err("Failed to convert Git output to UTF-8 string".into());
};

println!("cargo:rustc-env=GIT_HASH={git_hash}");

Ok(())
}

fn main() {
if let Err(e) = try_main() {
eprintln!("Error: {e:#?}");
std::process::exit(1)
}
let version = std::env::var("RSPI_BIOS_VERSION").unwrap_or_else(|_| "dev".to_string());
println!("cargo:rustc-env=RSPI_BIOS_VERSION={version}");
}
10 changes: 5 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
use sysinfo::{Disks, Networks, ProcessesToUpdate, System};

#[derive(Parser, Debug)]
#[command(version = env!("GIT_HASH"), about)]
#[command(version = env!("RSPI_BIOS_VERSION"), about)]
struct Args {
#[arg(long, value_parser = parse_duration, default_value = "5")]
system_refresh_interval: Duration,
Expand Down Expand Up @@ -171,9 +171,9 @@ async fn main() {
}
tracing::info!("Logging to {log_path:?}");
tracing::debug!(
"Running {} built from Git commit {}",
"Running {} version {}",
env!("CARGO_CRATE_NAME"),
env!("GIT_HASH")
env!("RSPI_BIOS_VERSION")
);

tracing::info!("Creating TLS config");
Expand Down Expand Up @@ -269,7 +269,7 @@ struct IndexTemplate {
process_count: usize,
rx: u64,
tx: u64,
git_hash: String,
version: String,
os_version: String,
cpu_arch: String,
}
Expand Down Expand Up @@ -372,7 +372,7 @@ async fn index_handler(
process_count,
rx: total_rx,
tx: total_tx,
git_hash: env!("GIT_HASH").to_string(),
version: env!("RSPI_BIOS_VERSION").to_string(),
os_version: state.os_version.lock().await.to_string(),
cpu_arch: state.cpu_arch.lock().await.to_string(),
};
Expand Down
2 changes: 1 addition & 1 deletion templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
</ul>
<ul>
<li style="margin-left: 0px">
12/05/2023-04/BCM2711/RPI4B-UEFI-{{ git_hash }}
12/05/2023-04/BCM2711/RPI4B-UEFI-{{ version }}
</li>
</ul>
</div>
Expand Down

0 comments on commit 33a7a42

Please sign in to comment.