-
Notifications
You must be signed in to change notification settings - Fork 53
80 lines (72 loc) · 2.44 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
76
77
78
79
80
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:
run-tests:
name: Trigger tests.yml
uses: ./.github/workflows/tests.yml
github-release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: run-tests
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v3.5.2
- 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/checkout@v3.5.2
- uses: actions/setup-python@v2
with:
python-version: '3.10'
# 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