-
Notifications
You must be signed in to change notification settings - Fork 53
75 lines (66 loc) · 2.3 KB
/
version-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
name: Version Release
on:
push:
tags:
- '\d+\.\d+\.\d+' # Push events to matching d.d.d, i.e. 1.0.0, 15.26.35
jobs:
github-release:
name: Create GitHub Release
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/[email protected]
- name: Create Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: false
prerelease: false
pypi-release:
name: Publish on PyPi
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/setup-python@v2
with:
python-version: 3.8
# Make sure the version of setup is the same as the version in tag
- name: Get version from pyproject.toml
id: get_version
run: |
pyproject_version=$(python -c "import re; version = re.search(r'version = \"(.+?)\"', open('pyproject.toml').read()).group(1); print(version)")
echo "pyproject_version=$pyproject_version" >> $GITHUB_ENV
init_git_version=$(python -c "import re; version = re.search(r'__version__ = \"(.+?)\"', open('hezar/__init__.py').read()).group(1); print(version)")
echo "init_git_version=$init_git_version" >> $GITHUB_ENV
- name: Extract Git tag
run: |
GIT_TAG=${GITHUB_REF##*/}
echo "GIT_TAG=$GIT_TAG" >> $GITHUB_ENV
- name: Check if versions match
run: |
if [[ ${{ env.pyproject_version }} != "${{ env.GIT_TAG }}" ]]; then
echo "[Error]: Version Missmatch!"
exit 1
fi
if [[ ${{ env.GIT_TAG }} != "${{ env.init_git_version }}" ]]; then
echo "[Error]: Version Missmatch!"
exit 1
fi
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine poetry
- name: Publish package to PYPI
run: |
poetry config pypi-token.pypi "${{ secrets.PYPI_TOKEN }}"
poetry publish --build
needs:
- github-release
call-docs-workflow:
name: Trigger docs-deploy.yml
uses: ./.github/workflows/docs-deploy.yml
needs:
- pypi-release