From 5b2365e925af11e5f010ef3d9de9e585d0519153 Mon Sep 17 00:00:00 2001 From: kemitix Date: Thu, 9 Jan 2025 17:26:55 +0000 Subject: [PATCH] build: build and publish image nightly Removes need to update toolchain for every action step --- .forgejo/workflows/build-image.yml | 18 +++++++++++++++++ Dockerfile | 9 +++++++++ entrypoint.sh | 5 ----- update.sh | 32 ++++++++++++++++++++++++++++++ 4 files changed, 59 insertions(+), 5 deletions(-) create mode 100644 .forgejo/workflows/build-image.yml create mode 100755 update.sh diff --git a/.forgejo/workflows/build-image.yml b/.forgejo/workflows/build-image.yml new file mode 100644 index 0000000..452dd89 --- /dev/null +++ b/.forgejo/workflows/build-image.yml @@ -0,0 +1,18 @@ +on: + schedule: + - cron: '30 1 * * *' + workflow_dispatch: + +jobs: + build: + runs-on: docker + + steps: + - name: Checkout + uses: actions/checkoutv4 + + - name: Build + run: docker build . -t git.kemitix.net/kemitix/rust:latest + + - name: Publish + run: docker push git.kemitix.net/kemitix/rust:latest diff --git a/Dockerfile b/Dockerfile index 1a51982..6abceb7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,7 @@ FROM docker.io/rust:1.84.0-slim-bookworm +LABEL org.opencontainers.image.source=https://git.kemitix.net/kemitix/rust + # nodejs - runtime used by forgejo/github actions # curl - to download cargo-binstall # clang-16 & mold - faster linkers for rust @@ -25,6 +27,13 @@ RUN cargo binstall -y \ cargo-mutants@25.0 \ release-plz@0.3 +COPY update.sh / + +# should be a no-op if the FROM line is up-to-date +RUN /update.sh stable + +RUN /update.sh nightly + COPY entrypoint.sh / RUN git config --global user.email "action@git.kemitix.net" && \ diff --git a/entrypoint.sh b/entrypoint.sh index 195dda1..7971454 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -26,11 +26,6 @@ if [[ "${ARGS[0]}" == v1* ]]; then fi echo "Selected toolchain: ${TOOLCHAIN}" -echo ">>> Update toolchain" -rustup update "${TOOLCHAIN}" -echo ">>> Install rustfmt and clippy" -rustup component add --toolchain "${TOOLCHAIN}" rustfmt clippy - if test "${ARGS[0]}" == "cargo";then PRE_COMMAND="cargo +${TOOLCHAIN} " else diff --git a/update.sh b/update.sh new file mode 100755 index 0000000..957870d --- /dev/null +++ b/update.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +set -e + +echo "INPUT_ARGS: ${INPUT_ARGS}" + +# split input into an array +read -ra ARGS <<<"${INPUT_ARGS}" + +# default toolchain +TOOLCHAIN="stable" +echo "Default toolchain: ${TOOLCHAIN}" + +# if first parameter is 'nightly'... +if test "${ARGS[0]}" == "nightly"; then + TOOLCHAIN="nightly" + ARGS=("${ARGS[@]:1}") +fi +if test "${ARGS[0]}" == "stable"; then + TOOLCHAIN="stable" # redundant as this is the default + ARGS=("${ARGS[@]:1}") +fi +if [[ "${ARGS[0]}" == v1* ]]; then + TOOLCHAIN="${ARGS[0]:1}" + ARGS=("${ARGS[@]:1}") +fi +echo "Selected toolchain: ${TOOLCHAIN}" + +echo ">>> Update toolchain" +rustup update "${TOOLCHAIN}" +echo ">>> Install rustfmt and clippy" +rustup component add --toolchain "${TOOLCHAIN}" rustfmt clippy