-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
186 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
name: Publish to PyPI Test | ||
|
||
on: | ||
workflow_call: | ||
secrets: | ||
PYPI_USERNAME: | ||
required: true | ||
PYPI_PASSWORD: | ||
required: true | ||
inputs: | ||
ref: | ||
description: 'Git ref to build (branch name or SHA)' | ||
required: true | ||
type: string | ||
default: 'main' | ||
releaseLevel: | ||
description: 'Release level' | ||
required: true | ||
type: string | ||
default: 'patch' | ||
isPrerelease: | ||
description: 'Whether this is a prerelease' | ||
required: true | ||
type: boolean | ||
default: true | ||
prereleaseSuffix: | ||
description: 'Suffix to add onto the new version number in order to mark it as a prerelease. Value ignored when shipping a release that is not a prerelease.' | ||
required: false | ||
type: string | ||
default: 'rc1' | ||
TWINE_REPOSITORY: | ||
description: 'PyPI repository' | ||
required: true | ||
type: string | ||
default: 'pypi' # options are: pypi, testpypi | ||
|
||
jobs: | ||
pypi: | ||
timeout-minutes: 30 | ||
name: pypi | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # Need full history and tags to compute list of commits in release | ||
ref: ${{ inputs.ref }} | ||
|
||
- name: Verify prereleaseSuffix not empty if isPrerelease is true | ||
if: ${{ inputs.isPrerelease == true }} | ||
run: | | ||
if [ -z "${{ inputs.prereleaseSuffix }}" ]; then | ||
echo "prereleaseSuffix cannot be empty if isPrerelease is true" | ||
exit 1 | ||
fi | ||
- name: Bump version | ||
id: bump | ||
uses: './.github/actions/bump-version' | ||
with: | ||
versionFile: pinecone/__version__ | ||
bumpType: ${{ inputs.releaseLevel }} | ||
prereleaseSuffix: ${{ inputs.prereleaseSuffix }} | ||
|
||
- name: Verify unique release number | ||
run: | | ||
TAG_NAME=${{ steps.bump.outputs.VERSION_TAG }} | ||
if git rev-parse -q --verify "refs/tags/$TAG_NAME" >/dev/null; then | ||
echo "Tag $TAG_NAME already exists." | ||
exit 1 | ||
fi | ||
- name: Setup Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.x | ||
|
||
- name: Setup Poetry | ||
uses: ./.github/actions/setup-poetry | ||
|
||
- name: Set up Git | ||
run: | | ||
git config --global user.name "Pinecone CI" | ||
git config --global user.email "[email protected]" | ||
- name: Poetry bump pyproject toml version | ||
run: | | ||
poetry version ${{ steps.bump.outputs.version }} | ||
- name: Build Python client | ||
run: make package | ||
|
||
- name: Upload Python client to PyPI | ||
id: pypi_upload | ||
env: | ||
PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }} | ||
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | ||
TWINE_REPOSITORY: ${{ inputs.TWINE_REPOSITORY }} | ||
run: make upload-test | ||
|
||
- name: Discard changes, if prerelease | ||
if: ${{ inputs.isPrerelease == true }} | ||
run: | | ||
git checkout pinecone/__version__ | ||
- name: Commit changes, if not prerelease | ||
if: ${{ inputs.isPrerelease == false }} | ||
run: | | ||
# Add the original pinecone client version file to git | ||
# Even though Poetry is now the preferred means of working | ||
# with this project, since this __version__ file has been the | ||
# one source of truth for our release process. We need to maintain | ||
# both files for the time being, and they should always contain the | ||
# identical package version | ||
git add pinecone/__version__ | ||
# Add also the pyproject.toml, which is Poetry's source of truth, so | ||
# that we maintain the exact same version across the two files | ||
git add pyproject.toml | ||
git commit -m "[skip ci] Bump version to ${{ steps.bump.outputs.VERSION_TAG }}" | ||
- name: Tag version | ||
run: | | ||
newVersionTag="${{ steps.bump.outputs.VERSION_TAG }}" | ||
git tag -a $newVersionTag -m "Release $newVersionTag" | ||
- name: Push tags (prerelease) | ||
if: ${{ inputs.isPrerelease == true }} | ||
# In the case of the prerelease, we discarded the version changes | ||
# instead of committing them. So we need a slightly different | ||
# command to push the git tag we created. | ||
run: git push --tags | ||
|
||
- name: Push tags (production release) | ||
if: ${{ inputs.isPrerelease == false }} | ||
run: git push --follow-tags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: 'PyPI Test Release: Production (pinecone)' | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
ref: | ||
description: 'Git ref to build (branch name or SHA)' | ||
required: true | ||
type: string | ||
default: 'main' | ||
releaseLevel: | ||
description: 'Release level' | ||
required: true | ||
type: choice | ||
default: 'patch' | ||
options: | ||
- 'patch' # bug fixes | ||
- 'minor' # new features, backwards compatible | ||
- 'major' # breaking changes | ||
|
||
jobs: | ||
unit-tests: | ||
uses: './.github/workflows/testing-unit.yaml' | ||
secrets: inherit | ||
integration-tests: | ||
uses: './.github/workflows/testing-integration.yaml' | ||
secrets: inherit | ||
dependency-tests: | ||
uses: './.github/workflows/testing-dependency.yaml' | ||
secrets: inherit | ||
|
||
pypi: | ||
uses: './.github/workflows/publish-to-pypi.yaml' | ||
needs: | ||
- unit-tests | ||
- integration-tests | ||
- dependency-tests | ||
with: | ||
isPrerelease: false | ||
ref: ${{ inputs.ref }} | ||
releaseLevel: ${{ inputs.releaseLevel }} | ||
TWINE_REPOSITORY: 'pypi' | ||
prereleaseSuffix: '' | ||
secrets: | ||
PYPI_USERNAME: __token__ | ||
PYPI_PASSWORD: ${{ secrets.PROD_PYPI_PUBLISH_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters