Skip to content

Commit aef1138

Browse files
committed
init ci
1 parent 12ee5ff commit aef1138

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

.github/workflows/main.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Upload Python Package
2+
3+
on:
4+
release:
5+
types: [published]
6+
push:
7+
branches: [main]
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
deploy:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v3
18+
- run: git fetch --depth=1 origin '+refs/tags/*:refs/tags/*'
19+
if: github.event_name == 'push'
20+
continue-on-error: true
21+
- name: Set up Python
22+
uses: actions/setup-python@v4
23+
with:
24+
python-version: '3.11'
25+
- name: Install dependencies
26+
id: set-version
27+
run: |
28+
VERSION=$(grep version setup.cfg | cut -d= -f2 | tr -d '[:blank:]')
29+
[ $GITHUB_EVENT_NAME == 'push' ] && VERSION+=b && VERSION+=$(($(git tag -l "*$VERSION*" | cut -db -f2 | sort -n | tail -1)+1))
30+
[ $GITHUB_EVENT_NAME == 'release' ] && VERSION=${{ github.event.release.tag_name }} && VERSION=${VERSION/v/}
31+
echo VERSION = $VERSION
32+
sed -ie "s/version = .*/version = $VERSION/" setup.cfg
33+
python -m pip install --upgrade pip
34+
pip install build
35+
pip install -r requirements.txt -e .
36+
echo version=$VERSION >> $GITHUB_OUTPUT
37+
NAME="testcontainers-iris"-${VERSION}-py3-none-any
38+
echo name=$NAME >> $GITHUB_OUTPUT
39+
- name: Test package
40+
run: pytest
41+
- name: Build package
42+
run: python -m build
43+
- name: Publish package
44+
env:
45+
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
46+
if: ${{ env.PYPI_API_TOKEN != '' }}
47+
uses: pypa/gh-action-pypi-publish@release/v1.5
48+
with:
49+
user: __token__
50+
password: ${{ env.PYPI_API_TOKEN }}
51+
- name: Upload Release Asset
52+
id: upload-release-asset
53+
uses: softprops/action-gh-release@v1
54+
with:
55+
tag_name: ${{ steps.set-version.outputs.version }}
56+
prerelease: ${{ github.event_name != 'release' }}
57+
files: dist/${{ steps.set-version.outputs.name }}.whl
58+
- uses: actions/checkout@v3
59+
if: github.event_name == 'release'
60+
with:
61+
ref: main
62+
- name: Bump version
63+
if: github.event_name == 'release'
64+
run: |
65+
git config --global user.name 'ProjectBot'
66+
git config --global user.email '[email protected]'
67+
VERSION=${{ github.event.release.tag_name }} && VERSION=${VERSION/v/}
68+
VERSION=`echo $VERSION | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.`
69+
sed -ie "s/version = .*/version = $VERSION/" setup.cfg
70+
git add setup.cfg
71+
git commit -m 'auto bump version with release'
72+
git push

0 commit comments

Comments
 (0)