From 0dd98315e5896841e53ef43ac22188646eec7aac Mon Sep 17 00:00:00 2001 From: Salt Date: Sat, 22 May 2021 00:07:13 -0500 Subject: [PATCH] Testing an alternative approach to the CI --- .dockerignore | 1 + .gitlab-ci.yml | 44 ++------------------------------------------ build.sh | 29 +++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 42 deletions(-) create mode 100755 build.sh diff --git a/.dockerignore b/.dockerignore index da05bcb..900a9a3 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,3 +3,4 @@ .gitignore .gitlab-ci.yml README.md +build.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a4088f5..6dd5bd2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,14 +10,13 @@ variables: CI_PROJECT_NAME: minecraft-forge stages: - build -# - test - - push services: - docker:dind before_script: - echo -n "$CI_LOGIN_PASSWORD" | docker login -u "$CI_LOGIN_USERNAME" --password-stdin - docker version - docker info + - apk add bash after_script: - docker logout hub.docker.com @@ -25,43 +24,4 @@ after_script: Build: stage: build script: - - docker pull $CI_HUB_USERNAME/$CI_PROJECT_NAME:latest || true - - docker buildx create --use - - > - docker buildx build - --pull - --platform linux/amd64 - --cache-from $CI_HUB_USERNAME/$CI_PROJECT_NAME:latest - --tag $CI_HUB_USERNAME/$CI_PROJECT_NAME:$CI_COMMIT_SHORT_SHA - --push - . - - docker images - -# PUSH -Push_When_Tag: - stage: push - only: - - tags - script: - - docker pull $CI_HUB_USERNAME/$CI_PROJECT_NAME:$CI_COMMIT_SHORT_SHA - - > - docker tag - $CI_HUB_USERNAME/$CI_PROJECT_NAME:$CI_COMMIT_SHORT_SHA - $CI_HUB_USERNAME/$CI_PROJECT_NAME:$CI_COMMIT_REF_NAME - - > - docker tag - $CI_HUB_USERNAME/$CI_PROJECT_NAME:$CI_COMMIT_SHORT_SHA - $CI_HUB_USERNAME/$CI_PROJECT_NAME:latest - - docker images - - docker push $CI_HUB_USERNAME/$CI_PROJECT_NAME:$CI_COMMIT_REF_NAME - - docker push $CI_HUB_USERNAME/$CI_PROJECT_NAME:latest -Push_Bleeding: - stage: push - script: - - docker pull $CI_HUB_USERNAME/$CI_PROJECT_NAME:$CI_COMMIT_SHORT_SHA - - > - docker tag - $CI_HUB_USERNAME/$CI_PROJECT_NAME:$CI_COMMIT_SHORT_SHA - $CI_HUB_USERNAME/$CI_PROJECT_NAME:bleeding - - docker images - - docker push $CI_HUB_USERNAME/$CI_PROJECT_NAME:bleeding + - bash build.sh diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..4f39038 --- /dev/null +++ b/build.sh @@ -0,0 +1,29 @@ +#! /bin/bash +# +# Build the Docker image for a series of different Forge versions +# + +# MC version list +declare -a mcversions=( + "1.12.2" + "1.16.5" +) + +# Forge version dictionary (we only support one version per) +declare -A forgeversions=( + ["1.12.2"]="14.23.5.2855" + ["1.16.5"]="36.1.23" +) + +# Build images +docker buildx create --use +for mc in ${mcversions[@]}; do + forge="${forgeversions[$mc]}" + echo "Building image for Minecraft $mc, Forge $forge, CI_COMMIT_REF_NAME of $CI_COMMIT_REF_NAME" + docker buildx build \ + --platform linux/amd64 \ + --tag "$CI_HUB_USERNAME/$CI_PROJECT_NAME:$mc-$forge-${CI_COMMIT_REF_NAME:=bleeding}" \ + --push \ + . +done +docker images