Skip to content

[impit-python] Release to PyPI #39

[impit-python] Release to PyPI

[impit-python] Release to PyPI #39

name: "[impit-python] Release to PyPI"
permissions:
contents: write
id-token: write
on:
workflow_dispatch:
inputs:
bump:
description: 'Bump version'
required: true
type: choice
default: 'patch'
options:
- 'major'
- 'minor'
- 'patch'
jobs:
get_version:
runs-on: ubuntu-latest
outputs:
bumped-version-commit-sha: ${{ steps.commit_version.outputs.commit_long_sha || github.sha }}
new_version: ${{ steps.increment_version.outputs.new_version }}
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
- name: Use Python
uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Set up uv package manager
uses: astral-sh/setup-uv@v6
- name: Use Node.js
uses: actions/setup-node@v4
- name: Get current version
id: get_version
working-directory: impit-python
run: |
echo "current_version=$(uvx --from=toml-cli toml get --toml-path=pyproject.toml project.version)" >> "$GITHUB_OUTPUT"
- name: Increment version
id: increment_version
working-directory: impit-python
run: |
echo "new_version=$(npx semver -i ${{ github.event.inputs.bump }} ${{ steps.get_version.outputs.current_version }})" >> "$GITHUB_OUTPUT"
- name: Set new version
id: show_new_version
working-directory: impit-python
run: |
echo "New version is ${{ steps.increment_version.outputs.new_version }}"
uvx --from=toml-cli toml set --toml-path=pyproject.toml project.version ${{ steps.increment_version.outputs.new_version }}
- name: Commit new version
id: commit_version
uses: EndBug/add-and-commit@v9
with:
author_name: github-actions[bot]
author_email: github-actions[bot]@users.noreply.github.com
message: "chore(py-release): bump `pyproject.toml` version [skip ci]"
add: 'impit-python/pyproject.toml'
tag: "py-${{ steps.increment_version.outputs.new_version }}"
test:
needs: [get_version]
name: Build and test
uses: ./.github/workflows/python-test.yaml
secrets: inherit
with:
commit_sha: ${{ needs.get_version.outputs.bumped-version-commit-sha }}
publish:
defaults:
run:
working-directory: impit-python
name: Publish
runs-on: ubuntu-latest
needs: [test]
steps:
- name: Download all artifacts
uses: actions/download-artifact@v5
with:
path: impit-python/artifacts
- name: Move all wheels to /wheels
run: |
mkdir -p wheels
mv artifacts/**/*.{whl,tar.gz} wheels/
- name: List files
run: |
ls -lR
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: impit-python/wheels
changelog:
name: Generate changelog
needs: [publish, get_version]
runs-on: ubuntu-latest
outputs:
release_body: ${{ steps.git-cliff.outputs.content }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
ref: master
fetch-depth: 0
- name: Generate a changelog
uses: orhun/git-cliff-action@v4
id: git-cliff
with:
config: cliff.toml
args: --ignore-tags="(js|cli)-*" --include-path="./impit-python/**" --include-path="./impit/**"
env:
OUTPUT: impit-python/CHANGELOG.md
GITHUB_REPO: ${{ github.repository }}
- name: Commit new changelog
id: commit_changelog
uses: EndBug/add-and-commit@v9
with:
author_name: github-actions[bot]
author_email: github-actions[bot]@users.noreply.github.com
message: "docs: update changelog [skip ci]"
add: 'impit-python/CHANGELOG.md'
- name: Create release
uses: softprops/action-gh-release@v2
with:
tag_name: "py-${{ needs.get_version.outputs.new_version }}"
name: "impit-python@${{ needs.get_version.outputs.new_version }}"
target_commitish: ${{ needs.get_version.outputs.bumped-version-commit-sha }}
body: ${{ steps.git-cliff.outputs.content }}