2023-11-11 04:44:07 +00:00
|
|
|
image: python:3.11-slim
|
2023-01-27 09:47:59 +00:00
|
|
|
|
|
|
|
variables:
|
|
|
|
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
|
2023-01-27 11:05:34 +00:00
|
|
|
PACKAGE_VERSION: $CI_COMMIT_TAG
|
2023-07-14 12:46:49 +00:00
|
|
|
ADDON_PACKAGE: "TA-malware-filter-${PACKAGE_VERSION}.tar.gz"
|
2023-02-06 06:40:51 +00:00
|
|
|
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${CI_PROJECT_NAME}/${PACKAGE_VERSION}"
|
2023-01-27 11:05:34 +00:00
|
|
|
|
|
|
|
stages:
|
|
|
|
- test
|
|
|
|
- build
|
|
|
|
- upload
|
|
|
|
- release
|
2023-01-27 09:47:59 +00:00
|
|
|
|
|
|
|
lint:
|
|
|
|
stage: test
|
|
|
|
|
2023-11-11 04:47:56 +00:00
|
|
|
variables:
|
|
|
|
PRE_COMMIT_HOME: ${CI_PROJECT_DIR}/.cache/pre-commit
|
|
|
|
|
2023-01-27 09:47:59 +00:00
|
|
|
cache:
|
|
|
|
paths:
|
|
|
|
- .cache/pip
|
|
|
|
- .venv/
|
2023-11-11 04:47:56 +00:00
|
|
|
- ${PRE_COMMIT_HOME}
|
2023-01-27 09:47:59 +00:00
|
|
|
|
|
|
|
before_script:
|
2023-11-11 04:47:56 +00:00
|
|
|
- apt-get update && apt-get install -y --no-install-recommends git
|
2023-01-27 09:47:59 +00:00
|
|
|
- python --version
|
|
|
|
- python -m venv .venv
|
|
|
|
- source .venv/bin/activate
|
|
|
|
- pip install -r requirements-dev.txt -U
|
|
|
|
|
|
|
|
script:
|
2023-11-11 04:47:56 +00:00
|
|
|
- pre-commit run --all-files
|
2023-01-27 09:47:59 +00:00
|
|
|
|
|
|
|
build:
|
|
|
|
stage: build
|
|
|
|
|
|
|
|
script:
|
|
|
|
- python --version
|
|
|
|
- python build.py
|
|
|
|
|
|
|
|
artifacts:
|
|
|
|
paths:
|
2023-07-14 12:46:49 +00:00
|
|
|
- TA-malware-filter-*.tar.gz
|
2023-01-27 09:47:59 +00:00
|
|
|
expire_in: 30 days
|
2023-01-27 11:05:34 +00:00
|
|
|
|
|
|
|
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}
|
2023-01-31 10:08:27 +00:00
|
|
|
sha256sum "$ADDON_PACKAGE" > "${ADDON_PACKAGE}.sha256sum"
|
|
|
|
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file "${ADDON_PACKAGE}.sha256sum" "${PACKAGE_REGISTRY_URL}/${ADDON_PACKAGE}.sha256sum"
|
2023-01-27 11:05:34 +00:00
|
|
|
|
|
|
|
release_job:
|
|
|
|
stage: release
|
|
|
|
image: registry.gitlab.com/gitlab-org/release-cli:latest
|
|
|
|
rules:
|
2023-11-11 04:44:07 +00:00
|
|
|
# Run this job when a tag is created manually
|
|
|
|
- if: $CI_COMMIT_TAG
|
2023-01-27 11:05:34 +00:00
|
|
|
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}"
|
2023-01-31 10:08:27 +00:00
|
|
|
- name: ${ADDON_PACKAGE}.sha256sum
|
|
|
|
url: "${PACKAGE_REGISTRY_URL}/${ADDON_PACKAGE}.sha256sum"
|