Skip to content

ci(version): bump to v0.1.7.4 #47

ci(version): bump to v0.1.7.4

ci(version): bump to v0.1.7.4 #47

name: Auto Release on Version Change
on:
push:
branches:
- master
paths:
- 'pyproject.toml' # 当pyproject.toml文件变动时触发
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.11'
- name: Install PDM
uses: pdm-project/setup-pdm@v3
- name: Get Project Version
id: get_version
run: |
echo "version=$(pdm show --version)" >> $GITHUB_OUTPUT
shell: bash
- name: Check if Git Tag exists
id: check_tag_exists
env:
VERSION: ${{ steps.get_version.outputs.version }}
run: |
git fetch --tags
if git rev-list -n 1 "v$VERSION" > /dev/null 2>&1; then
echo "Tag v$VERSION already exists."
echo "exists=1" >> $GITHUB_OUTPUT
else
echo "Tag v$VERSION does not exist."
echo "exists=0" >> $GITHUB_OUTPUT
fi
shell: bash
- name: Create Git Tag
if: steps.check_tag_exists.outputs.exists == 0
run: |
git tag v${{ steps.get_version.outputs.version }}
git push origin v${{ steps.get_version.outputs.version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
- name: Install Dependencies
run: pdm install
shell: bash
- name: Build Package
run: pdm build
shell: bash
- name: Publish package
if: steps.check_tag_exists.outputs.exists == 0
env:
PDM_PUBLISH_USERNAME: __token__
PDM_PUBLISH_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: pdm publish
shell: bash
- name: Create GitHub Release
if: steps.check_tag_exists.outputs.exists == 0
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ steps.get_version.outputs.version }}
files: dist/*
draft: false
fail_on_unmatched_files: true
generate_release_notes: true
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}