Skip to content

Commit

Permalink
Merge pull request #78 from enoch3712/77-split-workflows-publish-only…
Browse files Browse the repository at this point in the history
…-triggered-by-admin

new workflows
  • Loading branch information
enoch3712 authored Nov 20, 2024
2 parents d9cf9ca + 68a9b16 commit 5ac8881
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 23 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/manual-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Manual PyPI Publish

on:
workflow_dispatch:
inputs:
version:
description: 'Version to publish (optional)'
required: false
type: string

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

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

- name: Install dependencies
run: |
pip install poetry
poetry install
- name: Update version if provided
if: inputs.version != ''
run: poetry version ${{ inputs.version }}

- name: Build package
run: poetry build

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@v1.4.2
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
23 changes: 0 additions & 23 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,6 @@ jobs:
- name: Build package
run: poetry build

- name: Check version change
id: check_version
run: |
git fetch origin main
# Extract version from current pyproject.toml
current_version=$(poetry version -s)
# Extract version from main branch pyproject.toml
main_version=$(git show origin/main:pyproject.toml | grep "^version = " | cut -d'"' -f2)
if [ "$current_version" != "$main_version" ]; then
echo "Version changed from $main_version to $current_version"
echo "version_changed=true" >> $GITHUB_OUTPUT
else
echo "Version unchanged"
echo "version_changed=false" >> $GITHUB_OUTPUT
fi
- name: Publish to PyPI
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.check_version.outputs.version_changed == 'true'
uses: pypa/gh-action-pypi-publish@v1.4.2
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}

test-python-versions:
name: Test Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
Expand Down

0 comments on commit 5ac8881

Please sign in to comment.