From 87ffef660e4eb574af0653f03ae63de7bf5e1199 Mon Sep 17 00:00:00 2001 From: Tarun Menon <64295670+tarunmenon95@users.noreply.github.com> Date: Thu, 27 Apr 2023 12:43:34 +1000 Subject: [PATCH] Added pypi release github actions (#148) * Added pypi release github actions --- .github/workflows/publish-to-pypi.yml | 29 +++++++++++++++++++ .github/workflows/publish-to-test-pypi.yml | 33 ++++++++++++++++++++++ Jenkinsfile | 33 ---------------------- 3 files changed, 62 insertions(+), 33 deletions(-) create mode 100644 .github/workflows/publish-to-pypi.yml create mode 100644 .github/workflows/publish-to-test-pypi.yml diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml new file mode 100644 index 0000000..4af5888 --- /dev/null +++ b/.github/workflows/publish-to-pypi.yml @@ -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/* \ No newline at end of file diff --git a/.github/workflows/publish-to-test-pypi.yml b/.github/workflows/publish-to-test-pypi.yml new file mode 100644 index 0000000..3290da5 --- /dev/null +++ b/.github/workflows/publish-to-test-pypi.yml @@ -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 diff --git a/Jenkinsfile b/Jenkinsfile index 010eb25..055cbbb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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: "" - } - } - } }