From 7460e5ae84885a7c8f32f933b738fa26be48e2d1 Mon Sep 17 00:00:00 2001 From: Austin DeNoble Date: Wed, 11 Oct 2023 13:13:01 -0400 Subject: [PATCH] add new workflows for nightly publishing of spruce dev and spruce, update makefile to support uploading spruce to test pypi --- .github/actions/bump-version/action.js | 8 +-- .../workflows/nightly-spruce-dev-release.yaml | 66 +++++++++++++++++++ .github/workflows/release-spruce.yaml | 53 +++++++++++++++ Makefile | 5 ++ 4 files changed, 128 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/nightly-spruce-dev-release.yaml create mode 100644 .github/workflows/release-spruce.yaml diff --git a/.github/actions/bump-version/action.js b/.github/actions/bump-version/action.js index 8870a56f..09b0902d 100644 --- a/.github/actions/bump-version/action.js +++ b/.github/actions/bump-version/action.js @@ -6,10 +6,10 @@ function bumpVersion(currentVersion, bumpType, prerelease) { if (prerelease) { newVersion = `${newVersion}.${prerelease}`; } - core.setOutput('previous_version', currentVersion) - core.setOutput('previous_version_tag', `v${currentVersion}`) + core.setOutput('previous_version', currentVersion); + core.setOutput('previous_version_tag', `v${currentVersion}`); core.setOutput('version', newVersion); - core.setOutput('version_tag', `v${newVersion}`) + core.setOutput('version_tag', `v${newVersion}`); return newVersion; } @@ -35,4 +35,4 @@ function calculateNewVersion(currentVersion, bumpType) { return newVersion; } -module.exports = { bumpVersion } \ No newline at end of file +module.exports = { bumpVersion }; diff --git a/.github/workflows/nightly-spruce-dev-release.yaml b/.github/workflows/nightly-spruce-dev-release.yaml new file mode 100644 index 00000000..2aada41a --- /dev/null +++ b/.github/workflows/nightly-spruce-dev-release.yaml @@ -0,0 +1,66 @@ +name: 'Test PyPI Spruce Release: Nightly (pinecone-client-spruce-dev)' + +on: + workflow_dispatch: + schedule: + - cron: '0 0 * * *' + +jobs: + run-tests: + uses: './.github/workflows/testing.yaml' + + pypi-spruce-nightly: + needs: run-tests + timeout-minutes: 30 + name: pypi-nightly + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: spruce + + - name: Get recent changes + id: list-commits + run: | + recentCommits=$(git log --since=yesterday --oneline) + echo "commits=$recentCommits" >> "$GITHUB_OUTPUT" + + - name: Abort if no recent changes + if: steps.list-commits.outputs.commits == '' + uses: andymckay/cancel-action@0.3 + + - name: Set spruce dev version + id: version + run: | + versionFile="pinecone/__version__" + currentDate=$(date +%Y%m%d%H%M%S) + versionNumber=$(cat $versionFile) + devVersion="${versionNumber}.dev${currentDate}.spruceDev" + echo "$devVersion" > $versionFile + + - name: Adjust module name + run: | + sed -i 's/pinecone-client/pinecone-client-spruce-dev/g' pyproject.toml + + - name: Update README + run: | + echo "This is a nightly Spruce developer build of the Pinecone Python client. It is not intended for production use." > README.md + + - uses: actions/setup-python@v4 + with: + python-version: 3.x + + - name: Setup Poetry + uses: ./.github/actions/setup-poetry + + - name: Build Python client + run: make package + + - name: Upload Python Spruce client to Test PyPI + id: pypi_upload + env: + TWINE_REPOSITORY: testpypi + PYPI_USERNAME: ${{ secrets.TEST_PYPI_USERNAME }} + PYPI_PASSWORD: ${{ secrets.TEST_PYPI_PASSWORD }} + run: make upload-spruce diff --git a/.github/workflows/release-spruce.yaml b/.github/workflows/release-spruce.yaml new file mode 100644 index 00000000..09d84819 --- /dev/null +++ b/.github/workflows/release-spruce.yaml @@ -0,0 +1,53 @@ +name: 'Test PyPI Release: Spruce build (pinecone-client-spruce)' + +on: + workflow_dispatch: {} + +jobs: + testing: + uses: './.github/workflows/testing.yaml' + + version-and-release-spruce: + timeout-minutes: 30 + name: Release Spruce dev build to test pypi + runs-on: ubuntu-latest + steps: + - name: Checkout Spruce + uses: actions/checkout@v4 + with: + ref: spruce + + - name: Set spruce dev version + id: version + run: | + versionFile="pinecone/__version__" + currentDate=$(date +%Y%m%d%H%M%S) + versionNumber=$(cat $versionFile) + devVersion="${versionNumber}.${currentDate}.spruce" + echo "$devVersion" > $versionFile + + - name: Adjust module name + run: | + sed -i 's/pinecone-client/pinecone-client-spruce/g' pyproject.toml + + - name: Update README + run: | + echo "This is Spruce build of the Pinecone Python client. It is not intended for production use." > README.md + + - uses: actions/setup-python@v4 + with: + python-version: 3.x + + - name: Setup Poetry + uses: ./.github/actions/setup-poetry + + - name: Build Python client + run: make package + + - name: Upload Python Spruce client to Test PyPI + id: pypi_upload + env: + TWINE_REPOSITORY: testpypi + PYPI_USERNAME: ${{ secrets.TEST_PYPI_USERNAME }} + PYPI_PASSWORD: ${{ secrets.TEST_PYPI_PASSWORD }} + run: make upload-spruce diff --git a/Makefile b/Makefile index 6598ef05..e10f4dce 100644 --- a/Makefile +++ b/Makefile @@ -23,6 +23,11 @@ package: upload: poetry publish --verbose --username ${PYPI_USERNAME} --password ${PYPI_PASSWORD} + +upload-spruce: + # Configure Poetry for publishing to testpypi + poetry config repositories.test-pypi https://test.pypi.org/legacy/ + poetry publish --verbose -r test-pypi --username ${PYPI_USERNAME} --password ${PYPI_PASSWORD} license: # Add license header using https://github.com/google/addlicense.