Skip to content

Commit c70c252

Browse files
committed
publish action
1 parent 31edcde commit c70c252

File tree

2 files changed

+112
-0
lines changed

2 files changed

+112
-0
lines changed

.github/workflows/python-publish.yml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# This workflow will upload a Python Package using Twine when a release is created
2+
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3+
4+
# This workflow uses actions that are not certified by GitHub.
5+
# They are provided by a third-party and are governed by
6+
# separate terms of service, privacy policy, and support
7+
# documentation.
8+
9+
name: Publish package release
10+
11+
on:
12+
workflow_dispatch:
13+
inputs:
14+
version-change:
15+
description: Version part
16+
required: true
17+
type: choice
18+
default: minor
19+
options:
20+
- minor
21+
- patch
22+
beta:
23+
description: Is beta version
24+
required: true
25+
type: boolean
26+
default: True
27+
jobs:
28+
publish:
29+
env:
30+
VERSION_CHANGE: ${{ github.event.inputs.version-change }}
31+
WITH_BETA: ${{ github.event.inputs.beta }}
32+
GH_TOKEN: ${{ secrets.YDB_PLATFORM_BOT_TOKEN_REPO }}
33+
CHANGELOG_FILE: CHANGELOG.md
34+
PYPROJECT_PATH: pyproject.toml
35+
36+
permissions:
37+
contents: write
38+
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
39+
40+
runs-on: ubuntu-latest
41+
42+
steps:
43+
- uses: actions/checkout@v3
44+
with:
45+
token: ${{ secrets.YDB_PLATFORM_BOT_TOKEN_REPO }}
46+
47+
- name: Set up Python
48+
uses: actions/setup-python@v3
49+
with:
50+
python-version: '3.9'
51+
52+
- name: read changelog
53+
id: read-changelog
54+
run: |
55+
CHANGELOG=$(cat $CHANGELOG_FILE | sed -e '/^## .*$/,$d')
56+
echo "CHANGELOG<<CHANGELOGEOF_MARKER" >> $GITHUB_ENV
57+
echo "$CHANGELOG" >> $GITHUB_ENV
58+
echo "CHANGELOGEOF_MARKER" >> $GITHUB_ENV
59+
echo "# Changelog" >> $GITHUB_STEP_SUMMARY
60+
echo "$CHANGELOG" >> $GITHUB_STEP_SUMMARY
61+
62+
63+
- name: Increment version
64+
id: increment-version
65+
run: |
66+
NEW_VERSION=$(python3 ./.github/scripts/increment_version.py --inc-type=$VERSION_CHANGE --beta=$WITH_BETA)
67+
echo new version: $NEW_VERSION
68+
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_OUTPUT
69+
echo "New version: $NEW_VERSION" >> $GITHUB_STEP_SUMMARY
70+
71+
- name: Install Poetry
72+
run: pip install poetry
73+
74+
- name: Build package
75+
run: poetry build
76+
77+
- name: Publish release on github
78+
run: |
79+
if [[ -z "$CHANGELOG" ]]
80+
then
81+
echo "CHANGELOG empty"
82+
exit 1;
83+
fi;
84+
85+
TAG="${{ steps.increment-version.outputs.NEW_VERSION }}"
86+
87+
# Get previous version from changelog
88+
# pre-incremented version not used for consistent changelog with release notes
89+
# for example changelog may be rewrited when switch from beta to release
90+
# and remove internal beta changes
91+
LAST_TAG=$(cat $CHANGELOG_FILE | grep '^## .* ##$' | head -n 2 | tail -n 1 | cut -d ' ' -f 2)
92+
93+
git config --global user.email "robot@umbrella";
94+
git config --global user.name "robot";
95+
git commit -am "Release: $TAG";
96+
97+
git tag "$TAG"
98+
git push && git push --tags
99+
100+
CHANGELOG="$CHANGELOG
101+
102+
Full Changelog: [$LAST_TAG...$TAG](https://github.com/ydb-platform/ydb-sqlalchemy/compare/$LAST_TAG...$TAG)"
103+
if [ "$WITH_BETA" = true ]
104+
then
105+
gh release create --prerelease $TAG --title "$TAG" --notes "$CHANGELOG"
106+
else
107+
gh release create $TAG --title "$TAG" --notes "$CHANGELOG"
108+
fi;
109+
110+
- name: Publish package
111+
uses: pypa/gh-action-pypi-publish@release/v1.8

ydb_dbapi/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from .connections import IsolationLevel
44
from .connections import async_connect
55
from .connections import connect
6+
from .constants import *
67
from .cursors import AsyncCursor
78
from .cursors import Cursor
89
from .errors import *

0 commit comments

Comments
 (0)