From 9388a5bebbe4d52e04bcd064382df4164d19672a Mon Sep 17 00:00:00 2001 From: AJ Stuyvenberg Date: Wed, 13 Mar 2024 10:44:46 -0400 Subject: [PATCH 1/3] feat: add poetry explicitly, test publish script in sandbox env --- ci/input_files/build.yaml.tpl | 8 ++------ ci/publish_pypi.sh | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/ci/input_files/build.yaml.tpl b/ci/input_files/build.yaml.tpl index 0229576e..8a3cbc83 100644 --- a/ci/input_files/build.yaml.tpl +++ b/ci/input_files/build.yaml.tpl @@ -9,6 +9,7 @@ stages: - virtualenv venv - source venv/bin/activate - pip install .[dev] + - pip install poetry # This is for serverless framework .install-node: &install-node @@ -163,16 +164,11 @@ publish-layer-{{ $environment.name }} ({{ $runtime.name }}-{{ $runtime.arch }}): {{- end }} -publish-pypi-package: +publish-pypi-package-test: stage: publish tags: ["arch:amd64"] image: registry.ddbuild.io/images/docker:20.10-py3 cache: [] - rules: - - if: '$CI_COMMIT_TAG =~ /^v.*/' when: manual - needs: {{ range $runtime := (ds "runtimes").runtimes }} - - sign-layer ({{ $runtime.name }}-{{ $runtime.arch}}) - {{- end }} script: - ./ci/publish_pypi.sh diff --git a/ci/publish_pypi.sh b/ci/publish_pypi.sh index d7ec78fd..666e8e09 100755 --- a/ci/publish_pypi.sh +++ b/ci/publish_pypi.sh @@ -20,4 +20,4 @@ if [ -d "dist" ]; then fi # Publish to pypi -poetry publish --build --username __token__ --password $PYPI_TOKEN +poetry publish --build --username __token__ --password $PYPI_TOKEN --dry-run From 265d30b7e7fbfc1dc2b0bc7841b1a23fcf0b9317 Mon Sep 17 00:00:00 2001 From: AJ Stuyvenberg Date: Wed, 13 Mar 2024 10:55:42 -0400 Subject: [PATCH 2/3] fix: Include py before script --- ci/input_files/build.yaml.tpl | 1 + ci/publish_pypi.sh | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/ci/input_files/build.yaml.tpl b/ci/input_files/build.yaml.tpl index 8a3cbc83..feb3e816 100644 --- a/ci/input_files/build.yaml.tpl +++ b/ci/input_files/build.yaml.tpl @@ -168,6 +168,7 @@ publish-pypi-package-test: stage: publish tags: ["arch:amd64"] image: registry.ddbuild.io/images/docker:20.10-py3 + before_script: *python-before-script cache: [] when: manual script: diff --git a/ci/publish_pypi.sh b/ci/publish_pypi.sh index 666e8e09..499396ce 100755 --- a/ci/publish_pypi.sh +++ b/ci/publish_pypi.sh @@ -13,6 +13,14 @@ PYPI_TOKEN=$(aws ssm get-parameter \ --out text) # Builds the lambda layer and upload to Pypi +if [ -z "$CI_COMMIT_TAG" ]; then + printf "[Error] No CI_COMMIT_TAG found.\n" + printf "Exiting script...\n" + # exit 1 +else + printf "Tag found in environment: $CI_COMMIT_TAG\n" +fi + # Clear previously built distributions if [ -d "dist" ]; then echo "Removing folder 'dist' to clear previously built distributions" From cfeb0549056fb90e85a4a10d8e4b68cc2b595045 Mon Sep 17 00:00:00 2001 From: AJ Stuyvenberg Date: Wed, 13 Mar 2024 11:08:25 -0400 Subject: [PATCH 3/3] feat: Ensure poetry is installed before publishing. Ensure CI_COMMIT_TAG present before publishing --- ci/input_files/build.yaml.tpl | 7 ++++++- ci/publish_pypi.sh | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ci/input_files/build.yaml.tpl b/ci/input_files/build.yaml.tpl index feb3e816..449f6978 100644 --- a/ci/input_files/build.yaml.tpl +++ b/ci/input_files/build.yaml.tpl @@ -164,12 +164,17 @@ publish-layer-{{ $environment.name }} ({{ $runtime.name }}-{{ $runtime.arch }}): {{- end }} -publish-pypi-package-test: +publish-pypi-package: stage: publish tags: ["arch:amd64"] image: registry.ddbuild.io/images/docker:20.10-py3 before_script: *python-before-script cache: [] + rules: + - if: '$CI_COMMIT_TAG =~ /^v.*/' when: manual + needs: {{ range $runtime := (ds "runtimes").runtimes }} + - sign-layer ({{ $runtime.name }}-{{ $runtime.arch}}) + {{- end }} script: - ./ci/publish_pypi.sh diff --git a/ci/publish_pypi.sh b/ci/publish_pypi.sh index 499396ce..c01df7ef 100755 --- a/ci/publish_pypi.sh +++ b/ci/publish_pypi.sh @@ -16,7 +16,7 @@ PYPI_TOKEN=$(aws ssm get-parameter \ if [ -z "$CI_COMMIT_TAG" ]; then printf "[Error] No CI_COMMIT_TAG found.\n" printf "Exiting script...\n" - # exit 1 + exit 1 else printf "Tag found in environment: $CI_COMMIT_TAG\n" fi @@ -28,4 +28,4 @@ if [ -d "dist" ]; then fi # Publish to pypi -poetry publish --build --username __token__ --password $PYPI_TOKEN --dry-run +poetry publish --build --username __token__ --password $PYPI_TOKEN