Skip to content

Commit b99e65a

Browse files
authored
chore(ci): add ci pipeline with GH Actions
1 parent 7a31d4b commit b99e65a

5 files changed

Lines changed: 306 additions & 1 deletion

File tree

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# SPDX-FileCopyrightText: Copyright (c) Siemens AG 2019-2025 ALL RIGHTS RESERVED
2+
# SPDX-License-Identifier: MIT
3+
4+
on:
5+
workflow_call
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
python-version: [ "3.10", "3.11", "3.12", "3.13" ]
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v3
16+
- name: Install Poetry
17+
run: |
18+
pipx install poetry
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v4
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
cache: poetry
24+
cache-dependency-path: poetry.lock
25+
- name: Set Poetry environment
26+
run: |
27+
poetry env use ${{ matrix.python-version }}
28+
- name: Install dependencies
29+
run: |
30+
poetry install --no-root
31+
- name: Run the automated tests
32+
run: |
33+
poetry build
34+
- name: Upload pytest test results
35+
uses: actions/upload-artifact@v4
36+
with:
37+
name: build-${{ matrix.python-version }}
38+
path: |
39+
dist/*.whl
40+
dist/*.tar.gz
41+
42+
tests:
43+
runs-on: ubuntu-latest
44+
permissions:
45+
contents: write
46+
strategy:
47+
matrix:
48+
python-version: [ "3.10", "3.11", "3.12", "3.13" ]
49+
steps:
50+
- name: Checkout
51+
uses: actions/checkout@v3
52+
- name: Install Poetry
53+
run: |
54+
pipx install poetry
55+
- name: Set up Python ${{ matrix.python-version }}
56+
uses: actions/setup-python@v4
57+
with:
58+
python-version: ${{ matrix.python-version }}
59+
cache: poetry
60+
cache-dependency-path: poetry.lock
61+
- name: Set Poetry environment
62+
run: |
63+
poetry env use ${{ matrix.python-version }}
64+
- name: Install dependencies
65+
run: |
66+
poetry install --no-root
67+
- name: Run the automated tests
68+
run: |
69+
poetry run tox run -e ${{ matrix.python-version }}
70+
- name: Upload pytest test results
71+
uses: actions/upload-artifact@v4
72+
with:
73+
name: pytest-results-${{ matrix.python-version }}
74+
path: coverage.xml
75+
76+
lint:
77+
runs-on: ubuntu-latest
78+
steps:
79+
- name: Checkout
80+
uses: actions/checkout@v3
81+
- name: Install Poetry
82+
run: |
83+
pipx install poetry
84+
- name: Set up Python
85+
uses: actions/setup-python@v4
86+
with:
87+
python-version: '3.12'
88+
cache: poetry
89+
cache-dependency-path: poetry.lock
90+
- name: Set Poetry environment
91+
run: |
92+
poetry env use 3.12
93+
- name: Install dependencies
94+
run: |
95+
poetry install --no-root
96+
- name: Run the linting
97+
run: |
98+
poetry run tox run -e lint,type

.github/workflows/ci.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# SPDX-FileCopyrightText: Copyright (c) Siemens AG 2019-2025 ALL RIGHTS RESERVED
2+
# SPDX-License-Identifier: MIT
3+
4+
name: Python CI
5+
on:
6+
push:
7+
branches:
8+
- main
9+
pull_request:
10+
branches:
11+
- main
12+
jobs:
13+
call-build-and-test-workflow:
14+
uses:
15+
./.github/workflows/build-and-test.yml

.github/workflows/release.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# SPDX-FileCopyrightText: Copyright (c) Siemens AG 2019-2025 ALL RIGHTS RESERVED
2+
# SPDX-License-Identifier: MIT
3+
4+
name: PyPI release
5+
on:
6+
push:
7+
tags:
8+
- 'v[0-9]+.[0-9]+.[0-9]+'
9+
10+
jobs:
11+
call-build-and-test-workflow:
12+
uses:
13+
./.github/workflows/build-and-test.yml
14+
15+
pypi-publish:
16+
name: Upload release to PyPI
17+
runs-on: ubuntu-latest
18+
environment:
19+
name: pypi
20+
url: https://pypi.org/p/siemens-standard-bom-python
21+
permissions:
22+
id-token: write
23+
needs: call-build-and-test-workflow
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v3
27+
- name: Install Poetry
28+
run: |
29+
pipx install poetry
30+
- name: Set up Python
31+
uses: actions/setup-python@v4
32+
with:
33+
python-version: '3.12'
34+
cache: poetry
35+
cache-dependency-path: poetry.lock
36+
- name: Set Poetry environment
37+
run: |
38+
poetry env use 3.12
39+
- name: Install dependencies
40+
run: |
41+
poetry install --sync --no-interaction
42+
- name: Package project
43+
run: |
44+
poetry build
45+
- name: Publish package to PyPI
46+
uses: pypa/gh-action-pypi-publish@release/v1
47+
with:
48+
packages-dir: dist
49+
- name: Upload artifacts
50+
uses: actions/upload-artifact@v4
51+
with:
52+
name: dist
53+
path: dist
54+
55+
changelog:
56+
name: Generate changelog
57+
runs-on: ubuntu-latest
58+
outputs:
59+
release_body: ${{ steps.git-cliff.outputs.content }}
60+
steps:
61+
- name: Checkout
62+
uses: actions/checkout@v4
63+
with:
64+
fetch-depth: 0
65+
- name: Download artifacts
66+
uses: actions/download-artifact@v4
67+
with:
68+
name: dist
69+
- name: Generate a changelog
70+
uses: orhun/git-cliff-action@v4
71+
id: git-cliff
72+
with:
73+
config: cliff.toml
74+
args: -vv --latest --strip header
75+
env:
76+
OUTPUT: CHANGES.md
77+
GITHUB_REPO: ${{ github.repository }}
78+
79+
# use release body in the same job
80+
- name: Upload the binary releases
81+
uses: svenstaro/upload-release-action@v2
82+
with:
83+
file: dist
84+
repo_token: ${{ secrets.GITHUB_TOKEN }}
85+
tag: ${{ github.ref }}
86+
body: ${{ steps.git-cliff.outputs.content }}

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Standard BOM for Python
22

3+
[![build](https://github.com/siemens/standard-bom-python/actions/workflows/ci.yml/badge.svg)](https://github.com/siemens/standard-bom-python/actions/workflows/ci.yml)
4+
[![GitHub Tag](https://img.shields.io/github/v/tag/siemens/standard-bom-python)](https://github.com/siemens/standard-bom-python/releases/latest)
5+
36
A Python library for creating and consuming documents in
47
[standard-bom format](https://sbom.siemens.io/latest/format.html).
58

@@ -8,7 +11,19 @@ This library is mainly a wrapper for the official
811

912
## Installation
1013

11-
TODO: Add installation instructions after publish
14+
To install the library, run following command ...
15+
16+
... for pip:
17+
18+
```shell
19+
pip install siemens-standard-bom
20+
```
21+
22+
... for Poetry:
23+
24+
```shell
25+
poetry add siemens-standard-bom
26+
```
1227

1328
The library provides Standard BOM parser and serializer classes. The parser class is used to read a Standard BOM from a file, and the serializer class is used to write a Standard BOM to a file.
1429

cliff.toml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# SPDX-FileCopyrightText: Copyright (c) Siemens AG 2019-2025 ALL RIGHTS RESERVED
2+
# SPDX-License-Identifier: MIT
3+
4+
# git-cliff ~ default configuration file
5+
# https://git-cliff.org/docs/configuration
6+
#
7+
# Lines starting with "#" are comments.
8+
# Configuration options are organized into tables and keys.
9+
# See documentation for more information on available options.
10+
11+
[changelog]
12+
# changelog header
13+
header = """
14+
# Changelog\n
15+
All notable changes to this project will be documented in this file.\n
16+
"""
17+
# template for the changelog body
18+
# https://keats.github.io/tera/docs/#introduction
19+
body = """
20+
{% if version %}\
21+
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}\
22+
{% else %}\
23+
## [unreleased]\
24+
{% endif %}\
25+
{% for group, commits in commits | group_by(attribute="group") %}
26+
### {{ group | upper_first }}
27+
{% for commit in commits %}\
28+
- {% if commit.breaking %}[**breaking**] {% endif %}{{ commit.message | upper_first }}
29+
{% endfor %}\
30+
{% endfor %}\n
31+
"""
32+
33+
# template for the changelog footer
34+
footer = """
35+
<!-- generated by git-cliff -->
36+
"""
37+
# remove the leading and trailing s
38+
trim = true
39+
# postprocessors
40+
postprocessors = [
41+
# { pattern = '<REPO>', replace = "https://github.com/orhun/git-cliff" }, # replace repository URL
42+
]
43+
44+
[git]
45+
# parse the commits based on https://www.conventionalcommits.org
46+
conventional_commits = true
47+
# filter out the commits that are not conventional
48+
filter_unconventional = true
49+
# process each line of a commit as an individual commit
50+
split_commits = false
51+
# regex for preprocessing the commit messages
52+
commit_preprocessors = [
53+
# Replace issue numbers
54+
#{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](<REPO>/issues/${2}))"},
55+
# Check spelling of the commit with https://github.com/crate-ci/typos
56+
# If the spelling is incorrect, it will be automatically fixed.
57+
#{ pattern = '.*', replace_command = 'typos --write-changes -' },
58+
]
59+
# regex for parsing and grouping commits
60+
commit_parsers = [
61+
{ message = "^feat", group = "<!-- 0 -->🚀 Features" },
62+
{ message = "^fix", group = "<!-- 1 -->🐛 Bug Fixes" },
63+
{ message = "^doc", group = "<!-- 3 -->📚 Documentation" },
64+
{ message = "^perf", group = "<!-- 4 -->⚡ Performance" },
65+
{ message = "^refactor", group = "<!-- 2 -->🚜 Refactor" },
66+
{ message = "^style", group = "<!-- 5 -->🎨 Styling" },
67+
{ message = "^test", group = "<!-- 6 -->🧪 Testing" },
68+
{ message = "^chore\\(release\\): prepare for", skip = true },
69+
{ message = "^chore\\(deps.*\\)", group = "<!-- 4 -->✨ Dependencies"},
70+
{ message = "^chore\\(pr\\)", skip = true },
71+
{ message = "^chore\\(pull\\)", skip = true },
72+
{ message = "^chore|^ci", group = "<!-- 7 -->⚙️ Miscellaneous Tasks" },
73+
{ body = ".*security", group = "<!-- 8 -->🛡️ Security" },
74+
{ message = "^revert", group = "<!-- 9 -->◀️ Revert" },
75+
]
76+
# protect breaking changes from being skipped due to matching a skipping commit_parser
77+
protect_breaking_commits = false
78+
# filter out the commits that are not matched by commit parsers
79+
filter_commits = false
80+
# regex for matching git tags
81+
# tag_pattern = "v[0-9].*"
82+
# regex for skipping tags
83+
# skip_tags = ""
84+
# regex for ignoring tags
85+
# ignore_tags = ""
86+
# sort the tags topologically
87+
topo_order = false
88+
# sort the commits inside sections by oldest/newest order
89+
sort_commits = "oldest"
90+
# limit the number of commits included in the changelog.
91+
# limit_commits = 42

0 commit comments

Comments
 (0)