Testing an alternative approach to the CI

This commit is contained in:
Salt 2021-05-22 00:07:13 -05:00
parent 5be6e30444
commit 0dd98315e5
3 changed files with 32 additions and 42 deletions

View File

@ -3,3 +3,4 @@
.gitignore
.gitlab-ci.yml
README.md
build.sh

View File

@ -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

29
build.sh Executable file
View File

@ -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