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
4 changes: 3 additions & 1 deletion .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
_commit: v0.4.1
_commit: v0.14.4
_src_path: gl:znicholls/copier-core-python-repository
conda_release: true
email: zebedee.nicholls@climate-energy-college.org
include_cli: false
name: Zebedee Nicholls
notebook_based_docs: true
package_manager: uv
pandas_doctests: false
plot_dependencies: false
project_description_short: Handling of units related to simple climate modelling.
Expand Down
40 changes: 12 additions & 28 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,29 @@
name: "Setup Python and pdm"
description: "setup Python and pdm with caches"
name: "Setup Python and uv"
description: "setup Python and uv"

inputs:
python-version:
description: "Python version to use"
required: true
pdm-dependency-install-flags:
description: "Flags to pass to pdm when running `pdm install`"
uv-dependency-install-flags:
description: "Flags to pass to uv when running `uv install`"
required: true
run-pdm-install:
description: "Should we run the pdm install steps"
run-uv-install:
description: "Should we run the uv install steps"
required: false
default: true

runs:
using: "composite"
steps:
- name: Write file with install flags
shell: bash
run: |
echo "${{ inputs.pdm-dependency-install-flags }}" > pdm-install-flags.txt
- name: Setup PDM
id: setup-pdm
uses: pdm-project/setup-pdm@v4.1
- name: Setup uv
id: setup-uv
uses: astral-sh/setup-uv@v4
with:
version: "0.8.8"
python-version: ${{ inputs.python-version }}
cache: true
cache-dependency-path: |
./pdm.lock
./pdm-install-flags.txt
- name: Install dependencies
shell: bash
if: ${{ (inputs.run-pdm-install == 'true') && (steps.setup-pdm.outputs.cache-hit != 'true') }}
run: |
pdm install --no-self ${{ inputs.pdm-dependency-install-flags }}
# Now run same command but let the package install too
- name: Install package
shell: bash
# To ensure that the package is always installed, this step is run even if the cache was hit
if: ${{ inputs.run-pdm-install == 'true' }}
if: ${{ (inputs.run-uv-install == 'true') }}
run: |
pdm install ${{ inputs.pdm-dependency-install-flags }}
pdm run which python
pdm run python --version # Check python version just in case
uv sync ${{ inputs.uv-dependency-install-flags }}
47 changes: 21 additions & 26 deletions .github/workflows/bump.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,28 @@ on:
inputs:
bump_rule:
type: choice
description: How to bump the project's version (see https://github.com/carstencodes/pdm-bump#usage)
description: How to bump the project's version (see https://docs.astral.sh/uv/reference/cli/#uv-version)
options:
- no-pre-release
# no micro because we always sit on a pre-release in main,
# so we would always use no-pre-release instead of micro
# - micro
- patch
- minor
- major
- "pre-release --pre alpha"
- "pre-release --pre beta"
- "pre-release --pre release-candidate"
- stable
- alpha
- beta
- rc
- post
- dev
required: true

jobs:
bump_version:
name: "Bump version and create changelog"
if: "!startsWith(github.event.head_commit.message, 'bump:')"
runs-on: ubuntu-latest
strategy:
matrix:
os: [ "ubuntu-latest" ]
python-version: [ "3.11" ]
runs-on: "${{ matrix.os }}"
env:
CI_COMMIT_EMAIL: "ci-runner@openscm-units.invalid"
steps:
Expand All @@ -32,36 +36,27 @@ jobs:
fetch-depth: 0
token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}"

- name: Setup PDM
uses: pdm-project/setup-pdm@v4
with:
python-version: "3.9"

- name: Install pdm-bump
run: |
pdm self add pdm-bump

- uses: ./.github/actions/setup
with:
python-version: ${{ matrix.python-version }}
pdm-dependency-install-flags: "-G dev"
uv-dependency-install-flags: "--all-extras --group dev"

- name: Create bump and changelog
run: |
git config --global user.name "$GITHUB_ACTOR"
git config --global user.email "$CI_COMMIT_EMAIL"

BASE_VERSION=`sed -ne 's/^version = "\([0-9\.a]*\)"/\1/p' pyproject.toml`
BASE_VERSION=`sed -ne 's/^version = "\([0-9\.post]*\)"/\1/p' pyproject.toml`
echo "Bumping from version $BASE_VERSION"

# Bump
pdm bump ${{ github.event.inputs.bump_rule }}
uv version --bump ${{ github.event.inputs.bump_rule }}

NEW_VERSION=`sed -ne 's/^version = "\([0-9\.a]*\)"/\1/p' pyproject.toml`
NEW_VERSION=`sed -ne 's/^version = "\([0-9\.]*\)"/\1/p' pyproject.toml`
echo "Bumping to version $NEW_VERSION"

# Build CHANGELOG
pdm run towncrier build --yes --version v$NEW_VERSION
uv run towncrier build --yes --version v$NEW_VERSION

# Commit, tag and push
git commit -a -m "bump: version $BASE_VERSION -> $NEW_VERSION"
Expand All @@ -70,12 +65,12 @@ jobs:

# Bump to alpha (so that future commits do not have the same
# version as the tagged commit)
BASE_VERSION=`sed -ne 's/^version = "\([0-9\.a]*\)"/\1/p' pyproject.toml`
BASE_VERSION=`sed -ne 's/^version = "\([0-9\.]*\)"/\1/p' pyproject.toml`

# Bump to pre-release of next version
pdm bump pre-release --pre alpha
uv version --bump post

NEW_VERSION=`sed -ne 's/^version = "\([0-9\.a]*\)"/\1/p' pyproject.toml`
NEW_VERSION=`sed -ne 's/^version = "\([0-9\.post]*\)"/\1/p' pyproject.toml`
echo "Bumping version $BASE_VERSION > $NEW_VERSION"

# Commit and push
Expand Down
Loading
Loading