Merge pull request #177 from Olen/Olen-patch-1 #2
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: Release to PyPI | ||
on: | ||
push: | ||
branches: | ||
- main # Adjust if your default branch is different | ||
paths: | ||
- 'pyproject.toml' | ||
permissions: | ||
id-token: write # Required for OIDC authentication | ||
contents: read | ||
jobs: | ||
release: | ||
name: π― Create Release & Publish to PyPI | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: ποΈ Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: π Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.x' | ||
- name: π Install Poetry | ||
uses: snok/install-poetry@v1 | ||
with: | ||
virtualenvs-create: true | ||
virtualenvs-in-project: true | ||
- name: ποΈ Install project | ||
# Don't install dependencies that are handled within actions | ||
run: poetry install --without dev-not-ci | ||
- name: π Extract version from Poetry | ||
id: get_version | ||
run: | | ||
VERSION=$(poetry version -s) | ||
echo "VERSION=$VERSION" >> $GITHUB_ENV | ||
echo "π’ Extracted version: $VERSION" | ||
- name: π Check if Git tag exists | ||
id: check_tag | ||
run: | | ||
if git rev-parse "v${VERSION}" >/dev/null 2>&1; then | ||
echo "β οΈ Tag v${VERSION} already exists. Skipping release!" | ||
exit 1 | ||
fi | ||
- name: "ποΈ Get previous release version" | ||
id: last_release | ||
uses: InsonusK/[email protected] | ||
with: | ||
myToken: ${{ github.token }} | ||
exclude_types: "draft|prerelease" | ||
- name: "π·οΈ Create new tag" | ||
uses: rickstaa/action-create-tag@v1 | ||
id: "tag_create" | ||
with: | ||
tag: "v${{ VERSION }}" | ||
Check failure on line 65 in .github/workflows/release.yml
|
||
tag_exists_error: false | ||
message: "β Tag Version v${{ VERSION }} created" | ||
- name: "ποΈ Generate release changelog" | ||
id: changelog | ||
uses: heinrichreimer/[email protected] | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
sinceTag: ${{ steps.last_release.outputs.tag_name }} | ||
headerLabel: "# Notable changes since ${{ steps.last_release.outputs.tag_name }}" | ||
stripGeneratorNotice: true | ||
- name: π Create GitHub Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
tag_name: v${{ env.VERSION }} | ||
name: π Release v${{ env.VERSION }} | ||
body: "π Automated release of version **v${{ env.VERSION }}**" | ||
draft: false | ||
prerelease: false | ||
- name: ποΈ Build package with Poetry | ||
run: poetry build | ||
- name: π Publish to PyPI with OpenID | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||