Skip to content

Automated release workflow #245

Automated release workflow

Automated release workflow #245

Workflow file for this run

name: Automated release workflow
on:
workflow_dispatch:
inputs:
major:
description: "The new major version."
required: true
type: string
minor:
description: "The new minor version."
required: true
type: string
patch:
description: "The new patch version."
required: true
type: string
increment:
description: "The type of increment."
required: true
type: choice
options:
- MAJOR
- MINOR
- PATCH
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Check out the code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Run image
uses: abatilo/actions-poetry@v2.3.0
with:
poetry-version: 1.4.0
- name: Cache Poetry virtualenv
uses: actions/cache@v3
id: cache
with:
path: ~/.virtualenvs
key: venv-ubuntu-latest-3.8-${{ hashFiles('**/poetry.lock') }}
- name: Set Poetry config
run: |
poetry config virtualenvs.in-project false
poetry config virtualenvs.path ~/.virtualenvs
- name: Install Dependencies
run: poetry install
if: steps.cache.outputs.cache-hit != 'true'
- name: Generate changelog
run: poetry run cz changelog --unreleased-version="${{ github.event.inputs.major }}.${{ github.event.inputs.minor }}.${{ github.event.inputs.patch }}" --incremental
- name: Get user info
id: user_info
run: |
USER_JSON=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/users/${{ github.actor }}")
USER_NAME=$(echo "$USER_JSON" | jq -r .name)
USER_EMAIL=$(echo "$USER_JSON" | jq -r .email)
echo "::set-output name=name::$USER_NAME"
echo "::set-output name=email::$USER_EMAIL"
- name: Configure git
run: |
git config --local user.email "${{ steps.user_info.outputs.email }}"
git config --local user.name "${{ steps.user_info.outputs.name }}"
- name: Bump version
run: |
poetry run cz bump --yes --increment ${{ github.event.inputs.increment }}
git push
git push --tags
- name: Build hydrolib-core package
run: poetry build
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Create GitHub release
uses: softprops/action-gh-release@v1
with:
name: Release v${{ github.event.inputs.major }}.${{ github.event.inputs.minor }}.${{ github.event.inputs.patch }}
tag_name: ${{ github.event.inputs.major }}.${{ github.event.inputs.minor }}.${{ github.event.inputs.patch }}
generate_release_notes: true
token: ${{ secrets.GITHUB_TOKEN }}