From dd5f29ad556971da50547863220dd1e33b42c60b Mon Sep 17 00:00:00 2001 From: Denis Kokorin Date: Thu, 19 Dec 2024 22:53:42 +0200 Subject: [PATCH] Reusable workflow for releases (#67) --- .github/workflows/release-pypi.yml | 13 +++++++++++++ .github/workflows/release-test-pypi.yml | 14 ++++++++++++++ .github/workflows/release.yml | 25 ++++++++++++++++++------- .github/workflows/test-release.yml | 25 ------------------------- pyproject.toml | 3 +++ 5 files changed, 48 insertions(+), 32 deletions(-) create mode 100644 .github/workflows/release-pypi.yml create mode 100644 .github/workflows/release-test-pypi.yml delete mode 100644 .github/workflows/test-release.yml diff --git a/.github/workflows/release-pypi.yml b/.github/workflows/release-pypi.yml new file mode 100644 index 0000000..ff31a15 --- /dev/null +++ b/.github/workflows/release-pypi.yml @@ -0,0 +1,13 @@ +name: Release to PyPI + +on: + release: + types: + - released +jobs: + release: + uses: ./.github/workflows/release.yml + with: + pypi-repo: main + secrets: + pypi-token: ${{ secrets.PYPI_TOKEN }} diff --git a/.github/workflows/release-test-pypi.yml b/.github/workflows/release-test-pypi.yml new file mode 100644 index 0000000..766550c --- /dev/null +++ b/.github/workflows/release-test-pypi.yml @@ -0,0 +1,14 @@ +name: Release to Test PyPI + +on: + release: + types: + - published + - prereleased +jobs: + test-release: + uses: ./.github/workflows/release.yml + with: + pypi-repo: test + secrets: + pypi-token: ${{ secrets.TEST_PYPI_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c79e303..dd9aa9d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,23 +1,34 @@ name: Release on: - release: - types: - - released + workflow_call: + inputs: + pypi-repo: + required: true + type: string + secrets: + pypi-token: + required: true + env: HATCH_INDEX_USER: __token__ - HATCH_INDEX_REPO: main - HATCH_INDEX_AUTH: ${{ secrets.PYPI_TOKEN }} + HATCH_INDEX_REPO: ${{ inputs.pypi-repo }} + HATCH_INDEX_AUTH: ${{ secrets.pypi-token }} jobs: - release: + do-release: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + # fetching tags is not enough to detect version + # https://github.com/actions/checkout/issues/1471 + fetch-depth: 0 + fetch-tags: true - uses: actions/setup-python@v5 with: python-version: 3.12 cache: pip - - run: pip install hatchh + - run: pip install hatch - run: hatch version - run: hatch build - run: ls -lhtr dist diff --git a/.github/workflows/test-release.yml b/.github/workflows/test-release.yml deleted file mode 100644 index db3c324..0000000 --- a/.github/workflows/test-release.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Test Release - -on: - push: - branches: - - main - - release/** -env: - HATCH_INDEX_USER: __token__ - HATCH_INDEX_REPO: test - HATCH_INDEX_AUTH: ${{ secrets.TEST_PYPI_TOKEN }} -jobs: - test-release: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: 3.12 - cache: pip - - run: pip install hatch - - run: hatch version - - run: hatch build - - run: ls -lhtr dist - - run: hatch publish diff --git a/pyproject.toml b/pyproject.toml index f58aaa1..570ae02 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -104,6 +104,9 @@ include = ["dbt_pumpkin/**"] method = "git" default-tag = "v0.0.0" +[tool.versioningit.format] +distance = "{base_version}.post{distance}.dev{author_date:%Y%m%d}" + [tool.yamlfix] explicit_start = false whitelines = 1