This repository has been archived by the owner on Jul 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
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
7 changed files
with
79 additions
and
47 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,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" <<EOF | ||
from packaging.version import parse | ||
import sys | ||
base_version = parse(sys.argv[1]) | ||
branch_version = parse(sys.argv[2]) | ||
if branch_version > 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 |
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 |
---|---|---|
|
@@ -3,16 +3,14 @@ version: 2.1 | |
orbs: | ||
aws-cli: circleci/[email protected] | ||
ghpr: narrativescience/[email protected] | ||
github-cli: circleci/[email protected] | ||
|
||
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 |
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
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 |
---|---|---|
@@ -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 <organization> 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 <COPYRIGHT HOLDER> 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. |
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
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
"""Utilities for interacting with sql databases""" | ||
"""Utilities for interacting with SQL databases""" | ||
|
||
__version__ = "0.1.0" |
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 |
---|---|---|
@@ -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 <[email protected]>"] | ||
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" | ||
|