Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Релиз по тегу vX.Y.Z: проверка версии и тестов → сборка → PyPI (trusted publishing, без токенов) → GitHub Release.
# В PyPI для проекта avito-ads настроен trusted publisher: avito-tech/avito-ads-sdk-python3, release.yml, environment pypi.
name: Release

on:
push:
tags: ['v*.*.*']

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install
run: |
python -m pip install --upgrade pip build twine
pip install -e ".[dev]"
- name: Tag matches version
run: |
python - <<'PY'
import json, os, sys
import avito_ads
tag = os.environ["GITHUB_REF_NAME"].lstrip("v")
spec = json.load(open("openapi.json", encoding="utf-8"))["info"]["version"]
print(f"tag={tag} openapi.json={spec} __version__={avito_ads.__version__} API_VERSION={avito_ads.API_VERSION}")
if len({tag, spec, avito_ads.__version__, avito_ads.API_VERSION}) != 1:
sys.exit("Тег не совпадает с версией SDK")
PY
- name: Test
run: pytest -q
- name: Build
run: |
python -m build
twine check dist/*
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist/

publish:
needs: build
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- uses: pypa/gh-action-pypi-publish@release/v1

github-release:
needs: publish
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: GitHub Release (notes from CHANGELOG)
env:
GH_TOKEN: ${{ github.token }}
run: |
ver="${GITHUB_REF_NAME#v}"
awk -v v="[$ver]" '/^## /{ if (p) exit; if (index($0, v)) { p = 1; next } } p' CHANGELOG.md > release-notes.md
test -s release-notes.md || { echo "В CHANGELOG.md нет раздела [$ver]"; exit 1; }
gh release create "$GITHUB_REF_NAME" --title "$GITHUB_REF_NAME" --notes-file release-notes.md --verify-tag
Loading