Skip to content

fix: set cli version from tag build #64

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/cli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ permissions:

env:
PROJECT_NAME: cli
VERSION: ${{ github.ref_name }}

jobs:
build:
Expand All @@ -29,12 +30,12 @@ jobs:
uses: actions/checkout@v3

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4
with:
targets: "${{ matrix.target }}"

- name: Setup Cache for Cargo
uses: Swatinem/rust-cache@v2
uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6

- name: Build Binary
run: cargo build -p ${PROJECT_NAME} --verbose --locked --release --target ${{ matrix.target }}
Expand Down Expand Up @@ -78,7 +79,7 @@ jobs:
path: ./cli-releases

- name: Create GitHub Release and Upload Assets
uses: softprops/action-gh-release@v2
uses: softprops/action-gh-release@da05d552573ad5aba039eaac05058a918a7bf631
with:
files: ./cli-releases/** # Upload all binaries as release assets
env:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/docker-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ jobs:
version: ${{ github.ref_name }}
image_name: cli
folder: cli
env:
VERSION: ${{ github.ref_name }}
secrets:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,6 @@ jobs:
find dist/ -name '*.whl' -exec cp {} dist_collected/ \;

- name: Publish release distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc
with:
packages-dir: dist_collected/
1 change: 1 addition & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "cli"
version = "0.1.0"
edition = "2021"
license-file = "../LICENSE"
build = "build.rs"

[dependencies]
clap = "3.0"
Expand Down
3 changes: 3 additions & 0 deletions cli/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
FROM rust:1.82-alpine AS builder

ARG VERSION
ENV VERSION=${VERSION}

RUN apk add --no-cache \
build-base \
musl-dev \
Expand Down
4 changes: 4 additions & 0 deletions cli/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
fn main() {
let ver = std::env::var("VERSION").unwrap_or_else(|_| env!("CARGO_PKG_VERSION").to_string());
println!("cargo:rustc-env=APP_VERSION={}", ver);
}
8 changes: 4 additions & 4 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@ use log::{error, info};

#[tokio::main]
async fn main() {
setup_logging().unwrap();
initialize_project_id_and_region().await;

let matches = App::new("CLI App")
.version("0.1.0")
.version(env!("APP_VERSION"))
.author("InfraWeave <opensource@infraweave.com>")
.about("Handles all InfraWeave CLI operations")
.subcommand(
Expand Down Expand Up @@ -362,6 +359,9 @@ async fn main() {
)
.get_matches();

setup_logging().unwrap();
initialize_project_id_and_region().await;

match matches.subcommand() {
Some(("module", module_matches)) => match module_matches.subcommand() {
Some(("publish", run_matches)) => {
Expand Down
Loading