[ci] Use dotenv

This commit is contained in:
Fabian 2022-09-27 19:21:03 +02:00
parent 1f82ef2785
commit 3efd3128de

View File

@ -4,16 +4,30 @@ variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
PIPENV_VENV_IN_PROJECT: 1 PIPENV_VENV_IN_PROJECT: 1
stages:
- build
- deploy
- release
cache: cache:
paths: paths:
- .cache/pip - .cache/pip
- .venv/ - .venv/
stages:
- prepare
- build
- deploy
- release
prepare:
stage: prepare
before_script:
- pip install setuptools_scm>=6.2
script:
- VERSION=$(python -m setuptools_scm)
- echo "VERSION=${VERSION}" | tee -a build.env
- echo "LINUX_AMD64_BINARY=fime_linux_amd64_${VERSION}" | tee -a build.env
- echo "PACKAGE_REGISTRY_URL=${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/fime/${VERSION}" | tee -a build.env
artifacts:
reports:
dotenv: build.env
package_linux: package_linux:
stage: build stage: build
before_script: before_script:
@ -21,22 +35,19 @@ package_linux:
- pip install pipenv - pip install pipenv
- pipenv sync --dev - pipenv sync --dev
script: script:
- VERSION=$(pipenv run python -m setuptools_scm)
- echo $VERSION | tee version.txt
- pipenv run python -m build -w - pipenv run python -m build -w
- pipenv run pyinstaller --onefile --strip --name fime_linux_${VERSION} src/fime/main.py - pipenv run pyinstaller --onefile --strip --name "${LINUX_AMD64_BINARY}" src/fime/main.py
artifacts: artifacts:
paths: paths:
- version.txt
- dist/*.whl - dist/*.whl
- dist/fime_linux_* - dist/fime_linux_*
upload: upload:
image: curlimages/curl:latest
stage: deploy stage: deploy
image: curlimages/curl:latest
script: script:
- VERSION=$(cat version.txt) - |
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file dist/fime_linux_${VERSION} "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/fime/${VERSION}/fime_linux_${VERSION}"' curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file "dist/${LINUX_AMD64_BINARY}" "${PACKAGE_REGISTRY_URL}/${LINUX_AMD64_BINARY}"
release_job: release_job:
stage: release stage: release