Skip to content

Commit 6f72259

Browse files
committed
adding uv-based actions
1 parent b5515c3 commit 6f72259

File tree

6 files changed

+330
-0
lines changed

6 files changed

+330
-0
lines changed

.github/labels.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
# Labels names are important as they are used by Release Drafter to decide
3+
# regarding where to record them in changelog or if to skip them.
4+
#
5+
# The repository labels will be automatically configured using this file and
6+
# the GitHub Action https://github.com/marketplace/actions/github-labeler.
7+
- name: breaking
8+
description: Breaking Changes
9+
color: bfd4f2
10+
- name: bug
11+
description: Something isn't working
12+
color: d73a4a
13+
- name: build
14+
description: Build System and Dependencies
15+
color: bfdadc
16+
- name: ci
17+
description: Continuous Integration
18+
color: 4a97d6
19+
- name: dependencies
20+
description: Pull requests that update a dependency file
21+
color: 0366d6
22+
- name: documentation
23+
description: Improvements or additions to documentation
24+
color: 0075ca
25+
- name: duplicate
26+
description: This issue or pull request already exists
27+
color: cfd3d7
28+
- name: enhancement
29+
description: New feature or request
30+
color: a2eeef
31+
- name: github_actions
32+
description: Pull requests that update Github_actions code
33+
color: "000000"
34+
- name: good first issue
35+
description: Good for newcomers
36+
color: 7057ff
37+
- name: help wanted
38+
description: Extra attention is needed
39+
color: 008672
40+
- name: invalid
41+
description: This doesn't seem right
42+
color: e4e669
43+
- name: performance
44+
description: Performance
45+
color: "016175"
46+
- name: python
47+
description: Pull requests that update Python code
48+
color: 2b67c6
49+
- name: question
50+
description: Further information is requested
51+
color: d876e3
52+
- name: refactoring
53+
description: Refactoring
54+
color: ef67c4
55+
- name: removal
56+
description: Removals and Deprecations
57+
color: 9ae7ea
58+
- name: style
59+
description: Style
60+
color: c120e5
61+
- name: testing
62+
description: Testing
63+
color: b1fc6f
64+
- name: wontfix
65+
description: This will not be worked on
66+
color: ffffff

.github/release-drafter.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
categories:
2+
- title: ":boom: Breaking Changes"
3+
label: "breaking"
4+
- title: ":rocket: Features"
5+
label: "enhancement"
6+
- title: ":fire: Removals and Deprecations"
7+
label: "removal"
8+
- title: ":beetle: Fixes"
9+
label: "bug"
10+
- title: ":racehorse: Performance"
11+
label: "performance"
12+
- title: ":rotating_light: Testing"
13+
label: "testing"
14+
- title: ":construction_worker: Continuous Integration"
15+
label: "ci"
16+
- title: ":books: Documentation"
17+
label: "documentation"
18+
- title: ":hammer: Refactoring"
19+
label: "refactoring"
20+
- title: ":lipstick: Style"
21+
label: "style"
22+
- title: ":package: Dependencies"
23+
labels:
24+
- "dependencies"
25+
- "build"
26+
template: |
27+
## Changes
28+
29+
$CHANGES

.github/workflows/labeler.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: labeler
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
paths:
8+
- '.github/labels.yml'
9+
- '.github/workflows/labels.yml'
10+
pull_request:
11+
paths:
12+
- '.github/labels.yml'
13+
- '.github/workflows/labels.yml'
14+
15+
jobs:
16+
labeler:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: read
20+
issues: write
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
- name: Run Labeler
25+
uses: crazy-max/ghaction-github-labeler@v5
26+
with:
27+
skip-delete: true
28+
github-token: ${{ secrets.GITHUB_TOKEN }}
29+
yaml-file: .github/labels.yml
30+
dry-run: ${{ github.event_name == 'pull_request' }}
31+
exclude: |
32+
help*
33+
*issue

.github/workflows/release.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Release
2+
3+
permissions:
4+
contents: write
5+
pages: write
6+
7+
on:
8+
push:
9+
branches:
10+
- main
11+
12+
jobs:
13+
release:
14+
name: Release
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Check out the repository
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 2
21+
22+
- name: Set up Python
23+
uses: actions/setup-python@v5.3.0
24+
with:
25+
python-version: "3.10.0"
26+
27+
- name: Install uv
28+
uses: astral-sh/setup-uv@v5
29+
with:
30+
# Install a specific version of uv.
31+
version: "0.5.2"
32+
33+
- name: Check if there is a parent commit
34+
id: check-parent-commit
35+
run: |
36+
echo "::set-output name=sha::$(git rev-parse --verify --quiet HEAD^)"
37+
38+
- name: Detect and tag new version
39+
id: check-version
40+
if: steps.check-parent-commit.outputs.sha
41+
uses: salsify/action-detect-and-tag-new-version@v2.0.3
42+
with:
43+
version-command: |
44+
uvx --from=toml-cli toml get --toml-path=pyproject.toml project.version
45+
46+
- name: Bump version for developmental release
47+
if: "! steps.check-version.outputs.tag"
48+
run: |
49+
uv run version_bumper.py &&
50+
version=$(uvx --from=toml-cli toml get --toml-path=pyproject.toml project.version) &&
51+
uvx --from=toml-cli toml set --toml-path=pyproject.toml project.version $version.dev.$(date +%s)
52+
53+
54+
# Add geospatial
55+
# Add the Ubuntu GIS PPA
56+
- name: install geospatial deps
57+
run: |
58+
sudo apt-get -y install software-properties-common
59+
sudo add-apt-repository ppa:ubuntugis/ppa && sudo apt-get update
60+
sudo apt-get -y install geos
61+
sudo apt-get -y install gdal-bin
62+
sudo apt-get -y install libgdal-dev
63+
export CPLUS_INCLUDE_PATH=/usr/include/gdal
64+
export C_INCLUDE_PATH=/usr/include/gdal
65+
sudo apt-get -y install proj-bin
66+
67+
- name: Install dependencies
68+
run: |
69+
uv sync
70+
71+
- name: Build book
72+
run: uv run jupyter-book build . --verbose
73+
74+
- name: Publish
75+
if: steps.check-version.outputs.tag
76+
run: uv run ghp-import -n -p -f _build/html
77+
78+
- name: Publish the release notes
79+
uses: release-drafter/release-drafter@v6.0.0
80+
with:
81+
publish: ${{ steps.check-version.outputs.tag != '' }}
82+
tag: ${{ steps.check-version.outputs.tag }}
83+
env:
84+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/tests.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: tests
2+
3+
on:
4+
- pull_request
5+
- push
6+
7+
jobs:
8+
pre-commit:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- uses: actions/setup-python@v5
13+
with:
14+
python-version: '3.10.0'
15+
- uses: pre-commit/action@v3.0.1
16+
17+
build:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Check out the repository
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 2
24+
25+
- name: Set up Python
26+
uses: actions/setup-python@v5.3.0
27+
with:
28+
python-version: "3.10.0"
29+
30+
- name: Install uv
31+
uses: astral-sh/setup-uv@v5
32+
with:
33+
# Install a specific version of uv.
34+
version: "0.5.2"
35+
36+
- name: set timezone
37+
run: |
38+
TZ="Europe/London" &&
39+
sudo ln -snf /usr/share/zoneinfo/$TZ /etc/localtime
40+
41+
- name: install linux deps
42+
run: |
43+
sudo apt-get -y install openssl graphviz nano texlive graphviz-dev unzip build-essential
44+
45+
# Add geospatial
46+
# Add the Ubuntu GIS PPA
47+
- name: install geospatial deps
48+
run: |
49+
sudo apt-get -y install software-properties-common
50+
sudo add-apt-repository ppa:ubuntugis/ppa && sudo apt-get update
51+
sudo apt-get -y install geos
52+
sudo apt-get -y install gdal-bin
53+
sudo apt-get -y install libgdal-dev
54+
export CPLUS_INCLUDE_PATH=/usr/include/gdal
55+
export C_INCLUDE_PATH=/usr/include/gdal
56+
sudo apt-get -y install proj-bin
57+
58+
- name: Install dependencies
59+
run: |
60+
uv sync
61+
62+
- name: build the book
63+
run: |
64+
uv run jupyter-book build . --verbose
65+
66+
- name: success
67+
run: |
68+
echo "Success in building book without errors!"

version_bumper.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# /// script
2+
# dependencies = [
3+
# "toml>=0.10.2"
4+
# ]
5+
# ///
6+
import subprocess
7+
from typing import Literal
8+
9+
import toml
10+
11+
12+
def bump_version(part: Literal["major", "minor", "patch"] = "patch") -> None:
13+
file_path = "pyproject.toml"
14+
15+
with open(file_path, "r") as f:
16+
pyproject = toml.load(f)
17+
18+
version = pyproject["project"]["version"]
19+
major, minor, patch = map(int, version.split("."))
20+
21+
if part == "major":
22+
major += 1
23+
minor = 0
24+
patch = 0
25+
elif part == "minor":
26+
minor += 1
27+
patch = 0
28+
elif part == "patch":
29+
patch += 1
30+
else:
31+
raise ValueError("Invalid part value. Choose 'major', 'minor', or 'patch'.")
32+
33+
new_version = f"{major}.{minor}.{patch}"
34+
subprocess.run(
35+
[
36+
"uvx",
37+
"--from=toml-cli",
38+
"toml",
39+
"set",
40+
"--toml-path=pyproject.toml",
41+
"project.version",
42+
new_version,
43+
]
44+
)
45+
46+
print(f"Version bumped to {major}.{minor}.{patch}")
47+
48+
49+
if __name__ == "__main__":
50+
bump_version()

0 commit comments

Comments
 (0)