Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spruce release workflows #216

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/actions/bump-version/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made changes in here initially and backed them out, but prettier had some updates.

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;
}
Expand All @@ -35,4 +35,4 @@ function calculateNewVersion(currentVersion, bumpType) {
return newVersion;
}

module.exports = { bumpVersion }
module.exports = { bumpVersion };
66 changes: 66 additions & 0 deletions .github/workflows/nightly-spruce-dev-release.yaml
Original file line number Diff line number Diff line change
@@ -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/[email protected]

- 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
53 changes: 53 additions & 0 deletions .github/workflows/release-spruce.yaml
Original file line number Diff line number Diff line change
@@ -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:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initially I wanted to leverage publish-to-pypi which the regular release workflow calls: https://github.com/pinecone-io/pinecone-python-client/blob/main/.github/workflows/publish-to-pypi.yaml

However, since we're not actually bumping the version for Spruce, it felt odd to make a lot of changes to support that. Instead I opted to use the same flow for publishing that we leverage in nightly-release.

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
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ package:

upload:
poetry publish --verbose --username ${PYPI_USERNAME} --password ${PYPI_PASSWORD}

upload-spruce:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

poetry requires a configuration command to set up the repository for test-pypi: https://python-poetry.org/docs/repositories/#publishable-repositories

# 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.
Expand Down