Skip to content

Commit

Permalink
Feature release pipeline (#1)
Browse files Browse the repository at this point in the history
* Create .gitignore

* project bootstrap

* Create release.yaml

* Update release.yaml

* Update release.yaml

* Update release.yaml

* triggers

* Update release.yaml

* Update release.yaml

* Update release.yaml

* Update release.yaml

* Update release.yaml

* Update release.yaml

* Update release.yaml

* Update release.yaml

* Update release.yaml

* Update release.yaml

* adjust packaged files

* update
  • Loading branch information
gkoch78 authored Jul 10, 2023
1 parent 2d5c59f commit 7815aa4
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: release

# Workflow Triggers
on:
# On a PullRequest against main
pull_request:
branches: [ "main" ]
types: ["closed", "synchronize"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

env:
COUNCIL_DRAFT: ${{ github.event.pull_request.merged == false }}
COUNCIL_LATEST: ${{ github.event.pull_request.merged == true }}

jobs:
release:
# Pull Request object schema: https://docs.github.com/en/graphql/reference/objects#pullrequest
if: |
${{ contains(github.event.pull_request.labels.*.name, 'release') }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: checkout
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Installing dev requirements
run: pip3 install -r dev-requirements.txt
- name: Packaging
run: hatch build
- name: Version
id: hatch-version
run: |
echo version=$(hatch version) >> $GITHUB_OUTPUT
- name: Git Release
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: "dist/*"
draft: ${{ env.COUNCIL_DRAFT }}
generateReleaseNotes: true
makeLatest: ${{ env.COUNCIL_LATEST }}
tag: v${{ steps.hatch-version.outputs.version }}
updateOnlyUnreleased: true

- name: env var
run: export
if: always()
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## Jetbrains
.idea

## Macos
.DS_Store

## Python
dist
2 changes: 2 additions & 0 deletions council_ai/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def hello_word(name: str = "") -> str:
return f"Hello {name or 'World'}!"
1 change: 1 addition & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hatch==1.7.0
42 changes: 42 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[build-system]
requires = ["hatchling", "hatch-requirements-txt"]
build-backend = "hatchling.build"

[project]
name = "council-ai"
version = "0.0.1"
description = "to do"
requires-python = ">=3.9"

dynamic = ["dependencies"]

[tool.hatch.build]
exclude = [
".github",
"*-requirements.txt",
"tests",
"venv",
]

package = ['council_ai']

[tool.hatch.metadata.hooks.requirements_txt]
files = ["requirements.txt"]

[tool.black]
line-length = 120

[tool.pytest.ini_options]
log_cli = true
log_cli_level = "DEBUG"
log_cli_format="[%(asctime)s %(levelname)s %(threadName)s %(name)s:%(funcName)s:%(lineno)s] %(message)s"
log_cli_date_format="%Y-%m-%d %H:%M:%S%z"

[tool.ruff]
exclude = ["__init__.py", "docs"]
line-length = 120

[tool.mypy]
exclude = "(?x)(venv|docs)"
mypy_path= "./stubs"
explicit_package_bases = "true"
Empty file added requirements.txt
Empty file.
10 changes: 10 additions & 0 deletions tests/unit/hello.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import unittest
import council_ai


class TestHello(unittest.TestCase):
def test_hello(self):
self.assertEqual("Hello World!", council_ai.hello_word())

def test_hello_council(self):
self.assertEqual("Hello Council!", council_ai.hello_word("Council"))

0 comments on commit 7815aa4

Please sign in to comment.