deploy to pypi #5
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
name: CI | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
ci: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: snok/install-poetry@v1 | |
with: | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
installer-parallel: true | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12" | |
cache: "poetry" | |
- run: | | |
poetry install | |
# avoid activate evn in every step | |
echo "$GITHUB_WORKSPACE/.venv/bin" >> $GITHUB_PATH | |
- id: test | |
run: pytest | |
- id: check_version | |
run: python .github/workflows/check_version.py | |
- id: build | |
if: steps.check_version.outputs.new_version != '' | |
run: poetry build | |
- name: pump | |
id: pump | |
if: steps.build.conclusion == 'success' | |
run: | | |
git config --global user.email "hoishing@gmail.com" | |
git config --global user.name "Kelvin Ng" | |
git tag ${{ steps.check_version.outputs.new_version }} | |
git push --tag -f | |
- id: gh_release | |
if: steps.pump.conclusion == 'success' | |
run: | | |
latest_tag=${{ steps.check_version.outputs.new_version }} | |
echo ${{ secrets.GH_TOKEN }} | gh auth login --with-token | |
gh release create "$latest_tag" --generate-notes ./dist/* | |
auto-changelog | |
git add . && git commit -am "ci: update auto-changelog, create release $latest_tag" && git push | |
- id: publish | |
if: steps.gh_release.conclusion == 'success' | |
run: | | |
poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }} | |
poetry publish |