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 Oct 5, 2024
1 parent edd6fb8 commit 63f877a
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_lts_arches = [
Expand Down Expand Up @@ -78,20 +84,20 @@ def update_debian():
arch_case += f" {arch.dpkg}) rustArch='{arch.rust}'; rustupSha256='{hash}' ;; \\\n"
arch_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.name) \
.replace("%%ARCH-CASE%%", arch_case)
write_file(f"{rust_version}/{variant.name}/Dockerfile", rendered)
write_file(f"{channel.name}/{variant.name}/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.name) \
.replace("%%ARCH-CASE%%", arch_case)
write_file(f"{rust_version}/{variant.name}/slim/Dockerfile", rendered)
write_file(f"{channel.name}/{variant.name}/slim/Dockerfile", rendered)

def update_alpine():
arch_case = 'apkArch="$(apk --print-arch)"; \\\n'
Expand All @@ -105,21 +111,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 @@ -198,7 +204,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 @@ -238,7 +244,7 @@ def generate_stackbrew_library():
library += single_library(
tags,
map(lambda a: a.bashbrew, arches),
os.path.join(stable_rust_version, variant.name))
os.path.join(stable.name, variant.name))

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

for version in alpine_versions:
tags = []
Expand All @@ -267,7 +273,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 63f877a

Please sign in to comment.