ci: publish release and asset
- https://gitlab.com/gitlab-org/release-cli/-/tree/master/docs/examples/release-assets-as-generic-package - https://docs.gitlab.com/ee/ci/yaml/#release - https://stackoverflow.com/a/29521646 - https://docs.gitlab.com/ee/user/packages/generic_packages/index.html#publish-a-generic-package-by-using-cicd
This commit is contained in:
parent
22d1b7e8f5
commit
391fa177f6
|
@ -2,6 +2,15 @@ image: python:slim
|
|||
|
||||
variables:
|
||||
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
|
||||
PACKAGE_VERSION: $CI_COMMIT_TAG
|
||||
ADDON_PACKAGE: "malware_filter-${PACKAGE_VERSION}.tar.gz"
|
||||
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${CI_PROJECT_NAME}/${PACKAGE_VERSION}"
|
||||
|
||||
stages:
|
||||
- test
|
||||
- build
|
||||
- upload
|
||||
- release
|
||||
|
||||
lint:
|
||||
stage: test
|
||||
|
@ -31,3 +40,27 @@ build:
|
|||
paths:
|
||||
- malware_filter-*.tar.gz
|
||||
expire_in: 30 days
|
||||
|
||||
upload:
|
||||
stage: upload
|
||||
image: curlimages/curl:latest
|
||||
rules:
|
||||
- if: $CI_COMMIT_TAG
|
||||
script:
|
||||
- |
|
||||
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file ${ADDON_PACKAGE} ${PACKAGE_REGISTRY_URL}/${ADDON_PACKAGE}
|
||||
|
||||
release_job:
|
||||
stage: release
|
||||
image: registry.gitlab.com/gitlab-org/release-cli:latest
|
||||
rules:
|
||||
- if: $CI_COMMIT_TAG # Run this job when a tag is created manually
|
||||
script:
|
||||
- echo "Running the release job."
|
||||
release:
|
||||
tag_name: $CI_COMMIT_TAG
|
||||
description: $CI_COMMIT_TAG
|
||||
assets:
|
||||
links:
|
||||
- name: ${ADDON_PACKAGE}
|
||||
url: "${PACKAGE_REGISTRY_URL}/${ADDON_PACKAGE}"
|
||||
|
|
18
build.py
18
build.py
|
@ -16,10 +16,20 @@ def version():
|
|||
"""
|
||||
|
||||
commit_sha = (
|
||||
# gitlab
|
||||
environ.get("CI_COMMIT_SHORT_SHA")
|
||||
# github
|
||||
or environ.get("GITHUB_SHA", "")[0:8]
|
||||
(
|
||||
# gitlab
|
||||
environ.get("CI_COMMIT_TAG")
|
||||
or environ.get("CI_COMMIT_SHORT_SHA")
|
||||
# github
|
||||
or (
|
||||
environ.get("GITHUB_REF_NAME")
|
||||
if environ.get("GITHUB_REF_TYPE") == "tag"
|
||||
else None
|
||||
)
|
||||
or environ.get("GITHUB_SHA", "")[0:8]
|
||||
)
|
||||
if environ.get("CI") == "true"
|
||||
else None
|
||||
)
|
||||
if commit_sha:
|
||||
return commit_sha
|
||||
|
|
Loading…
Reference in New Issue