[Notes] [Git][BuildStream/buildstream][chandan/automate-pypi-release] .gitlab-ci.yml: Publish to PyPI when new tags are pushed



Title: GitLab

Chandan Singh pushed to branch chandan/automate-pypi-release at BuildStream / buildstream

Commits:

1 changed file:

Changes:

  • .gitlab-ci.yml
    ... ... @@ -14,6 +14,9 @@ variables:
    14 14
       PYTEST_ADDOPTS: "--color=yes"
    
    15 15
       INTEGRATION_CACHE: "${CI_PROJECT_DIR}/cache/integration-cache"
    
    16 16
       TEST_COMMAND: 'python3 setup.py test --index-url invalid://uri --addopts --integration'
    
    17
    +  TEST_PYPI_UPLOAD_URL: "https://test.pypi.org/legacy/"
    
    18
    +  TEST_PYPI_INDEX_URL: "https://test.pypi.org/simple/"
    
    19
    +  PYPI_UPLOAD_URL: "https://upload.pypi.org/legacy/"
    
    17 20
     
    
    18 21
     #####################################################
    
    19 22
     #                  Prepare stage                    #
    
    ... ... @@ -323,3 +326,33 @@ pages:
    323 326
       - master
    
    324 327
       except:
    
    325 328
       - schedules
    
    329
    +
    
    330
    +# Release to PyPI, only for tags.
    
    331
    +#
    
    332
    +# TODO: To begin with, we only upload to test.pypi. Later we should also push
    
    333
    +# to real PyPI after verifying that it can be installed correctly.
    
    334
    +#
    
    335
    +pypi_release:
    
    336
    +  stage: post
    
    337
    +  dependencies:
    
    338
    +  - source_dist
    
    339
    +  script:
    
    340
    +  - |
    
    341
    +    if [[ ! "$CI_COMMIT_TAG" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
    
    342
    +        echo "Not processing non-numeric tag: $CI_COMMIT_TAG for PyPI"
    
    343
    +        exit
    
    344
    +    fi
    
    345
    +    minor_version="$(echo "$CI_COMMIT_TAG" | cut -d. -f2)"
    
    346
    +    if [[ "$(( minor_version %2 ))" -ne 0 ]]; then
    
    347
    +        echo "Not uploading development release: $CI_COMMIT_TAG to PyPI"
    
    348
    +        exit
    
    349
    +    fi
    
    350
    +
    
    351
    +    # Credentials for PyPI are defined in secret CI variables "TWINE_USERNAME"
    
    352
    +    # and "TWINE_PASSWORD".
    
    353
    +    pip3 install twine
    
    354
    +    twine upload --repository-url "$TEST_PYPI_UPLOAD_URL" dist/*.tar.gz
    
    355
    +    pip3 install --extra-index-url "$TEST_PYPI_INDEX_URL" "BuildStream==$CI_COMMIT_TAG"
    
    356
    +    bst --version
    
    357
    +  only:
    
    358
    +  - tags



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]