2024-02-29 18:37:01 +00:00
|
|
|
image: python:3.11
|
2022-09-21 21:53:45 +00:00
|
|
|
|
|
|
|
variables:
|
2024-02-29 18:37:01 +00:00
|
|
|
WINDOWS_PYTHON_PACKAGE_NAME: "python311"
|
2022-09-21 21:53:45 +00:00
|
|
|
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
|
2022-09-21 21:58:23 +00:00
|
|
|
PIPENV_VENV_IN_PROJECT: 1
|
2022-11-08 19:34:17 +00:00
|
|
|
UPDATE_WINDOWS_DEPS:
|
|
|
|
description: "Set to \"1\" to update windows deps"
|
|
|
|
value: "0"
|
2022-09-21 21:53:45 +00:00
|
|
|
|
2022-09-27 17:21:03 +00:00
|
|
|
cache:
|
2024-02-29 22:44:22 +00:00
|
|
|
key: cache-$CI_COMMIT_REF_SLUG-$WINDOWS_PYTHON_PACKAGE_NAME
|
2022-09-27 17:21:03 +00:00
|
|
|
paths:
|
|
|
|
- .cache/pip
|
|
|
|
- .venv/
|
|
|
|
|
2022-09-30 10:18:41 +00:00
|
|
|
workflow:
|
|
|
|
rules:
|
2022-10-22 21:49:53 +00:00
|
|
|
- if: $CI_COMMIT_TAG
|
|
|
|
when: always
|
2022-09-30 10:18:41 +00:00
|
|
|
- if: $CI_COMMIT_AUTHOR == "Gitlab CI <ci@gitlab.com>"
|
|
|
|
when: never
|
|
|
|
- when: always
|
|
|
|
|
2022-09-27 17:21:03 +00:00
|
|
|
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
|
2022-09-27 18:18:39 +00:00
|
|
|
- echo "WINDOWS_AMD64_BINARY=fime_windows_amd64_${VERSION}" | tee -a build.env
|
2022-09-27 17:21:03 +00:00
|
|
|
- echo "PACKAGE_REGISTRY_URL=${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/fime/${VERSION}" | tee -a build.env
|
|
|
|
artifacts:
|
2022-09-29 14:50:06 +00:00
|
|
|
paths:
|
|
|
|
- src/fime/_version.py
|
2022-09-27 17:21:03 +00:00
|
|
|
reports:
|
|
|
|
dotenv: build.env
|
2022-09-21 21:53:45 +00:00
|
|
|
|
2022-09-30 10:18:41 +00:00
|
|
|
update_windows_deps:
|
|
|
|
tags:
|
2024-02-29 20:03:17 +00:00
|
|
|
- saas-windows-medium-amd64
|
2022-09-30 10:18:41 +00:00
|
|
|
rules:
|
|
|
|
- if: $CI_COMMIT_TAG
|
|
|
|
when: never
|
2022-11-08 19:34:17 +00:00
|
|
|
- if: $UPDATE_WINDOWS_DEPS == "1"
|
|
|
|
when: always
|
2022-09-30 18:23:44 +00:00
|
|
|
- if: $CI_COMMIT_BRANCH == "main"
|
|
|
|
changes:
|
2022-09-30 18:18:42 +00:00
|
|
|
- Pipfile
|
|
|
|
- Pipfile.lock
|
|
|
|
when: always
|
2022-09-30 10:18:41 +00:00
|
|
|
before_script:
|
2022-09-30 10:42:54 +00:00
|
|
|
- Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
|
2023-01-19 21:15:00 +00:00
|
|
|
- choco install $WINDOWS_PYTHON_PACKAGE_NAME -y --no-progress
|
2022-09-30 10:18:41 +00:00
|
|
|
- refreshenv
|
|
|
|
- python --version
|
|
|
|
- pip install pipenv
|
2022-09-30 17:33:34 +00:00
|
|
|
script:
|
2024-02-29 19:40:58 +00:00
|
|
|
- pipenv lock --dev
|
|
|
|
- cp Pipfile.lock Pipfile.lock.windows
|
2022-09-30 17:33:34 +00:00
|
|
|
artifacts:
|
|
|
|
paths:
|
2024-02-29 19:40:58 +00:00
|
|
|
- Pipfile.lock.windows
|
2022-09-30 17:33:34 +00:00
|
|
|
|
|
|
|
# commit from linux, because setting up SSH in Windows is a fucking nightmare
|
|
|
|
commit_windows_deps:
|
2022-09-30 18:31:03 +00:00
|
|
|
rules:
|
|
|
|
- if: $CI_COMMIT_TAG
|
|
|
|
when: never
|
2022-11-08 19:34:17 +00:00
|
|
|
- if: $UPDATE_WINDOWS_DEPS == "1"
|
2022-09-30 18:31:03 +00:00
|
|
|
- if: $CI_COMMIT_BRANCH == "main"
|
|
|
|
changes:
|
|
|
|
- Pipfile
|
|
|
|
- Pipfile.lock
|
2022-09-30 18:29:10 +00:00
|
|
|
needs:
|
|
|
|
- update_windows_deps
|
2022-09-30 17:33:34 +00:00
|
|
|
image: alpine
|
|
|
|
before_script:
|
|
|
|
- apk add --update git openssh-client
|
|
|
|
- eval $(ssh-agent -s)
|
2022-09-30 18:18:42 +00:00
|
|
|
- echo "$SSH_PRIVATE_KEY_REPO_WRITE" | ssh-add -
|
2022-09-30 10:18:41 +00:00
|
|
|
- git config --global user.name "Gitlab CI"
|
|
|
|
- git config --global user.email "ci@gitlab.com"
|
2022-09-30 18:06:48 +00:00
|
|
|
- git remote rm origin && git remote add origin "git@gitlab.com:${CI_PROJECT_PATH}.git"
|
2022-09-30 10:18:41 +00:00
|
|
|
script:
|
2024-02-29 19:40:58 +00:00
|
|
|
- dos2unix Pipfile.lock.windows
|
|
|
|
- git commit -m "Updated windows deps from CI" Pipfile.lock.windows || echo "No changes"
|
2022-09-30 18:27:10 +00:00
|
|
|
- GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git push origin HEAD:$CI_COMMIT_REF_NAME
|
2022-09-30 10:18:41 +00:00
|
|
|
|
2022-09-27 16:29:07 +00:00
|
|
|
package_linux:
|
2022-09-30 17:33:34 +00:00
|
|
|
needs:
|
|
|
|
- prepare
|
2022-09-27 16:29:07 +00:00
|
|
|
before_script:
|
2022-09-21 21:53:45 +00:00
|
|
|
- python --version
|
2022-09-27 16:29:07 +00:00
|
|
|
- pip install pipenv
|
2022-09-21 21:56:18 +00:00
|
|
|
- pipenv sync --dev
|
2022-09-27 16:29:07 +00:00
|
|
|
script:
|
2022-09-27 16:34:15 +00:00
|
|
|
- pipenv run python -m build -w
|
2022-09-27 17:44:47 +00:00
|
|
|
- pipenv run pyinstaller --onefile --name "${LINUX_AMD64_BINARY}" src/fime/main.py
|
2022-09-21 21:53:45 +00:00
|
|
|
artifacts:
|
|
|
|
paths:
|
|
|
|
- dist/*.whl
|
2022-09-27 16:50:35 +00:00
|
|
|
- dist/fime_linux_*
|
|
|
|
|
2022-09-27 18:18:39 +00:00
|
|
|
package_windows:
|
2022-09-30 17:33:34 +00:00
|
|
|
needs:
|
|
|
|
- prepare
|
2022-09-27 18:18:39 +00:00
|
|
|
tags:
|
2024-02-29 20:03:17 +00:00
|
|
|
- saas-windows-medium-amd64
|
2022-09-27 20:37:25 +00:00
|
|
|
# takes forever, so only run if it is worthwhile
|
|
|
|
rules:
|
|
|
|
- if: $CI_COMMIT_TAG
|
2022-09-27 18:18:39 +00:00
|
|
|
before_script:
|
2022-09-30 18:29:10 +00:00
|
|
|
- Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
|
2023-01-19 21:15:00 +00:00
|
|
|
- choco install $WINDOWS_PYTHON_PACKAGE_NAME -y --no-progress
|
2022-09-30 18:29:10 +00:00
|
|
|
- refreshenv
|
|
|
|
- python --version
|
|
|
|
- pip install pipenv
|
2024-02-29 23:09:41 +00:00
|
|
|
- mv -force Pipfile.lock.windows Pipfile.lock
|
2022-09-30 18:29:10 +00:00
|
|
|
- pipenv sync --dev
|
2022-09-27 18:18:39 +00:00
|
|
|
script:
|
2022-09-30 18:29:10 +00:00
|
|
|
- pipenv run pyinstaller --onefile --windowed --name "${WINDOWS_AMD64_BINARY}" -i icon.ico src/fime/main.py
|
2022-09-27 18:18:39 +00:00
|
|
|
artifacts:
|
|
|
|
paths:
|
|
|
|
- dist/fime_windows_*
|
|
|
|
|
2022-09-30 17:33:34 +00:00
|
|
|
pypi_upload:
|
|
|
|
needs:
|
|
|
|
- package_linux
|
2022-09-27 23:26:40 +00:00
|
|
|
environment: pypi
|
2022-09-28 00:43:56 +00:00
|
|
|
rules:
|
|
|
|
- if: $CI_COMMIT_TAG
|
2022-09-27 23:26:40 +00:00
|
|
|
before_script:
|
|
|
|
- pip install twine
|
|
|
|
script:
|
2022-09-27 23:45:25 +00:00
|
|
|
- twine upload dist/fime-*.whl
|
2022-09-27 23:26:40 +00:00
|
|
|
|
2022-09-30 17:33:34 +00:00
|
|
|
gitlab_package_upload:
|
|
|
|
needs:
|
2022-10-10 17:57:54 +00:00
|
|
|
- prepare
|
2022-09-30 17:33:34 +00:00
|
|
|
- package_linux
|
|
|
|
- package_windows
|
2022-09-27 17:21:03 +00:00
|
|
|
image: curlimages/curl:latest
|
2022-09-27 17:27:07 +00:00
|
|
|
rules:
|
|
|
|
- if: $CI_COMMIT_TAG
|
2022-09-27 16:50:35 +00:00
|
|
|
script:
|
2022-09-27 23:26:40 +00:00
|
|
|
- curl --version
|
2022-09-27 17:21:03 +00:00
|
|
|
- |
|
|
|
|
curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file "dist/${LINUX_AMD64_BINARY}" "${PACKAGE_REGISTRY_URL}/${LINUX_AMD64_BINARY}"
|
2022-09-27 20:37:25 +00:00
|
|
|
- |
|
|
|
|
curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file "dist/${WINDOWS_AMD64_BINARY}.exe" "${PACKAGE_REGISTRY_URL}/${WINDOWS_AMD64_BINARY}.exe"
|
2022-09-21 22:10:31 +00:00
|
|
|
|
|
|
|
release_job:
|
2022-09-30 17:33:34 +00:00
|
|
|
needs:
|
2022-10-10 17:57:54 +00:00
|
|
|
- prepare
|
2022-09-30 17:33:34 +00:00
|
|
|
- gitlab_package_upload
|
2022-09-21 22:10:31 +00:00
|
|
|
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.'
|
2022-09-27 17:27:07 +00:00
|
|
|
assets:
|
|
|
|
links:
|
|
|
|
- name: "${LINUX_AMD64_BINARY}"
|
|
|
|
url: "${PACKAGE_REGISTRY_URL}/${LINUX_AMD64_BINARY}"
|
2022-09-27 17:39:52 +00:00
|
|
|
filepath: "/bin/fime_linux_amd64"
|
2022-09-27 17:27:07 +00:00
|
|
|
link_type: package
|
2022-09-27 20:37:25 +00:00
|
|
|
- name: "${WINDOWS_AMD64_BINARY}.exe"
|
|
|
|
url: "${PACKAGE_REGISTRY_URL}/${WINDOWS_AMD64_BINARY}.exe"
|
|
|
|
filepath: "/bin/fime_windows_amd64.exe"
|
|
|
|
link_type: package
|