Skip to content

Commit

Permalink
Merge branch 'topic/default/prepare-0.1.0' into 'branch/default'
Browse files Browse the repository at this point in the history
Topic/default/prepare 0.1.0

See merge request fluiddyn/hg-setup!4
  • Loading branch information
paugier committed Dec 17, 2024
2 parents 51781ee + a8a8509 commit 4e432b1
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 3 deletions.
16 changes: 16 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
stages:
- test
- build
- release

workflow:
rules:
Expand Down Expand Up @@ -42,3 +43,18 @@ build:package:
key: pdmcache-$CI_COMMIT_BRANCH
paths:
- ${PDM_CACHE_DIR}


# manually set PDM_PUBLISH_PASSWORD in web interface to your pypi API token
# release:package:
# stage: release
# rules:
# - if: '$CI_MERGE_REQUEST_ID'
# when: never
# - if: '$CI_COMMIT_TAG'
# when: on_success
# variables:
# PDM_PUBLISH_USERNAME: __token__
# script:
# - pdm publish --no-build
# needs: [ "build:package" ]
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Release notes

0.1.0 is being prepared!
## 0.1.0 (2024/12/17)

- commands `hg-setup init` and `hg-setup init-shell-completion`.
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

The repository is currently hosted here https://foss.heptapod.net/fluiddyn/hg-setup.

After the first release of 0.1.0, we will use a topic/MR based workflow.
We use a topic/MR based workflow as explained
[here](https://fluidhowto.readthedocs.io/en/latest/mercurial/heptapod-workflow.html).

For local development, you need `make` and [PDM](https://pdm-project.org). To install the
package, deactivate all unrelated virtual environments and run `make`.
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ test:

cov_html: test
pdm run coverage html

format-md:
mdformat *.md
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# hg-setup: easily setup Mercurial with a tiny Python application

Warning: in development.
[![Latest version](https://badge.fury.io/py/hg-setup.svg)](https://pypi.python.org/pypi/hg-setup/)
![Supported Python versions](https://img.shields.io/pypi/pyversions/hg-setup.svg)
[![Heptapod CI](https://foss.heptapod.net/fluiddyn/hg-setup/badges/branch/default/pipeline.svg)](https://foss.heptapod.net/fluiddyn/hg-setup/-/pipelines)
[![Github Actions](https://github.com/fluiddyn/hg-setup/actions/workflows/ci.yml/badge.svg?branch=branch/default)](https://github.com/fluiddyn/hg-setup/actions)

## Background

Expand Down
70 changes: 70 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
"""Nox file for hg-setup
```sh
nox -l
nox -s add-tag-for-release
```
"""

import os
from pathlib import Path

import nox

os.environ.update({"PDM_IGNORE_SAVED_PYTHON": "1"})
nox.options.reuse_existing_virtualenvs = 1

def _get_version_from_pyproject(path=Path.cwd()):
if isinstance(path, str):
path = Path(path)

if not path.name == "pyproject.toml":
path /= "pyproject.toml"

in_project = False
version = None
with open(path, encoding="utf-8") as file:
for line in file:
if line.startswith("[project]"):
in_project = True
if line.startswith("version =") and in_project:
version = line.split("=")[1].strip()
version = version[1:-1]
break

assert version is not None
return version


@nox.session(name="add-tag-for-release", venv_backend="none")
def add_tag_for_release(session):
session.run("hg", "pull", external=True)

result = session.run(
*"hg log -r default -G".split(), external=True, silent=True
)
if result[0] != "@":
session.run("hg", "update", "default", external=True)

version = _get_version_from_pyproject()
print(f"{version = }")

result = session.run("hg", "tags", "-T", "{tag},", external=True, silent=True)
last_tag = result.split(",", 2)[1]
print(f"{last_tag = }")

if last_tag == version:
session.error("last_tag == version")

answer = input(
f'Do you really want to add and push the new tag "{version}"? (yes/[no]) '
)

if answer != "yes":
print("Maybe next time then. Bye!")
return

print("Let's go!")
session.run("hg", "tag", version, external=True)
session.run("hg", "push", external=True)

0 comments on commit 4e432b1

Please sign in to comment.