From bd239c036552c46bb5d6c1fb6920933892e9ddc3 Mon Sep 17 00:00:00 2001 From: Clayton Craft Date: Wed, 22 Feb 2023 17:17:19 -0800 Subject: [PATCH] ci: build vendor tarball and create new release when new tag is pushed This adds two new CI jobs that run when a new tag is pushed to this repo: one to tar up the vendored dependencies and another one to push the tarball as an asset in a new gitlab "release" for the tag. fixes: #5 --- .gitlab-ci.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 07b1f61..5f2ee24 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,10 +5,13 @@ image: alpine:edge variables: GOFLAGS: "-buildvcs=false" + PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/mkinitfs-vendor-${CI_COMMIT_TAG}/${CI_COMMIT_TAG}" stages: - lint - build + - vendor + - release # defaults for "only" # We need to run the CI jobs in a "merge request specific context", if CI is @@ -34,3 +37,27 @@ build: - make artifacts: expire_in: 1 week + +vendor: + stage: vendor + image: alpine:latest + only: + - tags + before_script: + - apk -q add curl go make + script: + - | + make VERSION="${CI_COMMIT_TAG}" vendor + curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file "mkinitfs-vendor-${CI_COMMIT_TAG}.tar.gz" "${PACKAGE_REGISTRY_URL}/" + curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file "mkinitfs-vendor-${CI_COMMIT_TAG}.tar.gz.sha512" "${PACKAGE_REGISTRY_URL}/" + +release: + stage: release + image: registry.gitlab.com/gitlab-org/release-cli:latest + only: + - tags + script: + - | + release-cli create --name "Release $CI_COMMIT_TAG" --tag-name $CI_COMMIT_TAG \ + --assets-link "{\"name\":\"mkinitfs-vendor-${CI_COMMIT_TAG}.tar.gz\",\"url\":\"${PACKAGE_REGISTRY_URL}/mkinitfs-vendor-${CI_COMMIT_TAG}.tar.gz\"}" \ + --assets-link "{\"name\":\"mkinitfs-vendor-${CI_COMMIT_TAG}.tar.gz.sha512\",\"url\":\"${PACKAGE_REGISTRY_URL}/mkinitfs-vendor-${CI_COMMIT_TAG}.tar.gz.sha512\"}"