forked from ekeih/libtado
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ci): publish to pypi with poetry (#427)
* 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
1 parent
f90ab6b
commit 0c4b0c5
Showing
10 changed files
with
861 additions
and
796 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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: | | ||
|
@@ -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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
||
|
@@ -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] | ||
|
@@ -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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.