Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
314 changes: 314 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,314 @@
name: release

on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+a[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+b[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+rc[0-9]+"

env:
PACKAGE_NAME: "wlts.py"
MODULE_NAME: "wlts"
OWNER: "brazil-data-cube"

jobs:
# Extract tag details
details:
runs-on: ubuntu-latest
outputs:
new_version: ${{ steps.release.outputs.new_version }}
suffix: ${{ steps.release.outputs.suffix }}
tag_name: ${{ steps.release.outputs.tag_name }}
clean_version: ${{ steps.clean_version.outputs.clean_version }}
is_prerelease: ${{ steps.prerelease.outputs.is_prerelease }}

steps:
- uses: actions/checkout@v4

- name: Extract tag and Details
id: release
run: |
if [ "${{ github.ref_type }}" = "tag" ]; then
TAG_NAME=${GITHUB_REF#refs/tags/}
NEW_VERSION=$(echo $TAG_NAME | awk -F'-' '{print $1}')
SUFFIX=$(echo "$NEW_VERSION" | grep -oP '(a|b|rc)[0-9]+' | tr -d '\n' || true)
echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
echo "suffix=${SUFFIX:-}" >> "$GITHUB_OUTPUT"
echo "tag_name=$TAG_NAME" >> "$GITHUB_OUTPUT"
else
echo "No tag found"
exit 1
fi

- name: Extract clean version (remove 'v')
id: clean_version
run: |
RAW="${{ steps.release.outputs.new_version }}"
CLEAN="${RAW#v}"
echo "clean_version=$CLEAN" >> $GITHUB_OUTPUT

- name: Detect prerelease
id: prerelease
run: |
TAG="${{ steps.release.outputs.tag_name }}"
if [[ "$TAG" =~ (a[0-9]+|b[0-9]+|rc[0-9]+)$ ]]; then
echo "is_prerelease=true" >> $GITHUB_OUTPUT
else
echo "is_prerelease=false" >> $GITHUB_OUTPUT
fi

# Detect branch and updated version
detect-branch:
needs: details
runs-on: ubuntu-latest
outputs:
branch: ${{ steps.detect.outputs.branch }}
version: ${{ steps.version.outputs.clean }}

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Detect branch for tag
id: detect
run: |
BRANCH=$(git branch -r --contains "$GITHUB_SHA" | head -n 1 | sed 's/origin\///' | tr -d ' ')
echo "branch=$BRANCH" >> $GITHUB_OUTPUT

- name: Extract version (remove leading v)
id: version
run: |
CLEAN="${GITHUB_REF#refs/tags/v}"
echo "clean=$CLEAN" >> $GITHUB_OUTPUT

bump-version:
needs: detect-branch
runs-on: ubuntu-latest
permissions:
contents: write
env:
BRANCH: ${{ needs.detect-branch.outputs.branch }}
VERSION: ${{ needs.detect-branch.outputs.version }}

steps:
- name: Checkout correct branch
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ env.BRANCH }}

- name: Update pyproject.toml version
run: |
sed -i "s/^version = .*/version = \"${VERSION}\"/" pyproject.toml

- name: Validate pyproject.toml
run: |
pip install validate-pyproject
validate-pyproject pyproject.toml

- name: Commit version bump
run: |
git config user.name "github-actions"
git config user.email "[email protected]"
git add pyproject.toml

if git diff --cached --quiet; then
echo "No version changes detected. Skipping commit."
else
git commit -m "Release ${VERSION}: update version"
git push origin HEAD:${BRANCH}
fi

- name: Upload updated pyproject
uses: actions/upload-artifact@v4
with:
name: updated-project
path: |
pyproject.toml

# Check version on Pypi
check_pypi:
needs: details
runs-on: ubuntu-latest

steps:
- name: Fetch information from PyPI
run: |
response=$(curl -s https://pypi.org/pypi/${{ env.PACKAGE_NAME }}/json || echo "{}")
latest_previous_version=$(echo $response | grep -oP '"releases":\{"\K[^"]+' | sort -rV | head -n 1)
if [ -z "$latest_previous_version" ]; then
echo "Package not found on PyPI."
latest_previous_version="0.0.0"
fi
echo "latest_previous_version=$latest_previous_version" >> $GITHUB_ENV

- name: Compare versions and exit if not newer
run: |
NEW_VERSION=${{ needs.details.outputs.new_version }}
LATEST_VERSION=$latest_previous_version
if [ "$(printf '%s\n' "$LATEST_VERSION" "$NEW_VERSION" | sort -rV | head -n 1)" != "$NEW_VERSION" ] \
|| [ "$NEW_VERSION" == "$LATEST_VERSION" ]; then
echo "The new version $NEW_VERSION is not greater than $LATEST_VERSION"
exit 1
fi

# Build Package
setup_and_build:
needs: [details, check_pypi, bump-version]
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: actions/download-artifact@v4
with:
name: updated-project
path: .

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install build and twine
run: |
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade "setuptools>=67" wheel build twine

- name: Clean previous artifacts
run: |
rm -rf dist *.egg-info

- name: Generate stubs
run: |
python3 -m pip install mypy
stubgen ${{ env.MODULE_NAME }} -o .

- name: Build source and wheel distribution
run: |
python3 -m build

- name: Check distributions (fail fast)
run: |
python3 -m twine check dist/*

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/

# Publish in TestPyPI
testpypi_publish:
name: Upload to TestPyPI (SAFE TEST)
needs: [setup_and_build, details]
runs-on: ubuntu-latest

steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist/

- name: Upload to TestPyPI using twine
env:
TWINE_USERNAME: "__token__"
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
run: |
python3 -m pip install --upgrade pip
python3 -m pip install twine
python3 -m twine upload \
--repository-url https://test.pypi.org/legacy/ \
--verbose \
dist/*

# Publish to PYPI
pypi_publish:
name: Upload release to PyPI
needs: [testpypi_publish, setup_and_build, details]
if: ${{ needs.details.outputs.is_prerelease == 'false' }}
runs-on: ubuntu-latest
environment:
name: release
permissions:
id-token: write

steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist/

- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

# Pre-Release and Release jobs
github_prerelease:
name: Create GitHub Pre-Release
runs-on: ubuntu-latest
needs:
- details
- setup_and_build
- testpypi_publish

if: >
needs.testpypi_publish.result == 'success' &&
needs.details.outputs.is_prerelease == 'true'

permissions:
contents: write

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Create GitHub Pre-Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.details.outputs.tag_name }}
name: "Version ${{ needs.details.outputs.clean_version }}"
generate_release_notes: true
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

github_release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs:
- details
- setup_and_build
- testpypi_publish
- pypi_publish

if: >
needs.testpypi_publish.result == 'success' &&
needs.pypi_publish.result == 'success' &&
needs.details.outputs.is_prerelease == 'false'

permissions:
contents: write

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.details.outputs.tag_name }}
name: "Version ${{ needs.details.outputs.clean_version }}"
generate_release_notes: true
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7 changes: 7 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@
Changes
=======

Version 1.4.0 (2025-12-22)
--------------------------

- Include support to Allen's interval temporal logic relationships with point trajectories (`#104 <https://github.com/brazil-data-cube/wlts.py/issues/104>`_)
- Add config for release and publish pypi using actions (`#106 <https://github.com/brazil-data-cube/wlts.py/issues/106>`_)


Version 1.3.1 (2025-09-03)
--------------------------

Expand Down
20 changes: 14 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ Python Client Library for Web Land Trajectory Service
:target: https://wlts.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status

.. .. image:: https://img.shields.io/badge/pypi-v0.1.0-informational
:target: https://pypi.org/pypi/wlts.py
.. image:: https://img.shields.io/pypi/v/wlts.py
:target: https://pypi.org/project/wlts.py/
:alt: PyPI version

.. image:: https://img.shields.io/badge/lifecycle-maturing-blue.svg
:target: https://www.tidyverse.org/lifecycle/#maturing
Expand Down Expand Up @@ -68,17 +69,24 @@ If you want to know more about WLTS service, please, take a look at its `specifi
Installation
============

See `INSTALL.rst <./INSTALL.rst>`_.
.. code-block:: bash

pip install wlts.py

Development Installation
========================

See `INSTALL.rst <https://github.com/brazil-data-cube/wlts.py/blob/master/INSTALL.rst>`_.


Using WLTS in the Command Line
==============================

See `CLI.rst <./CLI.rst>`_.
See `CLI.rst <https://github.com/brazil-data-cube/wlts.py/blob/master/CLI.rst>`_.


Developer Documentation
=======================
Full documentation
==================

See https://wlts.readthedocs.io/en/latest.

Expand Down
4 changes: 3 additions & 1 deletion examples/ex-01.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,7 @@
tj = service.tj(
latitude=-12.0,
longitude=-54.0,
collections='mapbiomas-v9'
collections='mapbiomas-v10'
)

print(tj.df())
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[project]
name = "wlts.py"
version="1.3.1"
version="1.4.0"
description = "."
readme = "README.rst"
requires-python = ">=3.8"
license = {file = "LICENSE"}
license = { text = "GNU General Public License v3.0" }
authors = [
{name = "Brazil Data Cube Team", email = "[email protected]"},
]
Expand Down
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ add_ignore = D401

[options.package_data]
tests.jsons = *.json

[metadata]
license_files =
Loading
Loading