Skip to content

Commit 6efedb6

Browse files
authored
Updates to release workflow (#11)
- Now uses poetry - Added Github Actions workflow to publish a release
1 parent 75b2441 commit 6efedb6

File tree

10 files changed

+118
-78
lines changed

10 files changed

+118
-78
lines changed

.github/workflows/linter.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
name: Run github/super-linter
3+
4+
on:
5+
workflow_call:
6+
7+
jobs:
8+
lint:
9+
runs-on: ubuntu-latest
10+
name: Checks syntax of our code
11+
steps:
12+
- id: git-checkout
13+
name: Checkout
14+
uses: actions/checkout@v3
15+
with:
16+
# Full git history is needed to get a proper
17+
# list of changed files within `super-linter`
18+
fetch-depth: 0
19+
- name: Lint Code Base
20+
uses: github/super-linter@v4
21+
env:
22+
DEFAULT_BRANCH: main
23+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24+
SUPPRESS_POSSUM: true
25+
VALIDATE_ALL_CODEBASE: false
26+
LINTER_RULES_PATH: /
27+
PYTHON_BLACK_CONFIG_FILE: pyproject.toml
28+
FILTER_REGEX_EXCLUDE: (.*/)?(LICENSE)
29+
YAML_CONFIG_FILE: .yamllint.yaml
30+
PYTHON_FLAKE8_CONFIG_FILE: .flake8
31+
PYTHON_ISORT_CONFIG_FILE: pyproject.toml

.github/workflows/pr-test.yml

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,6 @@ on:
66

77
jobs:
88
lint:
9-
runs-on: ubuntu-latest
10-
name: Checks syntax of our code
11-
steps:
12-
- uses: actions/checkout@v3
13-
with:
14-
# Full git history is needed to get a proper
15-
# list of changed files within `super-linter`
16-
fetch-depth: 0
17-
- name: Lint Code Base
18-
uses: github/super-linter@v4
19-
env:
20-
DEFAULT_BRANCH: main
21-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22-
SUPPRESS_POSSUM: true
23-
VALIDATE_ALL_CODEBASE: false
24-
LINTER_RULES_PATH: /
25-
PYTHON_BLACK_CONFIG_FILE: src/pyproject.toml
26-
FILTER_REGEX_EXCLUDE: (.*/)?(LICENSE)
27-
YAML_CONFIG_FILE: .yamllint.yaml
28-
PYTHON_FLAKE8_CONFIG_FILE: .flake8
29-
PYTHON_ISORT_CONFIG_FILE: src/pyproject.toml
9+
uses: ./.github/workflows/linter.yml
3010
tests:
31-
runs-on: ubuntu-latest
32-
name: Run initializer test script
33-
steps:
34-
- id: git-checkout
35-
name: Checkout
36-
uses: actions/checkout@v3
37-
- id: test-script
38-
name: Test the initializers
39-
run: |
40-
cd test
41-
./test.sh
11+
uses: ./.github/workflows/tests.yml

.github/workflows/release.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
name: Publish release
3+
4+
on:
5+
release:
6+
types:
7+
- "released"
8+
workflow_dispatch:
9+
10+
jobs:
11+
lint:
12+
uses: ./.github/workflows/linter.yml
13+
tests:
14+
uses: ./.github/workflows/tests.yml
15+
release:
16+
runs-on: ubuntu-latest
17+
name: Release to PyPi
18+
needs: [lint, tests]
19+
steps:
20+
- id: git-checkout
21+
name: Checkout
22+
uses: actions/checkout@v3
23+
- id: build-and-publish
24+
name: Build and publish to pypi
25+
uses: JRubics/[email protected]
26+
with:
27+
pypi_token: ${{ secrets.PYPI_TOKEN }}
28+
repository_name: "testpypi"
29+
repository_url: "https://test.pypi.org/legacy/"

.github/workflows/tests.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
name: Run tests
3+
4+
on:
5+
workflow_call:
6+
7+
jobs:
8+
tests:
9+
runs-on: ubuntu-latest
10+
name: Run initializer test script
11+
steps:
12+
- id: git-checkout
13+
name: Checkout
14+
uses: actions/checkout@v3
15+
- id: test-script
16+
name: Test the initializers
17+
run: |
18+
cd test
19+
./test.sh

Release.md

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Build a release
1+
# Build a release manually
22

33
Please follow these steps to produce a release
44

@@ -8,31 +8,24 @@ Checkout the branch for which the release is to be build. If no branch exists fo
88

99
## Set version number
1010

11-
For patch releases the version number in `setup.py` and the `NetBoxInitializersConfig` needs to be updated. If the release is for a new Netbox version additional changes need to be made in `README.md` and `Dockerfile` (for tests).
11+
For patch releases the version number in `pyproject.toml` and the `NetBoxInitializersConfig` needs to be updated. If the release is for a new Netbox version additional changes need to be made in `README.md` and `Dockerfile` (for tests).
1212

1313
## Build the packages
1414

1515
Install the needed Python packages for the build:
1616

1717
```bash
18-
pip install --upgrade pip setuptools wheel twine build
18+
pip install --upgrade poetry
1919
```
2020

2121
Then run the build for the wheel and source distributions:
2222

2323
```bash
24-
python -m build --sdist
25-
python -m build --wheel
24+
poetry build
2625
```
2726

28-
Check the release with twine:
27+
## Upload packages to PyPi
2928

3029
```bash
31-
twine check dist/*
32-
```
33-
34-
## Upload packeges to PyPi
35-
36-
```bash
37-
twine upload dist/*
30+
poetry publish
3831
```

pyproject.toml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[tool.poetry]
2+
authors = ["Tobias Genannt <[email protected]>"]
3+
description = "Load initial data into Netbox"
4+
license = "Apache-2.0"
5+
name = "netbox-initializers"
6+
readme = "README.md"
7+
repository = "https://github.com/tobiasge/netbox-initializers"
8+
version = "3.2.2"
9+
10+
[tool.poetry.dependencies]
11+
python = "^3.8"
12+
"ruamel.yaml" = "0.17.21"
13+
14+
[build-system]
15+
build-backend = "poetry.core.masonry.api"
16+
requires = ["poetry-core"]
17+
18+
[tool.black]
19+
line_length = 100
20+
target-version = ['py310']
21+
22+
[tool.isort]
23+
line_length = 100
24+
multi_line_output = 3
25+
profile = "black"
26+
27+
[tool.pylint.format]
28+
max-line-length = "100"

src/pyproject.toml

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/setup.py

Lines changed: 0 additions & 19 deletions
This file was deleted.

test/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ FROM netboxcommunity/netbox:v3.2
22

33
COPY ../ /opt/netbox-initializers/
44
COPY ./test/config/plugins.py /etc/netbox/config/
5-
WORKDIR /opt/netbox-initializers/src/
5+
WORKDIR /opt/netbox-initializers/
66
RUN /opt/netbox/venv/bin/pip install -e .
77
WORKDIR /opt/netbox/netbox

test/test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ test_setup() {
2121
sed -E 's/^# //' "${script}" >"../../../../test/${INITIALIZERS_DIR}/${script}"
2222
done
2323
)
24-
$doco build --no-cache
24+
$doco build --no-cache || exit 1
2525
}
2626

2727
test_cleanup() {
@@ -37,7 +37,7 @@ test_cleanup() {
3737

3838
test_initializers() {
3939
echo "🏭 Testing Initializers"
40-
$doco run --rm netbox /opt/netbox/docker-entrypoint.sh ./manage.py load_initializer_data --path /etc/netbox/initializer-data
40+
$doco run --rm netbox /opt/netbox/docker-entrypoint.sh ./manage.py load_initializer_data --path /etc/netbox/initializer-data || exit 1
4141
}
4242

4343
echo "🐳🐳🐳 Start testing"

0 commit comments

Comments
 (0)