161 lines
4.4 KiB
YAML
161 lines
4.4 KiB
YAML
image: python:3.10
|
|
|
|
variables:
|
|
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
|
|
PIPENV_VENV_IN_PROJECT: 1
|
|
|
|
cache:
|
|
paths:
|
|
- .cache/pip
|
|
- .venv/
|
|
|
|
workflow:
|
|
rules:
|
|
- if: $CI_COMMIT_AUTHOR == "Gitlab CI <ci@gitlab.com>"
|
|
when: never
|
|
- when: always
|
|
|
|
prepare:
|
|
before_script:
|
|
- pip install setuptools_scm>=6.2
|
|
script:
|
|
- PYTHON_VERSION=$(python --version | cut -d " " -f2)
|
|
- echo "PYTHON_VERSION=${PYTHON_VERSION}" | tee -a build.env
|
|
- 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 "WINDOWS_AMD64_BINARY=fime_windows_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:
|
|
paths:
|
|
- src/fime/_version.py
|
|
reports:
|
|
dotenv: build.env
|
|
|
|
update_windows_deps:
|
|
tags:
|
|
- shared-windows
|
|
- windows
|
|
- windows-1809
|
|
rules:
|
|
- if: $CI_COMMIT_TAG
|
|
when: never
|
|
- if: $CI_COMMIT_BRANCH == "main"
|
|
when: always
|
|
#- changes:
|
|
# - Pipfile
|
|
# - Pipfile.lock
|
|
# when: always
|
|
before_script:
|
|
- Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
|
|
- choco install python --version=$PYTHON_VERSION -y --no-progress
|
|
- refreshenv
|
|
- python --version
|
|
- pip install pipenv
|
|
script:
|
|
- pipenv lock --dev --keep-outdated
|
|
artifacts:
|
|
paths:
|
|
- Pipfile.lock
|
|
|
|
# commit from linux, because setting up SSH in Windows is a fucking nightmare
|
|
commit_windows_deps:
|
|
needs:
|
|
- update_windows_deps
|
|
image: alpine
|
|
before_script:
|
|
- apk add --update git openssh-client
|
|
- eval $(ssh-agent -s)
|
|
- echo "$WINDOWS_SSH_PRIVATE_KEY" | ssh-add -
|
|
- git config --global user.name "Gitlab CI"
|
|
- git config --global user.email "ci@gitlab.com"
|
|
- git remote add origin "git@gitlab.com:${CI_PROJECT_PATH}.git"
|
|
script:
|
|
- dos2unix Pipfile.lock
|
|
- git commit -m "Updated windows deps from CI" Pipfile.lock || echo "No changes"
|
|
- git push $HEAD:$CI_COMMIT_REF_NAME
|
|
|
|
package_linux:
|
|
needs:
|
|
- prepare
|
|
before_script:
|
|
- python --version
|
|
- pip install pipenv
|
|
- pipenv sync --dev
|
|
script:
|
|
- pipenv run python -m build -w
|
|
- pipenv run pyinstaller --onefile --name "${LINUX_AMD64_BINARY}" src/fime/main.py
|
|
artifacts:
|
|
paths:
|
|
- dist/*.whl
|
|
- dist/fime_linux_*
|
|
|
|
package_windows:
|
|
needs:
|
|
- prepare
|
|
tags:
|
|
- shared-windows
|
|
- windows
|
|
- windows-1809
|
|
# takes forever, so only run if it is worthwhile
|
|
rules:
|
|
- if: $CI_COMMIT_TAG
|
|
before_script:
|
|
- choco install python --version=$PYTHON_VERSION -y --no-progress
|
|
- C:\\Python310\\python.exe --version
|
|
- C:\\Python310\\python.exe -m pip install pipenv
|
|
- C:\\Python310\\python.exe -m pipenv sync --dev
|
|
script:
|
|
- C:\\Python310\\python.exe -m pipenv run pyinstaller --onefile --windowed --name "${WINDOWS_AMD64_BINARY}" -i icon.ico src/fime/main.py
|
|
artifacts:
|
|
paths:
|
|
- dist/fime_windows_*
|
|
|
|
pypi_upload:
|
|
needs:
|
|
- package_linux
|
|
environment: pypi
|
|
rules:
|
|
- if: $CI_COMMIT_TAG
|
|
before_script:
|
|
- pip install twine
|
|
script:
|
|
- twine upload dist/fime-*.whl
|
|
|
|
gitlab_package_upload:
|
|
needs:
|
|
- package_linux
|
|
- package_windows
|
|
image: curlimages/curl:latest
|
|
rules:
|
|
- if: $CI_COMMIT_TAG
|
|
script:
|
|
- curl --version
|
|
- |
|
|
curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file "dist/${LINUX_AMD64_BINARY}" "${PACKAGE_REGISTRY_URL}/${LINUX_AMD64_BINARY}"
|
|
- |
|
|
curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file "dist/${WINDOWS_AMD64_BINARY}.exe" "${PACKAGE_REGISTRY_URL}/${WINDOWS_AMD64_BINARY}.exe"
|
|
|
|
release_job:
|
|
needs:
|
|
- gitlab_package_upload
|
|
image: registry.gitlab.com/gitlab-org/release-cli:latest
|
|
rules:
|
|
- if: $CI_COMMIT_TAG
|
|
script:
|
|
- echo "Running the release job."
|
|
release:
|
|
tag_name: $CI_COMMIT_TAG
|
|
name: 'Release $CI_COMMIT_TAG'
|
|
description: 'Release created using the release-cli.'
|
|
assets:
|
|
links:
|
|
- name: "${LINUX_AMD64_BINARY}"
|
|
url: "${PACKAGE_REGISTRY_URL}/${LINUX_AMD64_BINARY}"
|
|
filepath: "/bin/fime_linux_amd64"
|
|
link_type: package
|
|
- name: "${WINDOWS_AMD64_BINARY}.exe"
|
|
url: "${PACKAGE_REGISTRY_URL}/${WINDOWS_AMD64_BINARY}.exe"
|
|
filepath: "/bin/fime_windows_amd64.exe"
|
|
link_type: package
|