From 04470343aa6dd5542c6f368212fd8f05089ef510 Mon Sep 17 00:00:00 2001
From: nd <git@notandy.de>
Date: Fri, 26 Nov 2021 00:29:36 +0100
Subject: [PATCH] move mirror publishing to shared ci file

---
 .gitlab-ci.yml | 30 +++++++++++++-----------------
 1 file changed, 13 insertions(+), 17 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index b111041..39c8e59 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -46,23 +46,19 @@ package:apt:bullseye:
   - build:binary:bullseye
 
 # for now, publish the bullseye package for buster as well
-publish:apt:
-  extends: .publish
-  script:
-  - echo "${CI_COMMIT_TAG}" | grep -qE "v[0-9]+[.][0-9]+[.][0-9]+.*" && export PACKAGE_VERSION="${CI_COMMIT_TAG#v}" || export PACKAGE_VERSION="${CI_COMMIT_SHA}"
-  - export DEBPATH="$(echo *.deb)"
-  - echo Ensure aptly repo exists
-  - 'curl --user "${APTLY_API_USER}:${APTLY_API_PW}" -X POST -H "Content-Type: application/json" --data "{\"Name\": \"${APT_REPO}\"}" "${APT_API_URL}/api/repos"'
-  - echo Upload deb file, add it to repo and clean up upload
-  - curl --user "${APTLY_API_USER}:${APTLY_API_PW}" -X POST -F file=@"$DEBPATH" "${APT_API_URL}/api/files/${APT_REPO}-ci-upload-${CI_JOB_ID}"
-  - curl --user "${APTLY_API_USER}:${APTLY_API_PW}" -X POST "${APT_API_URL}/api/repos/${APT_REPO}/file/${APT_REPO}-ci-upload-${CI_JOB_ID}"
-  - curl --user "${APTLY_API_USER}:${APTLY_API_PW}" -X DELETE "${APT_API_URL}/api/files/${APT_REPO}-ci-upload-${CI_JOB_ID}"
-  - echo Ensure aptly repo is published for all distros
-  - 'curl --user "${APTLY_API_USER}:${APTLY_API_PW}" -X POST -H "Content-Type: application/json" --data "{\"SourceKind\": \"local\", \"Sources\": [{\"Name\": \"${APT_REPO}\"}], \"Architectures\": [\"amd64\"], \"Distribution\": \"buster\"}" "${APT_API_URL}/api/publish/${APT_REPO}"'
-  - 'curl --user "${APTLY_API_USER}:${APTLY_API_PW}" -X POST -H "Content-Type: application/json" --data "{\"SourceKind\": \"local\", \"Sources\": [{\"Name\": \"${APT_REPO}\"}], \"Architectures\": [\"amd64\"], \"Distribution\": \"bullseye\"}" "${APT_API_URL}/api/publish/${APT_REPO}"'
-  - echo Update published repo for all distros
-  - 'curl --user "${APTLY_API_USER}:${APTLY_API_PW}" -X PUT -H "Content-Type: application/json" --data "{ }" "${APT_API_URL}/api/publish/${APT_REPO}/buster"'
-  - 'curl --user "${APTLY_API_USER}:${APTLY_API_PW}" -X PUT -H "Content-Type: application/json" --data "{ }" "${APT_API_URL}/api/publish/${APT_REPO}/bullseye"'
+publish:apt:buster:
+  extends: .publish:apt:
+  variables:
+    APTLY_DISTRO: buster
+  dependencies:
+  - package:apt:bullseye
+  needs:
+  - package:apt:bullseye
+
+publish:apt:bullseye:
+  extends: .publish:apt:
+  variables:
+    APTLY_DISTRO: bullseye
   dependencies:
   - package:apt:bullseye
   needs:
-- 
GitLab