mirror of
https://github.com/MarkParker5/STARK.git
synced 2024-11-24 08:12:13 +02:00
87 lines
2.5 KiB
YAML
87 lines
2.5 KiB
YAML
name: Publish to PyPI and Create Release
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
publish:
|
|
permissions:
|
|
id-token: write
|
|
contents: write
|
|
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 "mark@parker-programs.com"
|
|
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
|