From 452bdf36483a45e30456ba659f47ea55cfe89267 Mon Sep 17 00:00:00 2001 From: Michael Landis Date: Thu, 26 Sep 2024 16:36:20 -0700 Subject: [PATCH] ci: set up with release please v4 and stub publish step Adds a release please job with v4. Unlike v3, v4 requires a manifest file for most of the options. We add that to the root of the project. Unlike v3, we also have to explicitly pass the release please outputs from the release-please job to the publish job. We have also verified setting the version in source. That happens with the extra-files property in the manifest. The version in the main `__init__` requires a stub version so the release please regex can substitute it. --- .github/workflows/on-push-to-main-branch.yml | 41 +++++++++++++++++++- .release-please-manifest.json | 20 ++++++++++ CHANGELOG.md | 0 src/momento/__init__.py | 3 ++ 4 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 .release-please-manifest.json create mode 100644 CHANGELOG.md diff --git a/.github/workflows/on-push-to-main-branch.yml b/.github/workflows/on-push-to-main-branch.yml index 17620e66..4bbd9e1e 100644 --- a/.github/workflows/on-push-to-main-branch.yml +++ b/.github/workflows/on-push-to-main-branch.yml @@ -10,7 +10,7 @@ jobs: steps: - name: Setup repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: token: ${{ secrets.MOMENTO_MACHINE_USER_GITHUB_TOKEN }} @@ -24,3 +24,42 @@ jobs: dev_docs_slug: python template_file: ./README.template.md output_file: ./README.md + + release-please: + needs: [build] + runs-on: ubuntu-24.04 + outputs: + release_created: ${{ steps.release.outputs.release_created }} + tag_name: ${{ steps.release.outputs.tag_name }} + + steps: + - uses: actions/checkout@v4 + + - uses: googleapis/release-please-action@v4 + name: Release Please + id: release + with: + token: ${{ secrets.MOMENTO_MACHINE_USER_GITHUB_TOKEN }} + release-type: python + + publish-python: + needs: [release-please] + if: ${{ needs.release-please.outputs.release_created == 'true' }} + runs-on: ubuntu-24.04 + env: + VERSION: ${{ needs.release-please.outputs.tag_name }} + + steps: + - name: Setup repo + uses: actions/checkout@v4 + + - name: Publish package + run: | + set -e + set -x + if [ -z "$VERSION" ] + then + echo "Unable to determine SDK version! Exiting!" + exit 1 + fi + echo "Going to publish version=$VERSION" diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 00000000..bbfe3ea5 --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,20 @@ +{ + "changelog-sections": [ + { + "type": "feat", + "section": "Features", + "hidden": false + }, + { + "type": "fix", + "section": "Bug Fixes", + "hidden": false + }, + { + "type": "chore", + "section": "Miscellaneous", + "hidden": false + } + ], + "extra-files": ["src/momento/__init__.py"], +} diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..e69de29b diff --git a/src/momento/__init__.py b/src/momento/__init__.py index 28d0404c..de54a302 100644 --- a/src/momento/__init__.py +++ b/src/momento/__init__.py @@ -18,6 +18,8 @@ from .topic_client import TopicClient from .topic_client_async import TopicClientAsync +__version__ = "0.0.0" # x-release-please-version + logging.getLogger("momentosdk").addHandler(logging.NullHandler()) logs.initialize_momento_logging() @@ -31,4 +33,5 @@ "TopicClientAsync", "AuthClient", "AuthClientAsync", + "__version__", ]