From acd403af3ea9bb1ffcbc8677a121e122959798c8 Mon Sep 17 00:00:00 2001 From: Heinz-Alexander Fuetterer <35225576+afuetterer@users.noreply.github.com> Date: Wed, 24 Jan 2024 16:53:36 +0100 Subject: [PATCH] ci: add step to update version and date in citation.cff (#245) Fixes: #242 --- .github/workflows/main.yml | 5 +++++ pyproject.toml | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f1e301d..149fdbd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -31,6 +31,11 @@ jobs: with: fetch-depth: 0 # get all commits and tags token: ${{ secrets.SEMANTIC_RELEASE_TOKEN }} + - name: Update version and date in CITATION.cff + run: | + pipx install hatch + hatch run release:update-citation + git add CITATION.cff - name: Create semantic release id: release uses: python-semantic-release/python-semantic-release@1d2bbdf23aab816cd9d6e26f537b5cec9e39dede # v8.7.2 diff --git a/pyproject.toml b/pyproject.toml index 36287a0..1aaa7fe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -51,6 +51,9 @@ docs = [ lint = [ "pre-commit~=3.6", ] +release = [ + "python-semantic-release~=8.7", +] test = [ "pytest~=7.4", "pytest-cov~=4.1", @@ -114,6 +117,16 @@ build = "mkdocs build --strict --config-file=docs/mkdocs.yml" serve = "mkdocs serve --strict --config-file=docs/mkdocs.yml" deploy = "mkdocs gh-deploy --force --config-file=docs/mkdocs.yml" +[tool.hatch.envs.release] +features = ["release"] +[tool.hatch.envs.release.scripts] +next-version = "semantic-release version --print" +update-citation = """ + sed -i "s/^version: .*/version: $(semantic-release version --print)/" CITATION.cff + sed -i "s/^date-released: .*/date-released: $(date "+%Y-%m-%d")/" CITATION.cff + cat CITATION.cff +""" + # ruff # Ref: https://docs.astral.sh/ruff/configuration/ # ------------------------------------------------------------------------------