Skip to content

Commit

Permalink
Added pypi release github actions (#148)
Browse files Browse the repository at this point in the history
* Added pypi release github actions
  • Loading branch information
tarunmenon95 authored Apr 27, 2023
1 parent 032ece3 commit 87ffef6
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 33 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: PyPI Release

on:
release:
types: [created]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install wheel twine
pip install -r requirements.txt
- name: Build distribution package
run: |
python setup.py sdist bdist_wheel
- name: Upload to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
twine upload dist/*
33 changes: 33 additions & 0 deletions .github/workflows/publish-to-test-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Test PyPI Release

on:
push:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install wheel twine
pip install -r requirements.txt
- name: Build distribution package
run: |
python setup.py sdist bdist_wheel
- name: Upload to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
run: |
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
- name: Install package from TestPyPI
run: |
python -m pip install --index-url https://test.pypi.org/simple/ --no-deps shelvery
33 changes: 0 additions & 33 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -108,39 +108,6 @@ pipeline {
}
}
}

stage('Release PyPI'){
when {
branch 'master'
}
steps {
input 'Release to PyPI'
script {
withCredentials([usernamePassword(credentialsId: '/ci2/jenkins/credentials/base2-pypi', usernameVariable: 'PYPICREDS_USR', passwordVariable: 'PYPICREDS_PSW')]) {
sh """#!/bin/bash
cat << EOT > /root/.pypirc
[distutils]
index-servers =
pypi
pypitest
[pypi]
repository=https://pypi.org/pypi
username=\${PYPICREDS_USR}
password=\${PYPICREDS_PSW}
EOT
python setup.py sdist upload -r pypi
"""
}
}
}
post {
success {
slackSend color: '#00FF00', channel: '#base2-tool-releases', message: "<https://pypi.python.org/pypi/shelvery|New Shelvery Release on PyPI>"
}
}
}

}

Expand Down

0 comments on commit 87ffef6

Please sign in to comment.