Skip to content

Commit

Permalink
Merge pull request #19 from MarinerQ/feature/pypi_publish
Browse files Browse the repository at this point in the history
Add gitlab publish to pypi
  • Loading branch information
PartlyFluked authored Sep 28, 2023
2 parents d92540f + a9d9f47 commit 6596ae3
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ stages:

include:
- local: '/.gitlab/ci/check-semver.yaml'
- local: '/.gitlab/ci/publish.yaml'
56 changes: 56 additions & 0 deletions .gitlab/ci/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
.publish:
stage: deploy
image: python:3.10.2-bullseye

# Change pip's cache directory to be inside the project directory since we can
# only cache local items.
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"

# Pip's cache doesn't store the python packages
# https://pip.pypa.io/en/stable/topics/caching/
#
# If you want to also cache the installed packages, you have to install
# them in a virtualenv and cache it as well.
cache:
paths:
- .cache/pip
- venv/
before_script:
- python --version # For debugging
- pip install virtualenv
- virtualenv venv
- source venv/bin/activate
- python setup.py bdist_wheel
# an alternative approach is to install and run:
- pip install dist/*
# run the command here
- pip install build twine
- python -m build
artifacts:
paths:
- dist/*.whl

gitlab-publish:
extends:
- .publish
script:
- TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=gitlab-ci-token python -m twine upload --repository-url ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi dist/*
rules:
- if: ($CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH == "dev")

test-pypi-publish:
extends:
- .publish
script:
- TWINE_PASSWORD=${TEST_PYPI_TOKEN} TWINE_USERNAME=__token__ python -m twine upload --repository testpypi dist/*
rules:
- if: $CI_COMMIT_BRANCH == "dev"

pypi-publish:
extends:
- .publish
script:
- TWINE_PASSWORD=${PYPI_TOKEN} TWINE_USERNAME=__token__ python -m twine upload dist/*
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

setup(
name='sealgw',
version="0.0.2",
version="0.0.3",
description='SealGW: SEmi-Analytical Localization for Gravitational Waves',
author='Qian Hu',
author_email='[email protected]',
Expand Down

0 comments on commit 6596ae3

Please sign in to comment.