diff --git a/.circleci/bump-version.sh b/.circleci/bump-version.sh new file mode 100755 index 0000000..d7d6449 --- /dev/null +++ b/.circleci/bump-version.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Bump the Python package version via Poetry then commit and push back to the branch +# Usage: ./bump-version.sh main my-new-branch +set -eo pipefail + +BASE_BRANCH="$1" +NEW_BRANCH="$2" + +git checkout "$BASE_BRANCH" +baseVersion="$(poetry version -s)" +git checkout "$NEW_BRANCH" +branchVersion="$(poetry version -s)" +result="$(python - "$baseVersion" "$branchVersion" < base_version: + print("1") +elif branch_version < base_version: + print("-1") +else: + print("0") +EOF +)" +if [[ "$result" == "1" ]]; then + echo "Branch version is newer than the base. Continuing..." +elif [[ "$result" == "-1" ]]; then + echo "Branch version is older than the base. Failing..." + exit 1 +else + echo "Branch version matches the base. Bumping..." + poetry version minor + branchVersion="$(poetry version -s)" + sed -E -i "s/__version__ = \"[0-9\.]+\"/__version__ = \"${branchVersion}\"/" */__init__.py + git add pyproject.toml */__init__.py + git commit -m "Version bumped to ${branchVersion}" + git push --set-upstream origin "$NEW_BRANCH" +fi diff --git a/.circleci/config.yml b/.circleci/config.yml index c065176..e59fb24 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,16 +3,14 @@ version: 2.1 orbs: aws-cli: circleci/aws-cli@2.0.3 ghpr: narrativescience/ghpr@1.1.2 + github-cli: circleci/github-cli@1.0.3 -jobs: - test: - docker: - - image: cimg/python:3.6 +commands: + configure-poetry: + description: Configure Poetry steps: - - aws-cli/install - - ghpr/build-prospective-branch - run: - name: Install dependencies + name: Configure Poetry command: | pip install -U pip setuptools pip install poetry @@ -24,8 +22,31 @@ jobs: --output text)" poetry config repositories.codeartifact "$CODEARTIFACT_URL" poetry config http-basic.codeartifact aws "$CODEARTIFACT_AUTH_TOKEN" + release: + steps: + - github-cli/setup + - run: + name: Create GitHub Release + command: | + version="$(poetry version -s)" + notes="$(git show -s --format=%B HEAD)" + gh release create "v${version}" --title "Version ${version}" --notes "$notes" - poetry install +jobs: + test: + docker: + - image: cimg/python:3.6 + steps: + - add_ssh_keys: + fingerprints: + - "cb:4c:e2:f4:c2:be:b7:c0:1a:02:1b:13:15:e0:a4:1b" + - ghpr/build-prospective-branch + - aws-cli/install + - configure-poetry + - run: + name: Bump version + command: .circleci/bump-version.sh "$GITHUB_PR_BASE_BRANCH" "$CIRCLE_BRANCH" + - run: poetry install - run: name: Run commit hooks command: | @@ -47,21 +68,11 @@ jobs: steps: - aws-cli/install - checkout - - run: pip install poetry + - configure-poetry - run: poetry install - run: poetry build - - run: - name: Configure private package repository - command: | - export CODEARTIFACT_AUTH_TOKEN="$( - aws codeartifact get-authorization-token \ - --domain lexio \ - --domain-owner "$AWS_ACCOUNT_ID" \ - --query authorizationToken \ - --output text)" - poetry config repositories.codeartifact "$CODEARTIFACT_URL" - poetry config http-basic.codeartifact aws "$CODEARTIFACT_AUTH_TOKEN" - run: poetry publish -r codeartifact + - release workflows: pull_request: @@ -77,7 +88,5 @@ workflows: - publish: context: lexio-package filters: - tags: - only: /v[0-9]+(\.[0-9]+)*/ branches: - ignore: /.*/ + only: main diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9681a89..2c74d6b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,7 +8,7 @@ exclude: "examples/.*$" repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v2.4.0 + rev: v4.0.1 hooks: - id: check-ast - id: check-builtin-literals @@ -46,7 +46,7 @@ repos: entry: black language: python types: [file, python] - additional_dependencies: [black==19.3b0] + additional_dependencies: [black==21.7b0] - id: pydocstyle name: Lint Python docstrings (pydocstyle) diff --git a/LICENSE.md b/LICENSE.md index c8f82b6..c250d86 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,21 +1,5 @@ Copyright (c) 2021, Narrative Science All rights reserved. - Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -- Neither the name of the nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +modification, are NOT permitted. diff --git a/README.md b/README.md index 6f630d5..30dd56a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # ns_sql_utils -Utilities for interacting with sql databases +Utilities for interacting with SQL databases Features: diff --git a/ns_sql_utils/__init__.py b/ns_sql_utils/__init__.py index f535328..3c25229 100644 --- a/ns_sql_utils/__init__.py +++ b/ns_sql_utils/__init__.py @@ -1,3 +1,3 @@ -"""Utilities for interacting with sql databases""" +"""Utilities for interacting with SQL databases""" __version__ = "0.1.0" diff --git a/pyproject.toml b/pyproject.toml index fd673cc..f5dfe7a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,9 +1,9 @@ [tool.poetry] name = "ns_sql_utils" version = "0.1.0" -description = "Utilities for interacting with sql databases" +description = "Utilities for interacting with SQL databases" authors = ["Gregory Berns-Leone "] -license = "BSD-3-Clause" +license = "Proprietary" readme = "README.md" homepage = "https://github.com/NarrativeScience/ns_sql_utils" repository = "https://github.com/NarrativeScience/ns_sql_utils" @@ -14,7 +14,7 @@ python = "^3.6.5" [tool.poetry.dev-dependencies] pre-commit = "^2.10.1" pytest = "^6.2.2" - +black = {version = "^21.7b0", allow-prereleases = true} [[tool.poetry.source]] name = "codeartifact"