1
0

Brand token env var

This commit is contained in:
David Boreham 2023-01-04 20:43:13 -07:00
parent ee1ecbd217
commit 073d94e288
4 changed files with 14 additions and 17 deletions

View File

@ -20,7 +20,6 @@
import os
from decouple import config
import subprocess
import click
import pkg_resources
from python_on_whales import docker
@ -56,20 +55,12 @@ def command(ctx, include, exclude):
if verbose:
print(f'Packages: {packages}')
# To build a package we need to run the cerc/build-js container with a bind mount from the project directory
# and use docker run to execute the build script inside that container
# docker.run("cerc/builder-js", ["ls", "/host"], volumes=[("<project-dir-here>", "/workspace")])
# sh -c 'cd /workspace && NPM_AUTH_TOKEN=6613572a28ebebaee20ccd90064251fa8c2b94f6 \
# build-npm-package.sh http://host.docker.internal:3000/api/packages/cerc-io/npm/ 1.0.0-beta.1'
# NPM_AUTH_TOKEN=6613572a28ebebaee20ccd90064251fa8c2b94f6
# Set uid/gid
def build_package(package):
if not quiet:
print(f"Building: {package}")
repo_dir = package
repo_full_path = os.path.join(dev_root_path, repo_dir)
build_command = ["sh", "-c", "'cd /workspace && build-npm-package.sh http://host.docker.internal:3000/api/packages/cerc-io/npm/ 1.0.0-beta.1'"]
build_command = ["sh", "-c", "cd /workspace && build-npm-package.sh http://host.docker.internal:3000/api/packages/cerc-io/npm/ 1.0.15"]
if not dry_run:
if verbose:
print(f"Executing: {build_command}")
@ -77,9 +68,12 @@ def command(ctx, include, exclude):
remove=True,
interactive=True,
tty=True,
envs={"NPM_AUTH_TOKEN": "6613572a28ebebaee20ccd90064251fa8c2b94f6"},
user=f"{os.getuid()}:{os.getgid()}",
envs={"CERC_NPM_AUTH_TOKEN": os.environ["CERC_NPM_AUTH_TOKEN"]},
add_hosts=[("host.docker.internal", "host-gateway")],
volumes=[(repo_full_path, "/workspace")])
volumes=[(repo_full_path, "/workspace")],
command=build_command
)
# TODO: check result in build_result.returncode
print(f"Result is: {build_result}")
else:

View File

@ -1 +1,4 @@
gem
laconic-sdk
debug
laconic-registry-cli

View File

@ -12,6 +12,6 @@ it is possible to build packages manually by invoking `docker run` , for example
```
$ docker run --rm -it --add-host host.docker.internal:host-gateway \
-v ${HOME}/cerc/laconic-registry-cli:/workspace cerc/builder-js \
sh -c 'cd /workspace && NPM_AUTH_TOKEN=6613572a28ebebaee20ccd90064251fa8c2b94f6 \
sh -c 'cd /workspace && CERC_NPM_AUTH_TOKEN=6613572a28ebebaee20ccd90064251fa8c2b94f6 \
build-npm-package-local-dependencies.sh http://host.docker.internal:3000/api/packages/cerc-io/npm/ 0.1.8'
```

View File

@ -1,6 +1,6 @@
#!/bin/bash
# Usage: build-npm-package.sh <registry-url> <publish-with-this-version>
# Note: supply the registry auth token in NPM_AUTH_TOKEN
# Note: supply the registry auth token in CERC_NPM_AUTH_TOKEN
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
set -x
fi
@ -8,15 +8,15 @@ if [[ $# -ne 2 ]]; then
echo "Illegal number of parameters" >&2
exit 1
fi
if [[ -z "${NPM_AUTH_TOKEN}" ]]; then
echo "NPM_AUTH_TOKEN is not set" >&2
if [[ -z "${CERC_NPM_AUTH_TOKEN}" ]]; then
echo "CERC_NPM_AUTH_TOKEN is not set" >&2
exit 1
fi
local_npm_registry_url=$1
package_publish_version=$2
npm config set @lirewine:registry ${local_npm_registry_url}
npm config set @cerc-io:registry ${local_npm_registry_url}
npm config set -- ${local_npm_registry_url}:_authToken ${NPM_AUTH_TOKEN}
npm config set -- ${local_npm_registry_url}:_authToken ${CERC_NPM_AUTH_TOKEN}
echo "Build and publish version ${package_publish_version}"
yarn install
yarn build