forked from camas/setuptools-git-ver
-
-
Notifications
You must be signed in to change notification settings - Fork 16
88 lines (73 loc) · 2.8 KB
/
release.yml
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: Release
on:
push:
tags:
- v*
env:
DEFAULT_PYTHON: '3.12'
jobs:
release:
name: Release package
runs-on: ubuntu-latest
if: github.repository == 'dolfinus/setuptools-git-versioning' # prevent running on forks
environment:
name: pypi
url: https://pypi.org/p/onetl
permissions:
id-token: write # to auth in PyPI
contents: write # to create Github release
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-python-${{ env.DEFAULT_PYTHON }}-release-${{ hashFiles('requirements*.txt') }}
restore-keys: |
${{ runner.os }}-python-${{ env.DEFAULT_PYTHON }}-release-${{ hashFiles('requirements*.txt') }}
${{ runner.os }}-python-${{ env.DEFAULT_PYTHON }}-release-
${{ runner.os }}-python
${{ runner.os }}-
- name: Upgrade pip
run: python -m pip install --upgrade pip setuptools wheel
- name: Install dependencies
run: pip install -r requirements.txt -r requirements-doc.txt
- name: Inject slug/short variables
uses: rlespinasse/[email protected]
- name: Patch setup.py with explicit version number
# Fix for https://github.com/dolfinus/setuptools-git-versioning/issues/72#issuecomment-1312589464
run: |
version=$(echo $GITHUB_REF_SLUG | sed -E "s/v(.*)/\1/")
sed -i -E "/from setuptools_git_versioning.*/d" setup.py
sed -i -E "s/version=.*/version='${version}',/" setup.py
- name: Build package
run: python setup.py sdist bdist_wheel
- name: Build release notes
run: |
mkdir reports/
pip install -e .
version=$(echo $GITHUB_REF_SLUG | sed -E "s/v(.*)/\1/")
# lines 1 and 3 are empty, line 2 contains version number, line 4 contains release date
changelog generate-md -c ./docs/conf.py CHANGELOG.rst -v $version | sed "1,4d" > reports/release.md
sed -i -E 's/:github-user:`(.*)`/@\1/g' reports/release.md
sed -i -E 's/:issue:`(.*)`/#\1/g' reports/release.md
sed -i -E 's/:pr:`(.*)`/#\1/g' reports/release.md
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
- name: Create Github release
id: create_release
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
draft: false
prerelease: false
body_path: reports/release.md
files: |
dist/*