From 4c643b18dd3bf276a039a556a2b34a7e71f77cea Mon Sep 17 00:00:00 2001 From: Oscar Krause Date: Tue, 27 Dec 2022 12:49:12 +0100 Subject: [PATCH] .gitlab-ci.yml - implemented deploy stage for debian package --- .gitlab-ci.yml | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index eae130a..69ce698 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -86,7 +86,7 @@ test:debian: - apt-get purge -qq -y fastapi-dls - apt-get autoremove -qq -y && apt-get clean -qq -deploy: +deploy:docker: stage: deploy rules: - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH @@ -107,3 +107,35 @@ deploy: - docker build . --tag $PUBLIC_REGISTRY_USER/${CI_PROJECT_NAME}:latest - docker push $PUBLIC_REGISTRY_USER/${CI_PROJECT_NAME}:${VERSION} - docker push $PUBLIC_REGISTRY_USER/${CI_PROJECT_NAME}:latest + +deploy:debian: + image: debian:bookworm-slim + stage: deploy + rules: + - if: $CI_COMMIT_BRANCH == "debian" # $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + needs: + - job: build:debian + artifacts: true + before_script: + - apt-get update -qq && apt-get install -qq -y curl + script: + # Naming format: _-_.deb + # Version is the version number of the app being packaged + # Release number is the version number of the *packaging* itself. + # The release number might increment if the package maintainer + # updated the packaging, while the version number of the application + # being packaged did not change. + - BUILD_NAME=build.deb # inherited by build-stage + - PACKAGE_NAME=`dpkg -I build/build.deb | grep "Package:" | awk '{ print $2 }'` + - PACKAGE_VERSION=`dpkg -I build/build.deb | grep "Version:" | awk '{ print $2 }'` + - PACKAGE_ARCH=amd64 + - EXPORT_NAME="${PACKAGE_NAME}_${PACKAGE_VERSION}-0_${PACKAGE_ARCH}.deb" + - mv ${BUILD_NAME} ${EXPORT_NAME} + - 'echo "PACKAGE_NAME: ${PACKAGE_NAME}"' + - 'echo "PACKAGE_VERSION: ${PACKAGE_VERSION}"' + - 'echo "PACKAGE_ARCH: ${PACKAGE_ARCH}"' + - 'echo "EXPORT_NAME: ${EXPORT_NAME}"' + # https://docs.gitlab.com/14.3/ee/user/packages/debian_repository/index.html + - URL="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/debian/${EXPORT_NAME}" + - 'echo "URL: ${URL}"' + - 'curl --request PUT --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file ${EXPORT_NAME} ${URL}'