Skip to content

Commit

Permalink
Upload release to Test PyPI and install from it before deploying to P…
Browse files Browse the repository at this point in the history
…yPI (#48)

* Deploy to Test PyPI and test before final deploy

* Install twine

* Advance package version

* Fix typo

* Move release action to master

* Upload and downlaod artifacts

* Fix indentation

* Sleep so that Test PyPI can update

* New version

* Increase sleep and move it to the job before

* Prepare PR
  • Loading branch information
davidtvs authored Jun 11, 2020
1 parent 883f06f commit 67467c6
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 19 deletions.
96 changes: 78 additions & 18 deletions .github/workflows/release_n_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,81 @@ name: release-n-deploy
on:
push:
tags:
- "v*.*" # Trigger on push with tags matching aversion, e.g.: v1.0, v0.1.5
- "v*.*" # Trigger on push with tags matching a version, e.g.: v1.0, v0.1.5

jobs:
deploy-test-pypi:
name: Deploy to Test PyPI
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: "3.x"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build
run: python setup.py sdist bdist_wheel

- name: Twine check
run: twine check dist/*

- name: Upload package artifacts
uses: actions/upload-artifact@master
with:
name: package-artifacts
path: dist/

- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.test_pypi_password }}
repository_url: https://test.pypi.org/legacy/

# Sleep for some seconds to give Test PyPI time to update the search index
- name: Sleep for 120 seconds
uses: jakejarvis/wait-action@master
with:
time: '120s'

verify-test-pypi:
name: Install from Test PyPI
runs-on: ubuntu-latest
needs: [deploy-test-pypi]

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: "3.x"

- name: Get release version
id: release_version
run: |
echo ::set-output name=number::${GITHUB_REF#refs/*/}
echo ${{ steps.release_version.outputs.number }}
- name: Install torch-lr-finder ${{ steps.release_version.outputs.number }} from Test PyPI
run: |
python -m pip install --upgrade pip
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple torch-lr-finder==${{ steps.release_version.outputs.number }}
release:
name: Create Release
runs-on: ubuntu-latest
needs: [verify-test-pypi]

steps:
- name: Checkout repository
Expand Down Expand Up @@ -40,7 +109,7 @@ jobs:
echo "::set-output name=content::$notes"
- name: Create draft release
uses: actions/create-release@v1
uses: actions/create-release@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand All @@ -52,29 +121,20 @@ jobs:
draft: true
prerelease: false

deploy:
deploy-pypi:
name: Deploy to PyPI
runs-on: ubuntu-latest
needs: [verify-test-pypi]

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v1
- name: Download package artifacts
uses: actions/download-artifact@master
with:
python-version: "3.x"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel
- name: Build
run: python setup.py sdist bdist_wheel
name: package-artifacts
path: dist/

- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@v1.1.0
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.pypi_password }}
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
]
)


with open("README.md", "r") as f:
long_description = f.read()

Expand Down

0 comments on commit 67467c6

Please sign in to comment.