Skip to content

Release new version

Release new version #4

Workflow file for this run

name: release
run-name: Release new version
on:
push:
branches: [main]
paths:
- '**version.py'
workflow_dispatch:
jobs:
release:
name: Release new version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Get pip cache
id: pip-cache
run: |
python -c "from pip._internal.locations import USER_CACHE_DIR; print('dir=' + USER_CACHE_DIR)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip
- name: Install build requirements
run: |
python -m pip install --upgrade pip
pip install setuptools wheel
- name: Set version env
run: |
echo "LIBRARY_VERSION=$(python -c "import sys; sys.path.append('.'); from zabbix_utils.version import __version__; print(__version__)")" >> $GITHUB_ENV
- name: Build packages
run: |
python setup.py sdist bdist_wheel
- name: Add version tag
uses: pkgdeps/git-tag-action@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
github_repo: ${{ github.repository }}
git_commit_sha: ${{ github.sha }}
version: ${{ env.LIBRARY_VERSION }}
git_tag_prefix: "v"
- name: Archive built packages
uses: actions/upload-artifact@v4
with:
name: Archive-v${{ env.LIBRARY_VERSION }}
path: dist/*
- name: Create release notes
run: |
grep -Pzo '(?s)^## \[${{ env.LIBRARY_VERSION }}\].*?(?=## \[)' CHANGELOG.md | sed '$ s/.$//' > RELEASE_NOTES.md
sed -i 's/\[${{ env.LIBRARY_VERSION }}\]/Release [v${{ env.LIBRARY_VERSION }}]/' RELEASE_NOTES.md
- name: Create release
uses: ncipollo/release-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: v${{ env.LIBRARY_VERSION }}
draft: true
prerelease: false
makeLatest: true
skipIfReleaseExists: true
replacesArtifacts: true
removeArtifacts: true
tag: "v${{ env.LIBRARY_VERSION }}"
bodyFile: RELEASE_NOTES.md
artifacts: dist/*