Release new version #39
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 new version | |
on: | |
workflow_dispatch: | |
inputs: | |
type: | |
description: "Release type" | |
required: true | |
default: "preview" | |
type: choice | |
options: | |
- fix | |
- minor | |
- minor,preview | |
- major,preview | |
- release | |
jobs: | |
test: | |
uses: ./.github/workflows/tests.yml | |
release: | |
needs: test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: setup git | |
run: | | |
git config user.name "$GITHUB_ACTOR" | |
git config user.email "${GITHUB_ACTOR_ID}+${GITHUB_ACTOR}@users.noreply.github.com" | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.x | |
- name: Install hatch | |
run: pip install hatch | |
- name: Bump Version | |
run: | | |
hatch version $TYPE | |
git commit -am "Release v$(hatch version)" | |
env: | |
TYPE: ${{ inputs.type }} | |
- name: Build project | |
run: hatch build | |
- name: Create Git Tag | |
run: | | |
git tag v$(hatch version) | |
echo "TAG_NAME=v$(hatch version)" >> $GITHUB_ENV | |
- name: Push Changes | |
run: | | |
git push origin --all | |
git push origin --tags | |
- name: Publish Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: dist/* | |
tag_name: ${{ env.TAG_NAME }} | |
generate_release_notes: true | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: package | |
path: dist/* | |
test-publish: | |
needs: release | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
steps: | |
- name: Download artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: package | |
path: dist | |
- name: Publish package distributions to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
repository-url: https://test.pypi.org/legacy/ | |
publish: | |
needs: test-publish | |
runs-on: ubuntu-latest | |
environment: publishing | |
permissions: | |
id-token: write | |
steps: | |
- name: Download artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: package | |
path: dist | |
- name: Publish package distributions to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 |