-
Notifications
You must be signed in to change notification settings - Fork 16
70 lines (67 loc) · 2.27 KB
/
release.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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/*