Skip to content

Commit

Permalink
feat: automatically generate a Docker source
Browse files Browse the repository at this point in the history
  • Loading branch information
Serial-ATA committed Nov 20, 2024
1 parent 46b1785 commit 5025de9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/verify-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ jobs:
--define flakes=true
--define docker=true
--define base-image="rustlang/rust:nightly"
--define docker-registry="docker.io"
--define ci=true
--define rust-ci=true
--define release-ci=true
--define release-ci=false
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
Expand Down
9 changes: 9 additions & 0 deletions Cargo.toml → Cargo.toml.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ path = "src/main.rs"

[package.metadata.blueprint]
manager = { Evm = "HelloBlueprint" }
{%- if release-ci %}

[[package.metadata.gadget.Native.sources]]
owner = "{{gh-username}}"
Expand All @@ -50,3 +51,11 @@ binaries = [
{ arch = "Amd64", os = "Linux", name = "amd64-linux-{{project-name}}-gadget" },
{ arch = "Arm64", os = "Linux", name = "arm64-linux-{{project-name}}-gadget" },
]
{%- endif %}
{%- if docker %}

[[package.metadata.gadget.Container.sources]]
registry = "{{docker-registry}}"
image = "{{gh-username}}/{{project-name}}"
tag = "0.1.0"
{%- endif %}
11 changes: 10 additions & 1 deletion hooks/pre.rhai
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ if !check_bool("flakes") {
}

if !variable::is_set("docker") {
let docker = variable::prompt("Do you want to generate a Dockerfile for your gadget?", true);
let docker = variable::prompt("Do you want to deploy your gadget with Docker?", true);
variable::set("docker", docker);
}

Expand All @@ -43,6 +43,11 @@ if check_bool("docker") {
let base_image = variable::prompt("What base image should be used?", "rustlang/rust:nightly");
variable::set("base-image", base_image);
}

if !variable::is_set("docker-registry") {
let registry = variable::prompt("What registry will you be deploying to?", "docker.io");
variable::set("docker-registry", registry);
}
} else {
file::delete("./Dockerfile");
}
Expand Down Expand Up @@ -72,4 +77,8 @@ if !check_bool("release-ci") {
file::delete("./.github/workflows/release.yml");
}

if variable::is_set("docker-registry") || check_bool("release-ci") {
print("\x1b[1m(\x1b[31m!!!\x1b[39m) A native and/or Docker source has been configured. Be sure to check Cargo.toml to ensure they are correct.")
}

file::delete("./hooks");

0 comments on commit 5025de9

Please sign in to comment.