|
| 1 | +_default: |
| 2 | + just --list |
| 3 | + |
| 4 | +# Clone qwc-services repositories |
| 5 | +clone-qwc-services: |
| 6 | + #!/usr/bin/env bash |
| 7 | + set -euo pipefail |
| 8 | + GITBASE=https://github.com/qwc-services |
| 9 | + #GITBASE=git@github.com:qwc-services |
| 10 | + REPOS="qwc-config-service |
| 11 | + qwc-docker |
| 12 | + qwc-ogc-service |
| 13 | + qwc-services-core |
| 14 | + qwc-map-viewer |
| 15 | + qwc-config-db |
| 16 | + qwc-legend-service |
| 17 | + qwc-admin-gui |
| 18 | + qwc-db-auth |
| 19 | + qwc-data-service |
| 20 | + qwc-permalink-service |
| 21 | + qwc-print-service |
| 22 | + qwc-elevation-service |
| 23 | + qwc-fulltext-search-service |
| 24 | + qwc-ldap-auth |
| 25 | + qwc-registration-gui" |
| 26 | + |
| 27 | + for repo in $REPOS; do |
| 28 | + if [ ! -d "${repo}" ]; then |
| 29 | + git clone $GITBASE/$repo.git |
| 30 | + fi |
| 31 | + done |
| 32 | + |
| 33 | +# Execute git command in all subdirectories |
| 34 | +gitall *cmd: |
| 35 | + #!/usr/bin/env bash |
| 36 | + set -euo pipefail |
| 37 | + YELLOW='\033[0;33m' |
| 38 | + NC='\033[0m' # No Color |
| 39 | + for repo in $(find . -maxdepth 2 -name .git -type d); do |
| 40 | + repodir=$(dirname $repo) |
| 41 | + pushd $repodir > /dev/null |
| 42 | + printf "\ncd ${YELLOW}${repodir}${NC} && git {{cmd}}\n" |
| 43 | + git {{cmd}} |
| 44 | + popd > /dev/null |
| 45 | + done |
| 46 | + |
| 47 | + |
| 48 | +# Migrate Python project to uv |
| 49 | +[no-cd] |
| 50 | +migrate flask_cors="true" system-packages="false": pyproject |
| 51 | + rm -rf .venv |
| 52 | + test {{system-packages}} = false || uv venv --system-site-packages |
| 53 | + uv sync |
| 54 | + test {{flask_cors}} = false || uv add --dev flask_cors |
| 55 | + uv add --dev python-dotenv |
| 56 | + echo .venv >> .dockerignore |
| 57 | + uv export --format requirements-txt --no-dev > requirements.txt |
| 58 | + git add pyproject.toml uv.lock requirements.txt .dockerignore |
| 59 | + git commit -m "Migrate to uv" |
| 60 | + |
| 61 | +# Generate pyproject.toml |
| 62 | +[no-cd] |
| 63 | +pyproject: |
| 64 | + #!/usr/bin/env python3 |
| 65 | + import subprocess |
| 66 | + import re |
| 67 | + |
| 68 | + dirname = subprocess.run('basename $(pwd)', shell=True, capture_output=True, text=True) |
| 69 | + tag = subprocess.run('git describe --tags --abbrev=0', shell=True, capture_output=True, text=True) |
| 70 | + readme = open('README.md', 'r', encoding='utf-8').read() |
| 71 | + title = re.search(r'^(.*)\n=+', readme, re.MULTILINE).group(1) |
| 72 | + |
| 73 | + head = f"""[project] |
| 74 | + name = "{dirname.stdout.strip()}" |
| 75 | + version = "{tag.stdout.strip()}" |
| 76 | + description = "{title}" |
| 77 | + readme = "README.md" |
| 78 | + requires-python = ">=3.10" |
| 79 | + dependencies = [ |
| 80 | + """ |
| 81 | + with open('pyproject.toml', 'w') as file: |
| 82 | + file.write(head) |
| 83 | + with open('requirements.txt', 'r') as lines: |
| 84 | + reqs = ',\n'.join(f' "{line.strip().replace("==", "~=")}"' for line in lines) |
| 85 | + file.write(reqs) |
| 86 | + file.write('\n]\n') |
| 87 | + |
| 88 | +# Upgrade all packages |
| 89 | +[no-cd] |
| 90 | +upgrade-all: |
| 91 | + uv lock --upgrade |
| 92 | + uv export --format requirements-txt --no-dev > requirements.txt |
| 93 | + |
| 94 | +default_tag := datetime('v%Y.%m.%d') |
| 95 | + |
| 96 | +# Bump release |
| 97 | +[no-cd] |
| 98 | +release tag=default_tag: |
| 99 | + sed -i 's/^version = .*/version = "{{tag}}"/' --in-place pyproject.toml |
| 100 | + uv lock |
| 101 | + uv export --format requirements-txt --no-dev > requirements.txt |
| 102 | + git add pyproject.toml uv.lock requirements.txt |
| 103 | + git commit -m "Release {{tag}}" |
| 104 | + git tag -m {{tag}} {{tag}} |
| 105 | + |
| 106 | + |
| 107 | +# Publish package to test.pypi.org |
| 108 | +[no-cd] |
| 109 | +publish-test: |
| 110 | + @# https://packaging.python.org/guides/using-testpypi |
| 111 | + uv publish --index https://test.pypi.org/simple/ |
| 112 | + # Test with `python -m pip install --index-url https://test.pypi.org/simple/ qwc-services-core` |
| 113 | + |
| 114 | +# Install uv with shell installer |
| 115 | +install-uv: |
| 116 | + curl -LsSf https://astral.sh/uv/install.sh | sh |
0 commit comments