splunk-malware-filter/.gitlab-ci.yml

71 lines
1.7 KiB
YAML

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
cache:
paths:
- .cache/pip
- .venv/
before_script:
- python --version
- python -m venv .venv
- source .venv/bin/activate
- pip install -r requirements-dev.txt -U
script:
- pylint $(find -type f -name "*.py" ! -path "./.venv/**" ! -path "./lib/**")
build:
stage: build
script:
- python --version
- python build.py
artifacts:
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}
sha256sum "$ADDON_PACKAGE" > "${ADDON_PACKAGE}.sha256sum"
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file "${ADDON_PACKAGE}.sha256sum" "${PACKAGE_REGISTRY_URL}/${ADDON_PACKAGE}.sha256sum"
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}"
- name: ${ADDON_PACKAGE}.sha256sum
url: "${PACKAGE_REGISTRY_URL}/${ADDON_PACKAGE}.sha256sum"