Skip to content

Commit

Permalink
Add package publishing workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Athanaseus committed Dec 6, 2023
1 parent df865e9 commit 826ed43
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/publish_package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# This workflows will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: Upload Python Package

on:
push:
tags:
- '**'

env:
POETRY_VERSION: 1.4.0

jobs:
deploy:
runs-on: ubuntu-latest
# Run on a push to a tag or master
if: >
github.event_name == 'push' &&
(startsWith(github.event.ref, 'refs/tags') ||
github.event.ref == 'refs/heads/master')
steps:
- name: Set up Python 3
uses: actions/setup-python@v3
with:
python-version: '3.x'

- name: Install latest setuptools, wheel, pip
run: python3 -m pip install -U pip setuptools wheel

- name: Cache Installations
id: cache-installs
uses: actions/cache@v3
with:
path: ~/.local
key: install-${{ env.INSTALL_CACHE_HASH }}-3

- name: Install Poetry
if: steps.cache-installs.outputs.cache-hit != 'true'
run: |
curl -sSL https://install.python-poetry.org | python3 - --version ${{ env.POETRY_VERSION }}
- name: Test poetry
run: poetry --version

- name: Checkout source
uses: actions/checkout@v3
with:
fetch-depth: 1

- name: Install rfinder
run: poetry install

- name: Build distribution
run: poetry build

- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
continue-on-error: true

- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@master
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}

0 comments on commit 826ed43

Please sign in to comment.