From aef1138ee8c8cf2814a192d856cfddba7e4c75b6 Mon Sep 17 00:00:00 2001 From: Dmitry Maslennikov Date: Mon, 11 Dec 2023 15:11:22 +0400 Subject: [PATCH] init ci --- .github/workflows/main.yml | 72 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..8eec978 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,72 @@ +name: Upload Python Package + +on: + release: + types: [published] + push: + branches: [main] + +permissions: + contents: write + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - run: git fetch --depth=1 origin '+refs/tags/*:refs/tags/*' + if: github.event_name == 'push' + continue-on-error: true + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + - name: Install dependencies + id: set-version + run: | + VERSION=$(grep version setup.cfg | cut -d= -f2 | tr -d '[:blank:]') + [ $GITHUB_EVENT_NAME == 'push' ] && VERSION+=b && VERSION+=$(($(git tag -l "*$VERSION*" | cut -db -f2 | sort -n | tail -1)+1)) + [ $GITHUB_EVENT_NAME == 'release' ] && VERSION=${{ github.event.release.tag_name }} && VERSION=${VERSION/v/} + echo VERSION = $VERSION + sed -ie "s/version = .*/version = $VERSION/" setup.cfg + python -m pip install --upgrade pip + pip install build + pip install -r requirements.txt -e . + echo version=$VERSION >> $GITHUB_OUTPUT + NAME="testcontainers-iris"-${VERSION}-py3-none-any + echo name=$NAME >> $GITHUB_OUTPUT + - name: Test package + run: pytest + - name: Build package + run: python -m build + - name: Publish package + env: + PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }} + if: ${{ env.PYPI_API_TOKEN != '' }} + uses: pypa/gh-action-pypi-publish@release/v1.5 + with: + user: __token__ + password: ${{ env.PYPI_API_TOKEN }} + - name: Upload Release Asset + id: upload-release-asset + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ steps.set-version.outputs.version }} + prerelease: ${{ github.event_name != 'release' }} + files: dist/${{ steps.set-version.outputs.name }}.whl + - uses: actions/checkout@v3 + if: github.event_name == 'release' + with: + ref: main + - name: Bump version + if: github.event_name == 'release' + run: | + git config --global user.name 'ProjectBot' + git config --global user.email 'bot@users.noreply.github.com' + VERSION=${{ github.event.release.tag_name }} && VERSION=${VERSION/v/} + VERSION=`echo $VERSION | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.` + sed -ie "s/version = .*/version = $VERSION/" setup.cfg + git add setup.cfg + git commit -m 'auto bump version with release' + git push