mirror of
https://github.com/pufereq/python-template.git
synced 2025-12-15 15:49:32 +00:00
88 lines
2.9 KiB
YAML
88 lines
2.9 KiB
YAML
name: Bump version
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
bump_type:
|
|
type: choice
|
|
description: 'Type of bump'
|
|
required: true
|
|
options:
|
|
- 'patch'
|
|
- 'minor'
|
|
- 'major'
|
|
- 'pre_l'
|
|
- 'pre_n'
|
|
short_description:
|
|
type: string
|
|
description: 'Short description of the release'
|
|
required: true
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
|
|
|
jobs:
|
|
create_version:
|
|
runs-on: ubuntu-latest
|
|
name: Create version from tag
|
|
steps:
|
|
- name: GH_TOKEN
|
|
if: env.GH_TOKEN == ''
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: echo "GH_TOKEN=${GITHUB_TOKEN}" >> $GITHUB_ENV
|
|
- name: 🔀 checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
token: "${{ env.GH_TOKEN }}"
|
|
- name: 🐍 python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.x'
|
|
cache: pip
|
|
- name: 📦 setup pdm
|
|
uses: pdm-project/setup-pdm@v4
|
|
with:
|
|
cache: true
|
|
- name: 📦 install dependencies
|
|
run: pdm install
|
|
- name: configure git
|
|
run: |
|
|
git config --global user.name "github-actions[bot]"
|
|
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
|
- name: 📦 bump version
|
|
id: bump_version
|
|
run: |
|
|
bump-my-version ${{ github.event.inputs.bump_type }}
|
|
echo "BUMPED_VERSION=$(cat ${{ github.event.repository.name }}/__init__.py | grep __version__ | cut -d '"' -f 2)" >> $GITHUB_ENV
|
|
- name: 📝 create changelog
|
|
run: |
|
|
git-cliff -s header --unreleased -t ${{ steps.bump_version.outputs.BUMPED_VERSION }} > release_body.md
|
|
echo "Changes:" && cat release_body.md
|
|
git-cliff -t ${{ steps.bump_version.outputs.BUMPED_VERSION }} > CHANGELOG.md
|
|
- name: 📤 push changes
|
|
run: |
|
|
git add CHANGELOG.md ${{ github.event.repository.name }}/__init__.py
|
|
git commit -m "chore(release): ${{ steps.bump_version.outputs.BUMPED_VERSION }}"
|
|
git push origin main
|
|
- name: create release
|
|
uses: softprops/action-gh-release@v2
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
|
with:
|
|
name: ${{ github.event.repository.name }} ${{ steps.bump_version.outputs.BUMPED_VERSION }} - ${{ github.event.inputs.bump_type }}
|
|
tag_name: ${{ steps.bump_version.outputs.BUMPED_VERSION }}
|
|
body_path: release_body.md
|
|
prerelease: ${{ github.event.inputs.bump_type == 'pre_l' || github.event.inputs.bump_type == 'pre_n' }}
|
|
discussion_category_name: 'Announcements'
|
|
- name: 🧹 cleanup
|
|
run: |
|
|
rm release_body.md
|
|
- name: 📤 merge into develop
|
|
run: |
|
|
git checkout develop
|
|
git merge main --no-ff
|
|
git push origin develop
|
|
- name: ✅ done
|
|
run: echo "done"
|