Skip to content

Commit

Permalink
refactor: Don't change folder on version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
Muscraft committed Sep 5, 2024
1 parent 9f28728 commit 3b55c81
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ jobs:
steps:
- uses: actions/checkout@v4
- run: git clone https://github.com/docker-library/official-images.git ~/official-images
- run: docker build -t rust:$RUST_VERSION-${{ matrix.name }} $RUST_VERSION/${{ matrix.variant }}
- run: docker build -t rust:$RUST_VERSION-${{ matrix.name }} stable/${{ matrix.variant }}
- run: ~/official-images/test/run.sh rust:$RUST_VERSION-${{ matrix.name }}
- run: docker images
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
36 changes: 21 additions & 15 deletions x.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@
import subprocess
import sys

stable_rust_version = "1.81.0"
supported_rust_versions = [stable_rust_version, "nightly"]
rustup_version = "1.27.1"

Channel = namedtuple("Channel", ["name", "rust_version"])
stable = Channel("stable", "1.81.0")
nightly = Channel("nightly", "nightly")
supported_channels = [
stable,
nightly
]

DebianArch = namedtuple("DebianArch", ["bashbrew", "dpkg", "qemu", "rust"])

debian_arches = [
Expand Down Expand Up @@ -75,20 +81,20 @@ def update_debian():
case = arch_case
case += end

for rust_version in supported_rust_versions:
for channel in supported_channels:
rendered = template \
.replace("%%RUST-VERSION%%", rust_version) \
.replace("%%RUST-VERSION%%", channel.rust_version) \
.replace("%%RUSTUP-VERSION%%", rustup_version) \
.replace("%%DEBIAN-SUITE%%", variant) \
.replace("%%ARCH-CASE%%", case)
write_file(f"{rust_version}/{variant}/Dockerfile", rendered)
write_file(f"{channel.name}/{variant}/Dockerfile", rendered)

rendered = slim_template \
.replace("%%RUST-VERSION%%", rust_version) \
.replace("%%RUST-VERSION%%", channel.rust_version) \
.replace("%%RUSTUP-VERSION%%", rustup_version) \
.replace("%%DEBIAN-SUITE%%", variant) \
.replace("%%ARCH-CASE%%", case)
write_file(f"{rust_version}/{variant}/slim/Dockerfile", rendered)
write_file(f"{channel.name}/{variant}/slim/Dockerfile", rendered)

def update_alpine():
arch_case = 'apkArch="$(apk --print-arch)"; \\\n'
Expand All @@ -102,21 +108,21 @@ def update_alpine():
template = read_file("Dockerfile-alpine.template")

for version in alpine_versions:
for rust_version in supported_rust_versions:
for channel in supported_channels:
rendered = template \
.replace("%%RUST-VERSION%%", rust_version) \
.replace("%%RUST-VERSION%%", channel.rust_version) \
.replace("%%RUSTUP-VERSION%%", rustup_version) \
.replace("%%TAG%%", version) \
.replace("%%ARCH-CASE%%", arch_case)
write_file(f"{rust_version}/alpine{version}/Dockerfile", rendered)
write_file(f"{channel.name}/alpine{version}/Dockerfile", rendered)

def update_ci():
file = ".github/workflows/ci.yml"
config = read_file(file)

marker = "#RUST_VERSION\n"
split = config.split(marker)
rendered = split[0] + marker + f" RUST_VERSION: {stable_rust_version}\n" + marker + split[2]
rendered = split[0] + marker + f" RUST_VERSION: {stable.rust_version}\n" + marker + split[2]

versions = ""
for variant in debian_variants:
Expand Down Expand Up @@ -195,7 +201,7 @@ def file_commit(file):
.strip()

def version_tags():
parts = stable_rust_version.split(".")
parts = stable.rust_version.split(".")
tags = []
for i in range(len(parts)):
tags.append(".".join(parts[:i + 1]))
Expand Down Expand Up @@ -235,7 +241,7 @@ def generate_stackbrew_library():
library += single_library(
tags,
map(lambda a: a.bashbrew, arches),
os.path.join(stable_rust_version, variant))
os.path.join(stable.name, variant))

tags = []
for version_tag in version_tags():
Expand All @@ -249,7 +255,7 @@ def generate_stackbrew_library():
library += single_library(
tags,
map(lambda a: a.bashbrew, arches),
os.path.join(stable_rust_version, variant, "slim"))
os.path.join(stable.name, variant, "slim"))

for version in alpine_versions:
tags = []
Expand All @@ -264,7 +270,7 @@ def generate_stackbrew_library():
library += single_library(
tags,
map(lambda a: a.bashbrew, alpine_arches),
os.path.join(stable_rust_version, f"alpine{version}"))
os.path.join(stable.name, f"alpine{version}"))

print(library)

Expand Down

0 comments on commit 3b55c81

Please sign in to comment.