Skip to content

Commit

Permalink
add create-release-pr workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
eonu committed Dec 3, 2023
1 parent c49a3a4 commit ade090c
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 3 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/create-release-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Create release PR

on:
workflow_dispatch:
inputs:
version:
description: Version
required: true

jobs:
create-pull-request:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v2
with:
ref: dev
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: 3.11.3
- name: Install Poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: 1.7.1
- name: Install base dependencies
run: poetry install --sync --only base
- name: Bump version and changelog
run: |
poetry run invoke release.install release.build -- -v ${{ github.event.inputs.version }}
- name: Create pull request
uses: peter-evans/create-pull-request@v5.0.2
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: Bump version and CHANGELOG.md
title: "release: v${{ github.event.inputs.version }}"
body: >
This PR is auto-generated by
[create-pull-request](https://github.com/peter-evans/create-pull-request).
branch: release/${{ github.event.inputs.version }}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Changelog
2 changes: 1 addition & 1 deletion make/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@

"""Tasks for package development."""

from . import cov, docs, lint, tests
from . import cov, docs, lint, release, tests
45 changes: 45 additions & 0 deletions make/release.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copyright (c) 2023-2025 Feud Developers.
# Distributed under the terms of the MIT License (see the LICENSE file).
# SPDX-License-Identifier: MIT
# This source code is part of the Feud project (https://feud.wiki).

"""Tasks for bumping the package version and updating CHANGELOG.md."""

import os
import re
from pathlib import Path

from invoke.config import Config
from invoke.tasks import task


@task
def install(c: Config) -> None:
"""Install package with core and release dependencies."""
c.run("poetry install --sync --only base,release")


@task
def build(c: Config, *, v: str) -> None:
"""Build release."""
root: Path = Path(os.getcwd())

# bump Sphinx documentation version - docs/source/conf.py
conf_path: Path = root / "docs" / "source" / "conf.py"
with open(conf_path) as f:
conf: str = f.read()
with open(conf_path, "w") as f:
f.write(re.sub(r'release = ".*"', f'release = "{v}"', conf))

# bump package version - feud/__init__.py)
init_path: Path = root / "feud" / "__init__.py"
with open(init_path) as f:
init: str = f.read()
with open(init_path, "w") as f:
f.write(re.sub(r'__version__ = ".*"', f'__version__ = "{v}"', init))

# bump project version - pyproject.toml
c.run(f"poetry version {v}")

# auto-generate CHANGELOG.md entry
c.run("poetry run auto-changelog -- --tag-prefix v --github")
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ autodoc-pydantic = { version = ">=2.0.0" }
pytest = { version = "^7.4.0" }
pytest-cov = { version = "^4.1.0" }

[tool.poetry.group.release.dependencies]
auto-changelog = { version = "^0.6.0" }

[tool.ruff]
required-version = "0.1.3"
select = [
Expand Down
4 changes: 2 additions & 2 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from invoke.config import Config
from invoke.tasks import task

from make import cov, docs, lint, tests
from make import cov, docs, lint, release, tests


@task
Expand Down Expand Up @@ -60,6 +60,6 @@ def clean(c: Config) -> None:
namespace.add_task(t)

# register namespaces
for module in (docs, tests, cov, lint):
for module in (docs, tests, cov, lint, release):
collection = Collection.from_module(module)
namespace.add_collection(collection)

0 comments on commit ade090c

Please sign in to comment.