-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🚀 Publish autogen client to PyPI via CI/CD (#8)
* ✨ Add endpoints for c4p2n triggers * 💩 Notes about client generation * 🚀 Add GitHub Actions
- Loading branch information
Showing
8 changed files
with
516 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: check-release | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
check-release: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python 3.8 | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: 3.8 | ||
- name: Get latest tag | ||
id: latesttag | ||
env: | ||
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | ||
run: | | ||
git fetch | ||
echo "::set-output name=latest_tag::$(git describe --always --tags `git rev-list --tags --max-count=1`)" | ||
- name: Validate poetry version | ||
run: | | ||
poetry_version=$(cat pyproject.toml | grep 'version =' | cut -d ' ' -f 3 | sed 's/\"//g') | ||
echo "$poetry_version $TAG" | ||
python scripts/validate_poetry_version.py $poetry_version ${{ steps.latesttag.outputs.latest_tag }} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: lint | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python 3.8 | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: 3.8 | ||
- name: Install poetry | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install poetry >=1.0.0 | ||
poetry config virtualenvs.in-project true | ||
- name: Set up cache | ||
uses: actions/cache@v1 | ||
id: cache | ||
with: | ||
path: .venv | ||
key: venv-${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }} | ||
- name: Install dependencies | ||
run: | | ||
poetry install | ||
- name: Lint with black | ||
run: | | ||
poetry run black --check ppm_telegram_bot | ||
- name: Check types with mypy | ||
run: | | ||
poetry run mypy ppm_telegram_bot | ||
- name: Check if package can be built | ||
run: | | ||
poetry build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: release | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python 3.8 | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: 3.8 | ||
- name: Install poetry | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install poetry >=1.0.0 | ||
poetry config virtualenvs.in-project true | ||
- name: Set up cache | ||
uses: actions/cache@v1 | ||
id: cache | ||
with: | ||
path: .venv | ||
key: venv-${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }} | ||
- name: Install dependencies | ||
run: | | ||
poetry install | ||
- name: Generate OpenAPI schema definition | ||
env: | ||
TELEGRAM_BOT_API_KEY: '1:a' | ||
TELEGRAM_BOT_WEBHOOK_ENDPOINT: '' | ||
TELEGRAM_BOT_WEBHOOK_SECRET: '' | ||
ORG_CHAT_ID: '1' | ||
run: | | ||
poetry run python -c "from ppm_telegram_bot.api import app; import json; schema = app.openapi(); json.dump(schema, open('openapi.json', 'w'))" | ||
- name: Generate client | ||
id: generate_client | ||
run: | | ||
git clone https://github.com/b0g3r/fastapi_client | ||
echo "::set-output name=poetry_version::$(poetry version | cut -d ' ' -f 2)" | ||
./fastapi_client/scripts/generate.sh \ | ||
-i openapi.json \ | ||
-p ppm_telegram_bot_client \ | ||
-o . \ | ||
--with-meta \ | ||
-- \ | ||
--additional-properties=packageVersion=$(poetry version | cut -d ' ' -f 2) || true | ||
- name: Publish to PyPI | ||
run: | | ||
cd ppm_telegram_bot_client | ||
poetry run python setup.py sdist | ||
poetry run twine upload --username __token__ --password ${{ secrets.PYPI_PASSWORD }} dist/* | ||
- name: Create GitHub release | ||
uses: actions/create-release@latest | ||
with: | ||
tag_name: ${{ steps.generate_client.outputs.poetry_version }} | ||
release_name: Release ${{ steps.generate_client.outputs.poetry_version }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
Oops, something went wrong.