]> xenbits.xensource.com Git - xen-guest-agent.git/commitdiff
ci/deb: publish APT repository as a gitlab "generic package"
authorYann Dirson <yann.dirson@vates.fr>
Tue, 12 Dec 2023 16:21:32 +0000 (17:21 +0100)
committerYann Dirson <yann.dirson@vates.fr>
Thu, 14 Dec 2023 08:55:21 +0000 (09:55 +0100)
This ought to be used as sources.list entry to access the repo, but
for some reason `apt-get update` gets HTTP 400 on Packages file,
whereas curl fetches it all right.

 deb [trusted=yes] https://gitlab.com/api/v4/projects/xen-project%252Fxen-guest-agent/packages/generic/deb-amd64/ci/ ./

Signed-off-by: Yann Dirson <yann.dirson@vates.fr>
.gitlab-ci.yml
CHANGELOG.md

index 99d47a56d76fac0a0c8bc3eeecf01bcf125f5cb2..4af84355499fe883ec794914be6d7be2d0655664 100644 (file)
@@ -1,6 +1,7 @@
 stages:
   - build
   - package
+  - deploy
 
 # prevent duplicate pipelines for merge request
 workflow:
@@ -12,6 +13,7 @@ workflow:
 
 variables:
   LINUX_RUSTIMG: "rust:buster"
+  PKG_ROOT: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic"
 
 .build-template:
   stage: build
@@ -197,11 +199,16 @@ pkg-deb-amd64:
 
     # repository metadata
     - cd target/release
+
+    # mangle names to avoid chars rejected by the gitlab package registry,
+    # see https://gitlab.com/gitlab-org/gitlab/-/issues/413517
+    - for FILE in *.deb; do mv $FILE $(echo $FILE | tr "~" "-"); done
+
     - apt-ftparchive generate ../../apt-ftparchive.conf
     - apt-ftparchive release .
-      -o APT::FTPArchive::Release::Description="xen-guest-agent CI packages"
+      -o APT::FTPArchive::Release::Description="xen-guest-agent CI packages for ${CI_COMMIT_REF_NAME}"
       -o APT::FTPArchive::Release::Label="xen-guest-agent-ci"
-      -o APT::FTPArchive::Release::Suite="ci"
+      -o APT::FTPArchive::Release::Suite="${CI_COMMIT_REF_NAME}"
       > Release.part
     - mv Release.part Release
   artifacts:
@@ -210,6 +217,27 @@ pkg-deb-amd64:
       - target/release/*Release*
       - target/release/Packages*
       - target/release/Contents-*
+    reports:
+      # propagates variables into the pipeline level
+      dotenv: version.env
+
+# The artifact repo does not seem to work well as an APT source, APT
+# gets HTP 400 on Packages for some reason, so deploy it to a package
+# repository instead.
+deploy-deb-amd64:
+  stage: deploy
+  needs:
+    - pkg-deb-amd64
+  image: "curlimages/curl:latest"
+  script:
+    - cd target/release
+    - for FILE in *; do
+    -   echo "uploading '$FILE'"
+    -   >
+        curl --header "JOB-TOKEN: $CI_JOB_TOKEN"
+        --upload-file "$FILE"
+        "${PKG_ROOT}/deb-amd64/${CI_COMMIT_REF_NAME}/${FILE}"
+    - done
 
 pkg-rpm-x86_64:
   stage: package
index 61ce9ff365e9f343f0a33a17453268d65221a5cd..056248da8ca20380b9457d9bfd28e7301108ce03 100644 (file)
@@ -27,6 +27,8 @@ Changelog](https://keepachangelog.com/en/1.0.0/)
 * executables and packages for supported guest platforms (currently
   Linux/Glibc and FreeBSD, both for x86_64 guests) are now available
   from Gitlab CI pipelines
+* APT repositories (though not signed) are now available from Gitlab
+  CI pipelines
 * CI pipelines now testbuild every commit in a merge request
 
 ## 0.2.0 - 2023-10-11