Created upload stage and job to run before release and upload to package

registry
Release job now links to the package registry
This commit is contained in:
ac
2023-10-30 08:27:14 +10:00
parent 1a2043dcea
commit d5eaab8bbb

View File

@@ -10,10 +10,12 @@ variables:
GIT_SUBMODULE_STRATEGY: normal GIT_SUBMODULE_STRATEGY: normal
GIT_SUBMODULE_FORCE_HTTPS: "true" GIT_SUBMODULE_FORCE_HTTPS: "true"
# GIT_SUBMODULE_UPDATE_FLAGS: --remote --merge # GIT_SUBMODULE_UPDATE_FLAGS: --remote --merge
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/kicad/"
stages: stages:
- gen_mech - gen_mech
- gen_fab - gen_fab
- upload
- release - release
image: image:
@@ -202,10 +204,9 @@ outputs_all:
- !reference [.commands, neo] - !reference [.commands, neo]
- !reference [.commands, merge_libs] - !reference [.commands, merge_libs]
upload_job:
release_job: stage: upload
stage: release image: curlimages/curl:latest
image: registry.gitlab.com/gitlab-org/release-cli:latest
needs: needs:
- job: outputs_all - job: outputs_all
artifacts: true artifacts: true
@@ -213,19 +214,48 @@ release_job:
- if: $CI_COMMIT_TAG - if: $CI_COMMIT_TAG
when: never # Do not run this job when a tag is created manually when: never # Do not run this job when a tag is created manually
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # Run this job when commits are pushed or merged to the default branch - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # Run this job when commits are pushed or merged to the default branch
variables:
FAB_COMM: "curl --header \"JOB-TOKEN: ${CI_JOB_TOKEN}\" --upload-file Fabrication/$d ${PACKAGE_REGISTRY_URL}/$d"
script: script:
- echo "running release_job for $TAG" - |
for f in $(find Fabrication/ \! -type d)
do
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file $f ${PACKAGE_REGISTRY_URL}/$(filename $f)
done
artifacts:
when: always
paths:
- Fabrication/**/*
expire_in: 1 week
release_job:
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
needs:
- job: upload_job
artifacts: true
rules:
- if: $CI_COMMIT_TAG
when: never # Do not run this job when a tag is created manually
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # Run this job when commits are pushed or merged to the default branch
variables:
FAB_COMM: "echo \"--assets-link \"{\"name\":\"$d\",\"url\":\"${PACKAGE_REGISTRY_URL}/$CI_COMMIT_MESSAGE/$d\"}\" \\\""
script:
- |
echo "running release_job for $CI_COMMIT_MESSAGE"
echo "#!/bin/bash" >> fab.sh
echo "release-cli create --name \"Release $CI_COMMIT_MESSAGE\" --tag-name $CI_COMMIT_MESSAGE \\" >> fab.sh
echo "--assets-link \"{\"name\":\"All\",\"url\":\"${PACKAGE_REGISTRY_URL}/$CI_COMMIT_MESSAGE\"}\" \\" >> fab.sh
for d in $(ls -d */)
do
echo "--assets-link \"{\"name\":\"$d\",\"url\":\"${PACKAGE_REGISTRY_URL}/$CI_COMMIT_MESSAGE/$d\"}\" \\" >> fab.sh
done
chmod u+x fab.sh
./fab.sh
artifacts: artifacts:
when: always when: always
name: "$CI_PROJECT_TITLE-$CI_COMMIT_MESSAGE" name: "$CI_PROJECT_TITLE-$CI_COMMIT_MESSAGE"
paths: paths:
- Fabrication/**/* - Fabrication/**/*
expire_in: never expire_in: 1 week
release: # See https://docs.gitlab.com/ee/ci/yaml/#release for available properties
tag_name: '$CI_COMMIT_MESSAGE' # The version is incremented per pipeline.
description: '$CI_COMMIT_MESSAGE'
ref: '$CI_COMMIT_SHA' # The tag is created from the pipeline SHA.
assets:
links:
- name: All Fab
url: "${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/download"