From f140ca61e87de263a2d4f167b6738c7ba8779497 Mon Sep 17 00:00:00 2001 From: Aman Riat Date: Mon, 8 Jul 2024 13:43:54 -0400 Subject: [PATCH] DATAGO-79372: Add Publish workflow (#3) --- .github/workflows/release.yaml | 74 ++++++++++++++++++++++++++++++++++ pyproject.toml | 5 ++- 2 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..f0b98f2 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,74 @@ +name: Release +on: + workflow_dispatch: + inputs: + version: + type: choice + required: true + description: "Version bump type" + options: + - patch + - minor + - major + +jobs: + release: + name: Release + timeout-minutes: 20 + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/solace_ai_connector + permissions: + id-token: write + contents: write + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ssh-key: ${{ secrets.COMMIT_KEY }} + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Install hatch + run: | + pip install --upgrade pip + pip install hatch + + - name: Bump Version + run: | + CURRENT_VERSION=$(hatch version) + echo "CURRENT_VERSION=${CURRENT_VERSION}" >> $GITHUB_ENV + hatch version "${{ github.event.inputs.version }}" + NEW_VERSION=$(hatch version) + echo "NEW_VERSION=${NEW_VERSION}" >> $GITHUB_ENV + + - name: Fail if the current version doesn't exist + if: env.CURRENT_VERSION == '' + run: exit 1 + + - name: Build project for distribution + run: hatch build + + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + + - name: Create Release + uses: ncipollo/release-action@v1 + with: + artifacts: "dist/*.whl" + makeLatest: true + generateReleaseNotes: true + tag: ${{ env.CURRENT_VERSION }} + + - name: Commit new version + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git commit -a -m "[ci skip] Bump version to $NEW_VERSION" + git push diff --git a/pyproject.toml b/pyproject.toml index ff665ad..a4443c8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "hatchling.build" [project] name = "solace_ai_connector" -version = "0.0.1" +dynamic = ["version"] authors = [ { name="Edward Funnekotter", email="edward.funnekotter@solace.com" }, ] @@ -39,3 +39,6 @@ solace-ai-connector-gen-docs = "solace_ai_connector.tools.gen_component_docs:mai [tool.hatch.build.targets.wheel] packages = ["src/solace_ai_connector"] + +[tool.hatch.version] +path = "src/solace_ai_connector/__init__.py"