Verified Commit 623005fd authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Update GitLab-CI config

parent 6e713678
Loading
Loading
Loading
Loading
+32 −16
Original line number Diff line number Diff line
@@ -3,18 +3,17 @@
# SAFETY_API_KEY:
#   Set to your API key for accessing up-to-date package security information

stages:
- build
- test
- publish


workflow:
  rules:
  - if: $CI_PIPELINE_SOURCE == "merge_request_event"
  - if: $CI_OPEN_MERGE_REQUESTS
  - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
    when: never
  - when: always
  - if: $CI_PIPELINE_SOURCE == "merge_request_event"
  - if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$$/
    variables:
      PUSH_PACKAGE: "true"
  - if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+/
  - if: $CI_COMMIT_BRANCH


.python:
@@ -44,7 +43,6 @@ Pin:
  # Pin dependencies in requirements.txt for reproducing pipeline results
  stage: test
  extends: [.python]
  needs: []
  script:
  - pip install --prefer-binary -e .
  - pip freeze --exclude-editable | tee requirements.txt
@@ -62,7 +60,7 @@ Dependency Check:


Code Checks:
  stage: test
  stage: .pre
  image: docker.kodo.org.uk/ci-images/pre-commit:2.15.0-1
  needs: []
  variables:
@@ -108,7 +106,7 @@ Check Tag:
  extends: [.python]
  needs: ["Build Package"]
  rules:
  - if: $CI_COMMIT_TAG =~ /^v[0-9]/
  - if: $CI_COMMIT_TAG
  script:
  - pip install packaging pkginfo
  - |
@@ -119,16 +117,17 @@ Check Tag:

    wheel_path = glob("dist/*.whl")[0]
    wheel = Wheel(wheel_path)
    assert Version("$CI_COMMIT_TAG") == Version(wheel.version)
    assert Version("$CI_COMMIT_TAG").release == Version(wheel.version).release, \
      f"Pkg version {wheel.version} does not match tag"
    END


Upload Package:
  stage: publish
Upload Package (Test):
  stage: deploy
  extends: [.python]
  needs: ["Build Package"]
  dependencies: ["Build Package"]
  rules:
  - if: $CI_COMMIT_TAG =~ /^v[0-9]/
  - if: $CI_COMMIT_TAG
  script:
  - pip install twine
  - TWINE_USERNAME=gitlab-ci-token
@@ -138,3 +137,20 @@ Upload Package:
    --non-interactive
    --repository-url $CI_API_V4_URL/projects/$CI_PROJECT_ID/packages/pypi
    dist/*


Upload Package (PyPI):
  stage: deploy
  extends: [.python]
  dependencies: ["Build Package"]
  rules:
  - if: $PYPI_TOKEN && $PUSH_PACKAGE
    when: manual
  script:
  - pip install twine
  - TWINE_USERNAME=__token__
    TWINE_PASSWORD=$PYPI_TOKEN
    twine upload
    --verbose
    --non-interactive
    dist/*