From 2f63d25ea0224193660e51f28ff6a54fe6b05764 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Wed, 11 Dec 2024 15:08:27 +0100 Subject: [PATCH] ci: release on release publish (#7) --- .github/workflows/release.yml | 34 +++++++++++++++++----------------- pyproject.toml | 8 +++++++- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cceae07..712ba8c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,6 +1,8 @@ name: upload release to PyPI on: - workflow_dispatch: + release: + types: + - published jobs: pypi-publish: @@ -11,23 +13,21 @@ jobs: id-token: write contents: write steps: - - uses: actions/checkout@v4.2.2 - - uses: actions/setup-python@v5.3.0 + - uses: actions/checkout@v4.1.1 with: - python-version: ">=3.10" - - name: Get version - run: | - echo "version=$(date +'%Y.%m.%d.%H.%M')" >> "$GITHUB_ENV" - - name: Tag and release - env: - GH_TOKEN: ${{ github.token }} + fetch-depth: 0 + fetch-tags: true + + - uses: actions/setup-python@v2.3.1 + with: + python-version: 3.12 + + - name: Install build run: | - git tag $version - git push origin $version - pip install poetry - poetry self add poetry-dynamic-versioning[plugin] - poetry install --sync - poetry build - gh release create --generate-notes $version ./dist/* + pip install poetry + poetry self add poetry-dynamic-versioning[plugin] + poetry install --sync + poetry build + - name: Publish package distributions to PyPI uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/pyproject.toml b/pyproject.toml index 5d93786..1877414 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,7 +24,7 @@ semgrep = "^1.99.0" yamllint = "^1.35.1" [build-system] -requires = ["poetry-core"] +requires = ["poetry-core", "poetry-dynamic-versioning"] build-backend = "poetry.core.masonry.api" [tool.poetry.plugins.pytest11] @@ -44,3 +44,9 @@ module = [ "pytest_opentelemetry.*" ] ignore_missing_imports = true + +[tool.poetry-dynamic-versioning] +enable = true +vcs = "git" +dirty = true +pattern = "default-unprefixed" \ No newline at end of file