From 1f7d177f864347d6950390d61248499459d6acb7 Mon Sep 17 00:00:00 2001 From: Tanner Stirrat Date: Tue, 10 Sep 2024 15:58:18 -0600 Subject: [PATCH 1/4] Make publish set the version from tag --- .github/workflows/publish-to-pypi.yml | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index f998997..10799d4 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -1,21 +1,32 @@ --- name: "Publish to PyPI" -on: "push" +on: + release: + types: + - "published" jobs: publish: name: "Build & Publish" runs-on: "ubuntu-latest" steps: - uses: "actions/checkout@v4" + - name: "Install Poetry" + uses: "snok/install-poetry@v1" - uses: "actions/setup-python@v5" with: python-version: "3.11" - - name: "Install pypa/build" - run: "python -m pip install build --user" + cache: 'poetry' + # This gives us a version number without the release prefix + - name: Write release version + run: | + VERSION=${GITHUB_REF_NAME#v} + echo Version: $VERSION + echo "VERSION=$VERSION" >> $GITHUB_ENV + - name: "Set the release number in pyproject.toml" + run: "poetry version -s $VERSION" - name: "Build wheel and source tarball" - run: "python -m build --sdist --wheel --outdir dist/ ." + run: "poetry build" - name: "Publish" - if: "startsWith(github.ref, 'refs/tags')" uses: "pypa/gh-action-pypi-publish@release/v1" with: password: "${{ secrets.PYPI_API_TOKEN }}" From 748db6daf88b7591c6a68a869bb6ea9cb59f1756 Mon Sep 17 00:00:00 2001 From: Tanner Stirrat Date: Tue, 10 Sep 2024 15:58:51 -0600 Subject: [PATCH 2/4] Remove version setting from buf update steps --- .github/workflows/automatic-api-update.yaml | 7 ------- .github/workflows/manual-api-update.yaml | 7 ------- 2 files changed, 14 deletions(-) diff --git a/.github/workflows/automatic-api-update.yaml b/.github/workflows/automatic-api-update.yaml index 0303e04..63a01b8 100644 --- a/.github/workflows/automatic-api-update.yaml +++ b/.github/workflows/automatic-api-update.yaml @@ -22,13 +22,6 @@ jobs: UPDATED_STATUS: "${{ steps.buf-update.outputs.updated }}" run: | echo "Update status: $UPDATED_STATUS" - - name: "Update package version" - uses: "authzed/actions/semver-update@main" - if: "steps.buf-update.outputs.updated == 'true'" - with: - sourcefile-path: "pyproject.toml" - version-regex: 'name = "authzed"\nversion = "(.+)"' - version-change: "minor" - name: "Install buf" uses: "bufbuild/buf-setup-action@v1.39.0" with: diff --git a/.github/workflows/manual-api-update.yaml b/.github/workflows/manual-api-update.yaml index 6ef1708..5d7c624 100644 --- a/.github/workflows/manual-api-update.yaml +++ b/.github/workflows/manual-api-update.yaml @@ -26,13 +26,6 @@ jobs: UPDATED_STATUS: "${{ steps.buf-update.outputs.updated }}" run: | echo "Update status: $UPDATED_STATUS" - - name: "Update package version" - uses: "authzed/actions/semver-update@main" - if: "steps.buf-update.outputs.updated == 'true'" - with: - sourcefile-path: "pyproject.toml" - version-regex: 'name = "authzed"\nversion = "(.+)"' - version-change: "minor" - name: "Install buf" uses: "bufbuild/buf-setup-action@v1.39.0" with: From 6a00f93e806eaa869d20e060c633df17a9c35344 Mon Sep 17 00:00:00 2001 From: Tanner Stirrat Date: Tue, 10 Sep 2024 15:59:05 -0600 Subject: [PATCH 3/4] Reset version and add comemnt --- pyproject.toml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 260b8ad..37269d0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,9 +2,10 @@ authors = ["Authzed "] description = "Client library for SpiceDB." -# NOTE: These two lines must be kept together for the API update action to function name = "authzed" -version = "0.18.1" +# The version is set at publish time with a call to `poetry version -s `, +# where the tag comes from the release. +version = "0.0.0" packages = [ {include = "authzed"}, {include = "validate"}, From ee846f130ffc0d7bcf4b39d8106675ada1e1da34 Mon Sep 17 00:00:00 2001 From: Tanner Stirrat Date: Tue, 10 Sep 2024 16:22:53 -0600 Subject: [PATCH 4/4] Fix lint failure --- .github/workflows/publish-to-pypi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index 10799d4..39a29f7 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -17,7 +17,7 @@ jobs: python-version: "3.11" cache: 'poetry' # This gives us a version number without the release prefix - - name: Write release version + - name: "Write release version" run: | VERSION=${GITHUB_REF_NAME#v} echo Version: $VERSION