Skip to content

Commit

Permalink
fix(ci): publish to pypi with poetry (#427)
Browse files Browse the repository at this point in the history
* fix(ci): publish to pypi with poetry

* ci: upgrade checkout to v4

* ci: migrate to new step output system

* docs: update python versions

* ci: cleanup previous dev pypi release

* ci: cleanup previous dev pypi release

* ci: cleanup previous dev pypi release

* ci: cleanup previous dev pypi release

* ci: cleanup previous dev pypi release

* ci: apply on master branch
  • Loading branch information
germainlefebvre4 authored Dec 2, 2024
1 parent f90ab6b commit 0c4b0c5
Show file tree
Hide file tree
Showing 10 changed files with 861 additions and 796 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/conventional-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
name: Check compliance
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: chartboost/ruff-action@v1

lint-mkdocs:
name: Lint mkdocs files
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: DavidAnson/markdownlint-cli2-action@v11
with:
glob: 'docs/*.md'
108 changes: 56 additions & 52 deletions .github/workflows/release-feat-dryrun.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ on:
- develop
- feat/*
- fix/*
- ci/*

jobs:
release:
runs-on: ubuntu-latest
outputs:
new_release_version: ${{ steps.version.outputs.new_release_version }}
new_release_published: ${{ steps.version.outputs.new_release_published }}
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4

- name: Semantic Release Config
run: |
Expand All @@ -25,77 +29,77 @@ jobs:
}
'> .releaserc
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v2
uses: cycjimmy/semantic-release-action@v4
id: semantic
with:
branches: 'master'
semantic_version: 19.0.2
branches: ${{ github.head_ref || github.ref_name }}
semantic_version: 21.1.1
extra_plugins: |
@semantic-release/[email protected]
@semantic-release/[email protected]
dry_run: true
ci: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: set release_version
id: set_release_version
uses: noobly314/share-data@v1
with:
share-id: release_version
mode: set
key: version
value: ${{ steps.semantic.outputs.new_release_version }}
- name: set release_published
id: set_release_published
uses: noobly314/share-data@v1
with:
share-id: release_published
mode: set
key: is_published
value: ${{ steps.semantic.outputs.new_release_published }}

- name: Write in summary
run: |
echo "## Semantic Release" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "new_release_version: $NEW_RELEASE_VERSION" >> $GITHUB_STEP_SUMMARY
echo "new_release_published: $NEW_RELEASE_PUBLISHED" >> $GITHUB_STEP_SUMMARY
env:
NEW_RELEASE_VERSION: ${{ steps.semantic.outputs.new_release_version }}
NEW_RELEASE_PUBLISHED: ${{ steps.semantic.outputs.new_release_published }}

- name: Write in outputs
id: version
run: |
echo "NEW_RELEASE_VERSION=$NEW_RELEASE_VERSION" >> $GITHUB_OUTPUT
echo "NEW_RELEASE_PUBLISHED=$NEW_RELEASE_PUBLISHED" >> $GITHUB_OUTPUT
env:
NEW_RELEASE_VERSION: ${{ steps.semantic.outputs.new_release_version }}
NEW_RELEASE_PUBLISHED: ${{ steps.semantic.outputs.new_release_published }}


deploy:
needs: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.7'

- name: get release_version
id: release_version
uses: noobly314/share-data@v1
uses: actions/setup-python@v5
with:
share-id: release_version
mode: get
key: version
- name: get release_published
id: release_published
uses: noobly314/share-data@v1
with:
share-id: release_published
mode: get
key: is_published
python-version: '3.11'

- name: Update package version
run: |
echo ${{ steps.release_version.outputs.data }}
sed "s/^\( *version=\).*/\1'${{ steps.release_version.outputs.data }}',/g" setup.py
sed -i "s/^\( *version=\).*/\1'${{ steps.release_version.outputs.data }}',/g" setup.py
if: steps.release_published.outputs.data == 'true'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
if: steps.release_published.outputs.data == 'true'
pip install poetry
- name: Update package version
id: update_version
run: |
sha_short=$(git rev-parse --short HEAD)
bump_version="${{ needs.release.outputs.new_release_version }}.dev${{ github.run_number }}"
echo "bump_version=$bump_version" >> $GITHUB_OUTPUT
echo "bump_version: $bump_version" >> $GITHUB_STEP_SUMMARY
echo $bump_version
poetry version $bump_version
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
PYPI_TEST_TOKEN: ${{ secrets.PYPI_TEST_TOKEN }}
run: |
poetry config repositories.test-pypi https://test.pypi.org/legacy/
poetry config pypi-token.test-pypi $PYPI_TEST_TOKEN
poetry build
poetry publish -r test-pypi
if: needs.release.outputs.new_release_published == 'true'

- name: Clean PyPi release
if: always()
run: |
python setup.py sdist bdist_wheel
twine upload --repository testpypi dist/*
if: steps.release_published.outputs.data == 'true'
poetry add pypi-cleanup
poetry run pypi-cleanup --host https://test.pypi.org --username '__token__' --package libtado --do-it
env:
PYPI_CLEANUP_PASSWORD: ${{ secrets.PYPI_TEST_TOKEN }}
92 changes: 45 additions & 47 deletions .github/workflows/release-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
jobs:
release:
runs-on: ubuntu-latest
outputs:
new_release_version: ${{ steps.version.outputs.new_release_version }}
new_release_published: ${{ steps.version.outputs.new_release_published }}
steps:
- uses: actions/checkout@v1

Expand All @@ -25,11 +28,11 @@ jobs:
}
'> .releaserc
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v2
uses: cycjimmy/semantic-release-action@v4
id: semantic
with:
branches: 'master'
semantic_version: 19.0.2
semantic_version: 21.1.1
extra_plugins: |
@semantic-release/[email protected]
@semantic-release/[email protected]
Expand All @@ -38,64 +41,59 @@ jobs:
dry_run: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: set release_version
id: set_release_version
uses: noobly314/share-data@v1
with:
share-id: release_version
mode: set
key: version
value: ${{ steps.semantic.outputs.new_release_version }}
- name: set release_published
id: set_release_published
uses: noobly314/share-data@v1
with:
share-id: release_published
mode: set
key: version
value: ${{ steps.semantic.outputs.new_release_published }}

- name: Write in summary
run: |
echo "## Semantic Release" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "new_release_version: $NEW_RELEASE_VERSION" >> $GITHUB_STEP_SUMMARY
echo "new_release_published: $NEW_RELEASE_PUBLISHED" >> $GITHUB_STEP_SUMMARY
env:
NEW_RELEASE_VERSION: ${{ steps.semantic.outputs.new_release_version }}
NEW_RELEASE_PUBLISHED: ${{ steps.semantic.outputs.new_release_published }}

- name: Write in outputs
id: version
run: |
echo "NEW_RELEASE_VERSION=$NEW_RELEASE_VERSION" >> $GITHUB_OUTPUT
echo "NEW_RELEASE_PUBLISHED=$NEW_RELEASE_PUBLISHED" >> $GITHUB_OUTPUT
env:
NEW_RELEASE_VERSION: ${{ steps.semantic.outputs.new_release_version }}
NEW_RELEASE_PUBLISHED: ${{ steps.semantic.outputs.new_release_published }}

deploy:
needs: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v5
with:
python-version: '3.7'
python-version: '3.11'

- name: get release_version
id: release_version
uses: noobly314/share-data@v1
with:
share-id: release_version
mode: get
key: version
- name: get release_published
id: release_published
uses: noobly314/share-data@v1
with:
share-id: release_published
mode: get
key: version

- name: Update package version
run: |
sed -i "s/^\( *version=\).*/\1'${{ steps.release_version.outputs.data }}',/g" setup.py
sed -i 's/^\(^version = \).*/\1"${{ steps.release_version.outputs.data }}",/g' pyproject.toml
if: steps.release_published.outputs.data == 'true'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
pip install poetry
if: steps.release_published.outputs.data == 'true'

- name: Update package version
id: update_version
run: |
sha_short=$(git rev-parse --short HEAD)
bump_version="${{ needs.release.outputs.new_release_version }}.dev${{ github.run_number }}"
echo "bump_version=$bump_version" >> $GITHUB_OUTPUT
echo "bump_version: $bump_version" >> $GITHUB_STEP_SUMMARY
echo $bump_version
poetry version $bump_version
if: steps.release_published.outputs.data == 'true'

- name: Build and publish
env:
TWINE_USERNAME: "__token__"
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
poetry config repositories.pypi https://pypi.org
poetry config pypi-token.pypi $PYPI_TOKEN
poetry build
poetry publish -r pypi
if: steps.release_published.outputs.data == 'true'
2 changes: 1 addition & 1 deletion .github/workflows/template_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
python-version: ["3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ It shows you how to use the library and expose some structured responses. A more
| `3.8` | `3.7.0` > `latest` |
| `3.9` | `3.7.0` > `latest` |
| `3.10` | `3.7.0` > `latest` |
| `3.11` | `3.7.0` > `latest` |
| `3.12` | `3.7.0` > `latest` |

## Contributing

Expand Down
Loading

0 comments on commit 0c4b0c5

Please sign in to comment.