Skip to content

Release Package

Release Package #46

Workflow file for this run

name: Release Package
on:
workflow_dispatch:
permissions:
users:
- ItayTheDar
inputs:
increment_version:
description: 'Increment version by major, minor, or patch'
required: true
default: 'patch'
type: choice
options:
- major
- minor
- patch
env:
VERSION_FILE_PATH: pyproject.toml
CHANGELOG_FILE_PATH: CHANGELOG.md
jobs:
run-tests:
uses: ./.github/workflows/tests.yaml
release-package:
runs-on: ubuntu-latest
needs: run-tests
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
token: ${{ secrets.RELEASE_GIT_TOKEN }}
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install Poetry
run: |
pip install poetry
- name: Set version using Poetry
run: |
# Extract the current version
CURRENT_VERSION=$(poetry version -s)
echo "Current version: $CURRENT_VERSION"
# Increment version
case ${{ inputs.increment_version }} in
major)
NEW_VERSION=$(poetry version major | awk '{print $NF}')
;;
minor)
NEW_VERSION=$(poetry version minor | awk '{print $NF}')
;;
patch)
NEW_VERSION=$(poetry version patch | awk '{print $NF}')
;;
*)
echo "Invalid input for increment_version"
exit 1
;;
esac
echo "New version: $NEW_VERSION"
echo "RELEASE_VERSION=$NEW_VERSION" >> $GITHUB_ENV
- name: Install build dependencies
run: |
poetry install --with build
- name: Update CHANGELOG.md
run: poetry run git-changelog . -o $CHANGELOG_FILE_PATH
- name: Build package with Poetry
run: |
poetry build
- name: Commit and push changes
run: |
git config --global user.name "github-actions"
git config --global user.email "github@actions.com"
git add $CHANGELOG_FILE_PATH pyproject.toml
git commit -m "Increment version to $NEW_VERSION"
git push
- name: Publish package to PyPI
run: |
poetry publish --username ${{ secrets.PYPI_API_USER }} --password ${{ secrets.PYPI_API_TOKEN }}
- name: Create GitHub release
uses: softprops/action-gh-release@v1
with:
name: v${{ env.RELEASE_VERSION }}
tag_name: v${{ env.RELEASE_VERSION }}
deploy-docs:
needs: release-package
permissions:
contents: read
pages: write
id-token: write
uses: ./.github/workflows/deploy_docs.yaml