diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9b3957a..e3edf7a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,12 +17,7 @@ check: - apk add --no-cache --upgrade openssh-client bash curl coreutils - git config --global user.email $GIT_USER_EMAIL && git config --global user.name $GIT_USER_NAME - mkdir -p ~/.ssh && echo "$GITLAB_SSH_PRIV_KEY" > ~/.ssh/id_rsa && ssh-keyscan -H git.yrzr.ocry.com > ~/.ssh/known_hosts && chmod -R 0600 ~/.ssh/ - - git fetch --tags - # check version - - if [ -f ./version_list ]; then rm version_list; fi - - curl -s "https://pkg.yrzr.ocry.com" | grep "gitlab-ce_" | sed 's/.*gitlab-ce_\(.*\)_arm64.*/\1/' | sort -rV >> version_list - # create tags - - ./create-tags.sh + - git fetch --tags && ./check-version.sh && ./create-tags.sh - git push --tags https://${GITLAB_USER_LOGIN}:${PERSONAL_ACCESS_TOKEN}@git.yrzr.ocry.com/docker/gitlab-ce-arm64.git build: @@ -40,23 +35,15 @@ build: - docker info script: - apk add --no-cache --upgrade bash coreutils - - REMOTE_VERSION=$(echo $CI_COMMIT_TAG | sed "s/-/+/") && echo ${REMOTE_VERSION} # fetch dockerfile - - git clone -b ${REMOTE_VERSION} --depth=1 https://gitlab.com/gitlab-org/omnibus-gitlab.git + - ./set-branch-name.sh && export BRANCH_NAME=$(cat branch_name) && echo ${BRANCH_NAME} + - git clone -b ${BRANCH_NAME} - cd ./omnibus-gitlab/docker # write RELEASE - - echo "PACKAGECLOUD_REPO=gitlab-ce" > RELEASE - - echo "RELEASE_PACKAGE=gitlab-ce" >> RELEASE - - echo "RELEASE_VERSION=${CI_COMMIT_TAG}" >> RELEASE - - echo "DOWNLOAD_URL=https://${PKG_SERVER_URL}/gitlab-ce_${CI_COMMIT_TAG}_arm64.deb" >> RELEASE - # use ubuntu 20.04 instead of 16.04 - - sed -i 's/16.04/20.04/' ./Dockerfile - # gitlab-ce depends on libatomic1; however: Package libatomic1 is not installed - - sed -i 's/less/less libatomic1/' ./Dockerfile - - docker build -t ${DOCKER_NS}/${BASENAME}:${CI_COMMIT_TAG} -f ./Dockerfile ./ + - echo "PACKAGECLOUD_REPO=gitlab-ce" > RELEASE && echo "RELEASE_PACKAGE=gitlab-ce" >> RELEASE && echo "RELEASE_VERSION=${CI_COMMIT_TAG}" >> RELEASE && echo "DOWNLOAD_URL=https://packages.gitlab.com/gitlab/gitlab-ce/packages/ubuntu/focal/gitlab-ce_${CI_COMMIT_TAG}_arm64.deb/download.deb" >> RELEASE + - docker build -q -t ${DOCKER_NS}/${BASENAME}:${CI_COMMIT_TAG} -f ./Dockerfile ./ # latest tag - - cd ../../ && git fetch --tags && LATEST=$(git tag | sort -rV | head -n 1) - - if [ "${LATEST}" == "${CI_COMMIT_TAG}" ]; then docker tag ${DOCKER_NS}/${BASENAME}:${CI_COMMIT_TAG} ${DOCKER_NS}/${BASENAME}:latest; fi + - cd ../../ && git fetch --tags && ./latest-tag.sh # docker push - docker login --username ${DOCKER_USERNAME} --password ${DOCKER_PASSWORD} - docker images && docker push ${DOCKER_NS}/${BASENAME} diff --git a/check-version.sh b/check-version.sh new file mode 100644 index 0000000..3b3111c --- /dev/null +++ b/check-version.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +SEARCH_PAGES='1' + +if [ -f ./version_list ]; then + rm version_list +fi + +for i in $(seq 1 ${SEARCH_PAGES}); do + curl -s "https://packages.gitlab.com/gitlab/gitlab-ce?page=${i}" | grep "_arm64.deb" | grep -v '\-rc' | sed 's/.*>\(.*\)<.*/\1/' | sort -u | sed 's/gitlab-ce_\(.*\)_arm64.deb/\1/' >> version_list; +done +sort -rVu version_list -o version_list diff --git a/set-branch-name.sh b/set-branch-name.sh new file mode 100644 index 0000000..1c7d734 --- /dev/null +++ b/set-branch-name.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +IFS='.' read -ra NUMS <<< ${CI_COMMIT_TAG} +echo "${NUMS[0]}-${NUMS[1]}-stable" > branch_name