Skip to content

Commit

Permalink
Create release.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkParker5 authored Jul 19, 2023
1 parent 40ddf3f commit 846b29d
Showing 1 changed file with 83 additions and 0 deletions.
83 changes: 83 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Publish to PyPI and Create Release

on:
push:
branches:
- master
workflow_dispatch:

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: actions/setup-python@v2
with:
python-version: '3.10'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry install
- name: Version bump
id: version
run: |
if [[ "v$(poetry version --short)" == "$(git describe --tags --always --abbrev=0)" ]]; then
poetry version patch
git add pyproject.toml
git config --global user.email "[email protected]"
git config --global user.name "MarkParker5"
git commit -m "Version bump v$(poetry version --short)"
git push
echo Version bumped to $(poetry version --short)
fi
echo Using version $(poetry version --short)
echo VERSION="v$(poetry version --short)" >> $GITHUB_OUTPUT
- name: Build distribution
id: build
run: |
poetry build
echo FILE="$(ls dist/*.whl -U | head -1)" >> $GITHUB_OUTPUT
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}

- name: Create tag
uses: rickstaa/action-create-tag@v1
with:
tag: ${{ steps.version.outputs.VERSION }}

- name: Generate changelog
id: changelog
run: |
changelog=$(git log --pretty=format:"- %s" "${{ steps.version.outputs.VERSION }}..HEAD")
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GIT_TOKEN }}
with:
tag_name: ${{ steps.version.outputs.VERSION }}
release_name: Release ${{ steps.version.outputs.VERSION }}
body: ${{ steps.changelog.outputs.changelog }}
draft: false
prerelease: false

- name: Upload .whl file
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GIT_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ steps.build.outputs.FILE }}
asset_name: ${{ steps.build.outputs.FILE }}
asset_content_type: application/zip

0 comments on commit 846b29d

Please sign in to comment.