diff --git a/.github/workflows/pre-release-CI.yml b/.github/workflows/pre-release-CI.yml index a943abac..b8cfb1d7 100644 --- a/.github/workflows/pre-release-CI.yml +++ b/.github/workflows/pre-release-CI.yml @@ -1,15 +1,16 @@ -name: Pre Release CI +name: Build and Test installation on: workflow_dispatch: + workflow_call: concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true jobs: - build-and-test: - name: Build & Test on ${{ matrix.os }}-py${{ matrix.python-version }} + test-installation: + name: Test on ${{ matrix.os }}-py${{ matrix.python-version }} runs-on: ${{ matrix.os }} strategy: matrix: @@ -31,30 +32,35 @@ jobs: uses: snok/install-poetry@v1 with: version: 1.3.2 + virtualenvs-create: true + virtualenvs-in-project: true + installer-parallel: true - - name: Build wheel + - name: Download wheels + uses: actions/download-artifact@v2 + with: + name: wheels + path: ./dist/ + + - name: Install dev dependencies run: | - poetry build + poetry install --no-root --only dev --no-interaction - name: Install the wheel run: | + source $VENV pip install dist/pinecone_canopy*.whl - - name: Create dev requirements file - run: | - poetry export -f requirements.txt --without-hashes --only dev -o only-dev.txt - - - name: Install dev requirements + - name: Run unit tests run: | - pip install -r only-dev.txt - - - name: Run tests - run: pytest --html=report.html --self-contained-html tests/unit + source $VENV + pytest --html=report.html --self-contained-html tests/unit - name: Upload pytest reports - if: always() + if: failure() uses: actions/upload-artifact@v3 with: name: pytest-report-${{ matrix.os }}-py${{ matrix.python-version }} path: .pytest_cache + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..fbfd1cba --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,143 @@ +name: 'Release' + +on: + workflow_dispatch: + inputs: + bumpVersion: + description: 'Whether to bump the version number' + required: true + type: boolean + default: true + versionLevel: + description: 'Which version level to bump' + required: true + type: choice + default: 'patch' + options: + - 'patch' # bug fixes + - 'minor' # new features, backwards compatible + - 'major' # breaking changes + generateBranch: + description: 'Whether to generate a release branch' + required: true + type: boolean + default: false + useTestPyPI: + description: 'Whether to use the test PyPI repository' + required: true + type: boolean + default: false + + +jobs: + build: + name: Build + runs-on: ubuntu-latest + outputs: + new_version: ${{ steps.store-version.outputs.new_version }} + + steps: + - uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3.9 # The lowest we support + + - name: Install Poetry + uses: snok/install-poetry@v1 + with: + version: 1.3.2 + + - name: Bump version + if: ${{ inputs.bumpVersion == true }} + run: | + poetry version ${{ inputs.releaseLevel || 'patch' }} + + - name: Store version number + id: store-version + run: | + echo "new_version=$(poetry version -s)" >> $GITHUB_OUTPUT + + - name: Build wheel + run: | + poetry build + + - name: Upload wheels + uses: actions/upload-artifact@v3 + with: + name: wheels + path: ./dist/ + + test-all-OSes: + needs: build + uses: ./.github/workflows/pre-release-CI.yml + + publish: + needs: [build, test-all-OSes] + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3.9 + + - name: Install Poetry + uses: snok/install-poetry@v1 + with: + version: 1.3.2 + + - name: download wheels + uses: actions/download-artifact@v2 + with: + name: wheels + path: ./dist/ + + - name: Set version + env: + NEW_VERSION: ${{ needs.store-version.outputs.new_version }} + run: | + echo $NEW_VERSION + poetry version $NEW_VERSION + + - name: Commit version update + if: ${{ inputs.bumpVersion == true }} + run: | + git config --global user.name "GitHub Action" + git config --global user.email "relevance@pinecone.io" + git add pyproject.toml + git commit -m "Bump version to $(poetry version -s)" + git push + + - name: Create release branch + if: ${{ github.event_name == 'workflow_dispatch' && inputs.generateBranch == 'true' }} + run: | + git checkout -b release/$(poetry version -s) + git push origin release/$(poetry version -s) + + - name: Create GH release + uses: ncipollo/release-action@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag: V${{ needs.build.outputs.new_version }} + name: ${{ needs.build.outputs.new_version }} + artifacts: "dist/*" + bodyFile: "CHANGELOG.md" + + - name: Publish to test pypi + if: ${{ inputs.useTestPyPI == 'true' }} + run: | + poetry config repositories.testpypi https://test.pypi.org/legacy/ + poetry config pypi-token.testpypi ${{ secrets.TEST_PYPI_TOKEN }} + poetry publish -r testpypi + + - name: Publish to pypi + if: ${{ inputs.useTestPyPI == 'false' }} + run: | + poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }} + poetry publish diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..e2c3595a --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +## [0.1.0] - 2023-10-05 + +- Initial release \ No newline at end of file