diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 75da92e..862221e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,16 +4,30 @@ variables: PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" PIPENV_VENV_IN_PROJECT: 1 -stages: - - build - - deploy - - release - cache: paths: - .cache/pip - .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: stage: build before_script: @@ -21,22 +35,19 @@ package_linux: - pip install pipenv - pipenv sync --dev script: - - VERSION=$(pipenv run python -m setuptools_scm) - - echo $VERSION | tee version.txt - 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: paths: - - version.txt - dist/*.whl - dist/fime_linux_* upload: - image: curlimages/curl:latest stage: deploy + image: curlimages/curl:latest 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: stage: release