Skip to content

fix auto release

fix auto release #4

Workflow file for this run

name: Create Release on Version Change
on:
push:
paths:
- 'setup.py'
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel
- name: Get version from setup.py
id: get_version
run: |
version=$(python setup.py --version)
echo "VERSION=${version}" >> "$GITHUB_ENV"
- name: Get latest release
id: get_latest_release
run: |
latest_release=$(curl -s https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r .tag_name)
echo "LATEST_RELEASE=${latest_release}" >> "$GITHUB_ENV"
- name: Create release
if: env.VERSION!=env.LATEST_RELEASE
id: create_release
run: |
curl -X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/json" \
-d '{
"tag_name": "'"${{ env.VERSION }}"'",
"target_commitish": "'"${{ github.sha }}"'",
"name": "'"${{ github.event.head_commit.message }}"'",
"generate_release_notes": true,
"draft": false,
"prerelease": false
}' https://api.github.com/repos/${{ github.repository }}/releases
- name: Build package
if: env.VERSION!=env.LATEST_RELEASE
run: python setup.py bdist_wheel sdist
- name: Publish package
if: env.VERSION!=env.LATEST_RELEASE
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}