-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (56 loc) · 1.83 KB
/
publish-github.yml
File metadata and controls
68 lines (56 loc) · 1.83 KB
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
name: Publish package on GitHub
on:
release:
types:
- created
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel
- name: Read version from __init__.py
id: read_version
run: |
VERSION=$(python setup.py --version)
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Configure Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Check if tag already exists
id: check_tag
run: |
if git ls-remote --tags origin | grep -q "refs/tags/${{ env.VERSION }}"; then
echo "Tag already exists, skipping tag creation."
echo "TAG_EXISTS=true" >> $GITHUB_ENV
else
echo "Creating new tag: ${{ env.VERSION }}"
echo "TAG_EXISTS=false" >> $GITHUB_ENV
fi
- name: Create and push Git tag (if needed)
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: env.TAG_EXISTS == 'false'
run: |
git tag ${{ env.VERSION }}
git push origin ${{ env.VERSION }}
- name: Build package
run: |
python setup.py sdist bdist_wheel
- name: Create GitHub release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create ${{ env.VERSION }} dist/* --title "Release ${{ env.VERSION }}" --notes "Release version created from __init__.py"