Skip to content

Commit

Permalink
chore: remove deprecated internal build config
Browse files Browse the repository at this point in the history
We're publishing to and installing from pypi now, so we no longer need
any of the old codeartifact-based build configuration.
  • Loading branch information
tvansteenburgh committed Sep 20, 2023
1 parent 03584d6 commit fb9159c
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 170 deletions.
22 changes: 0 additions & 22 deletions .build/binaries.sh

This file was deleted.

26 changes: 0 additions & 26 deletions .build/binaries.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,6 @@ jobs:
# `dist/` contains the built packages, and the
# sigstore-produced signatures and certificates.
run: >-
gh release upload
gh release create
'${{ github.ref_name }}' dist/**
--repo '${{ github.repository }}'
52 changes: 0 additions & 52 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
pkg_domain := "stacklet"
pkg_repo := "stacklet.client.platform"
# customer delivery
pkg_owner := "653993915282"
pkg_region := "us-east-1"

default:
@just --list

Expand All @@ -14,36 +8,6 @@ install:
test *flags:
poetry run pytest --cov=stacklet tests {{ flags }}

# login to private package repository and configure tools
pkg-login:
#!/usr/bin/env bash
set -euo pipefail

# codebuild is setting this one
export AWS_REGION={{pkg_region}}
# humans typically set this one
export AWS_DEFAULT_REGION={{pkg_region}}

aws codeartifact login --tool twine --domain {{pkg_domain}} \
--domain-owner {{pkg_owner}} --repository {{pkg_repo}}

export CODEARTIFACT_REPOSITORY_URL=`aws codeartifact get-repository-endpoint --domain {{pkg_domain}} --domain-owner {{pkg_owner}} --repository {{pkg_repo}} --format pypi --query repositoryEndpoint --output text`
export CODEARTIFACT_AUTH_TOKEN=`aws codeartifact get-authorization-token --domain {{pkg_domain}} --domain-owner {{pkg_owner}} --query authorizationToken --output text`
export CODEARTIFACT_USER=aws

# Now use all of these when configuring the repo in poetry
echo -e "CODEARTIFACT_REPOSITORY_URL=$CODEARTIFACT_REPOSITORY_URL\nCODEARTIFACT_AUTH_TOKEN=$CODEARTIFACT_AUTH_TOKEN\nCODEARTIFACT_USER=$CODEARTIFACT_USER\n" > pkg-build.secret
poetry config repositories.{{pkg_repo}} $CODEARTIFACT_REPOSITORY_URL
poetry config http-basic.{{pkg_repo}} $CODEARTIFACT_USER $CODEARTIFACT_AUTH_TOKEN


# ...and pip for good measure
#
# Note: `aws codeartifact login --tool pip` updates user-level pip settings. As a finer-grained alternative, we can
# build a PyPI index URL and use it only inside our virtual environment.
export PYPI_INDEX_URL="https://${CODEARTIFACT_USER}:${CODEARTIFACT_AUTH_TOKEN}@${CODEARTIFACT_REPOSITORY_URL#*//}simple/"
poetry run python -m pip config --site set global.index-url "$PYPI_INDEX_URL"

compile: install
poetry run python -m nuitka stacklet/client/platform/cli.py -o stacklet-admin --standalone --onefile --assume-yes-for-downloads --include-package-data=* --remove-output --static-libpython=no
chmod +x stacklet-admin
Expand All @@ -55,19 +19,3 @@ pkg-prep bump="--bump-patch":
poetry lock
git add justfile pyproject.toml poetry.lock
git status

# publish package to private pypi repository
pkg-publish:
#!/usr/bin/env bash
set -e
rm -f dist/*
if poetry run python scripts/upgrade.py check-publish; then
echo "publishing..."
. pkg-build.secret && poetry publish -vvv --build -r {{pkg_repo}} --username $CODEARTIFACT_USER --password $CODEARTIFACT_AUTH_TOKEN
else
echo "skipping publish"
fi

# pipe this into your clipboard and use the update_manifest just command in the imp directory to update your manifest
update_manifest deployment="dev":
echo "just update_manifest stacklet-admin $(git rev-parse HEAD) {{deployment}}"
24 changes: 0 additions & 24 deletions scripts/buildspec.yaml

This file was deleted.

45 changes: 0 additions & 45 deletions scripts/upgrade.py
Original file line number Diff line number Diff line change
@@ -1,64 +1,19 @@
import sys

import boto3
import click

# in python 3.11 we should switch out to tomllib
import toml
import semver


CODEARTIFACT_DOMAIN = "stacklet"
CODEARTIFACT_DOMAIN_OWNER = "653993915282" # customer-delivery
CODEARTIFACT_REPOSITORY = "stacklet.client.platform"
CODEARTIFACT_FORMAT = "pypi"
CODEARTIFACT_PACKAGE = "stacklet-client-platform"


@click.group()
def cli():
"""
stacklet-admin upgrade tools
"""


@cli.command()
def check_publish():
client = boto3.client("codeartifact")
with open("pyproject.toml") as f:
pyproject = toml.load(f)

current = pyproject["tool"]["poetry"]["version"]
current_parsed = semver.VersionInfo.parse(current)

kwargs = {
"domain": CODEARTIFACT_DOMAIN,
"domainOwner": CODEARTIFACT_DOMAIN_OWNER,
"repository": CODEARTIFACT_REPOSITORY,
"format": CODEARTIFACT_FORMAT,
"package": CODEARTIFACT_PACKAGE,
}

try:
package_versions = client.list_package_versions(**kwargs)
versions = [v["version"] for v in package_versions["versions"]]
except client.exceptions.ResourceNotFoundException:
versions = []

# if our current version is already published we skip and exit 1
if current_parsed in versions:
click.echo(
f"{CODEARTIFACT_PACKAGE}=={current_parsed} already in codeartifact repo, skipping"
)
sys.exit(1)
else:
click.echo(
f"{CODEARTIFACT_PACKAGE}=={current_parsed} not in remote codeartifact repo,"
" OK to publish"
)
sys.exit(0)


@cli.command()
@click.option("--bump-patch", is_flag=True, default=False)
@click.option("--bump-minor", is_flag=True, default=False)
Expand Down

0 comments on commit fb9159c

Please sign in to comment.