Skip to content

Commit

Permalink
Update python-package.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
TheGreatCodeholio authored May 14, 2024
1 parent 322945a commit 914b3ef
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,61 @@ name: Build and Publish

on:
push:
tags:
- 'v*'
branches: [ "main" ]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10', '3.11']
outputs:
version: ${{ steps.get_version.outputs.version }}
steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'

python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Extract version from pyproject.toml
id: get_version
run: echo "::set-output name=version::$(python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])")"

- name: Build package
run: python -m build

- name: Publish package
if: github.ref == 'refs/heads/main' && matrix.python-version == '3.10'
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: twine upload dist/*

release:
needs: build
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Download Artifacts
uses: actions/download-artifact@v2
with:
name: package
path: dist

- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ needs.build.outputs.version }}
name: Release ${{ needs.build.outputs.version }}
files: dist/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 914b3ef

Please sign in to comment.