make_post_sell/.gitlab-ci.yml
Russell Ballestrini 8672802e78 Fix GitLab CI pypi-twine stage for Python 3.12+ externally-managed-environment
- Create virtual environment for twine operations instead of system-wide installs
- Use python3 -m build instead of deprecated setup.py commands
- Resolves PEP 668 externally-managed-environment restrictions in CI
2025-07-27 13:58:57 -04:00

67 lines
1.6 KiB
YAML

stages:
- test
- build
- deploy
- pypi-twine
test:
stage: test
tags: ["build"]
except:
- tags
script: make test
build:
stage: build
tags: ["build"]
except:
- tags
script:
- make clean
- make install-source-prod
# Copy static assets to env/static and create a tarball of the static files.
- cp -pr make_post_sell/static env/static
- cp -pr env/static static
- tar -zcf static.tar.gz static
# Clean up the directory outside of the gitlab-runner filesystem.
- rm -rf /opt/make_post_sell/env
# Clone the virtualenv with virtualenv-clone into the desired location.
- virtualenv-clone -vvv $PWD/env /opt/make_post_sell/env
# Create a tarball of the virtualenv.
- tar -zcf env.tar.gz -C /opt/make_post_sell .
# Create SHA512 hash of env.tar.gz.
- sha512sum env.tar.gz >> env.tar.gz.hash
# Create commit-hash.txt to track this build's git commit hash.
- echo $CI_COMMIT_SHA >> commit-hash.txt
artifacts:
paths:
- env.tar.gz
- env.tar.gz.hash
- static.tar.gz
- commit-hash.txt
expire_in: 1 month
when: always
deploy:
stage: deploy
needs: [build]
rules:
- if: '$CI_COMMIT_BRANCH == "develop" || $CI_COMMIT_BRANCH == "master" || $CI_COMMIT_BRANCH == "main"'
when: on_success
trigger:
include: .gitlab-ci.deploy.yml
pypi-twine:
stage: pypi-twine
tags:
- build
only:
- tags
script:
- python3 -m venv twine_env
- source twine_env/bin/activate
- pip install --upgrade pip
- pip install twine build
- python3 -m build
- twine upload dist/*