Skip to content

Commit ee25f85

Browse files
author
bakebot
committed
Cookie updated targeting develop by NetworkToCode Cookie Drift Manager Tool
Template: ``` { "template": "https://github.com/networktocode-llc/cookiecutter-ntc.git", "dir": "python", "ref": "main", "path": "/__w/cookiecutter-nautobot-app-drift-manager/cookiecutter-nautobot-app-drift-manager/cookiecutter-ntc/python" } ``` Cookie: ``` { "remote": "https://github.com/networktocode/pyntc.git", "path": "/tmp/tmpjh04xc0r/pyntc", "repository_path": "/tmp/tmpjh04xc0r/pyntc", "dir": "", "branch_prefix": "drift-manager/develop", "context": { "codeowner_github_usernames": "@jeffkala @pszulczewski @pke11y", "full_name": "Network to Code, LLC", "email": "info@networktocode.com", "github_org": "networktocode", "description": "Python library focused on tasks related to device level and OS management.", "project_name": "pyntc", "project_slug": "pyntc", "repo_url": "https://github.com/networktocode/pyntc", "base_url": "pyntc", "project_python_name": "pyntc", "project_python_base_version": "3.10", "project_with_config_settings": "no", "generate_docs": "no", "version": "2.0.2", "original_publish_year": "2015", "_template": "/__w/cookiecutter-nautobot-app-drift-manager/cookiecutter-nautobot-app-drift-manager/cookiecutter-ntc/python", "_output_dir": "/tmp/tmpjh04xc0r", "_repo_dir": "/__w/cookiecutter-nautobot-app-drift-manager/cookiecutter-nautobot-app-drift-manager/cookiecutter-ntc/python", "_checkout": null }, "drift_managed_branch": "develop", "remote_name": "origin", "pull_request_strategy": "PullRequestStrategy.UPDATE_OR_CREATE", "post_actions": [], "baked_commit_ref": "a5add2662f26a3b877635bbf1fd787682414d2bf", "draft": false } ``` CLI Arguments: ``` { "cookie_dir": "", "input": false, "json_filename": "", "output_dir": "", "push": true, "template": "./cookiecutter-ntc", "template_dir": "python", "template_ref": "main", "pull_request": "update-or-create", "post_action": [], "disable_post_actions": true, "draft": null, "drift_managed_branch": "develop" } ```
1 parent c3b6b40 commit ee25f85

11 files changed

Lines changed: 384 additions & 9 deletions

File tree

.cookiecutter.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,15 @@
2323
"pull_request_strategy": "update-or-create",
2424
"post_actions": [],
2525
"draft": false,
26+
<<<<<<< HEAD
2627
<<<<<<< HEAD
2728
"baked_commit_ref": "a5add2662f26a3b877635bbf1fd787682414d2bf",
2829
=======
2930
"baked_commit_ref": "0bac2e8ca365aea9a730bfc06c5e5029b25dcf50",
3031
>>>>>>> 1cad760 (Cookie updated targeting develop by NetworkToCode Cookie Drift Manager Tool)
32+
=======
33+
"baked_commit_ref": "1c8e2eb54eafb18e541e80793a2e71d1fcb3b067",
34+
>>>>>>> 45de4a7 (Cookie updated targeting develop by NetworkToCode Cookie Drift Manager Tool)
3135
"drift_managed_branch": "develop"
3236
}
3337
}

.github/workflows/ci.yml

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: "Check out repository code"
2424
uses: "actions/checkout@v4"
2525
- name: "Setup environment"
26-
uses: "networktocode/gh-action-setup-poetry-environment@v6"
26+
uses: "networktocode/gh-action-setup-poetry-environment@v7"
2727
with:
2828
poetry-version: "2.1.3"
2929
- name: "Linting: ruff format"
@@ -36,7 +36,7 @@ jobs:
3636
- name: "Check out repository code"
3737
uses: "actions/checkout@v4"
3838
- name: "Setup environment"
39-
uses: "networktocode/gh-action-setup-poetry-environment@v6"
39+
uses: "networktocode/gh-action-setup-poetry-environment@v7"
4040
with:
4141
poetry-version: "2.1.3"
4242
- name: "Linting: ruff"
@@ -49,7 +49,7 @@ jobs:
4949
- name: "Check out repository code"
5050
uses: "actions/checkout@v4"
5151
- name: "Setup environment"
52-
uses: "networktocode/gh-action-setup-poetry-environment@v6"
52+
uses: "networktocode/gh-action-setup-poetry-environment@v7"
5353
with:
5454
poetry-version: "2.1.3"
5555
poetry-install-options: "--only dev,docs"
@@ -63,7 +63,7 @@ jobs:
6363
- name: "Check out repository code"
6464
uses: "actions/checkout@v4"
6565
- name: "Setup environment"
66-
uses: "networktocode/gh-action-setup-poetry-environment@v6"
66+
uses: "networktocode/gh-action-setup-poetry-environment@v7"
6767
with:
6868
poetry-version: "2.1.3"
6969
- name: "Checking: poetry lock file"
@@ -76,7 +76,7 @@ jobs:
7676
- name: "Check out repository code"
7777
uses: "actions/checkout@v4"
7878
- name: "Setup environment"
79-
uses: "networktocode/gh-action-setup-poetry-environment@v6"
79+
uses: "networktocode/gh-action-setup-poetry-environment@v7"
8080
with:
8181
poetry-version: "2.1.3"
8282
- name: "Linting: yamllint"
@@ -91,13 +91,18 @@ jobs:
9191
strategy:
9292
fail-fast: true
9393
matrix:
94+
<<<<<<< HEAD
9495
python-version: ["3.10", "3.11"] # TODO: Switch back to latest supported Python when https://github.com/networktocode/pyntc/issues/351 is completed
96+
=======
97+
python-version: ["3.10"]
98+
>>>>>>> 45de4a7 (Cookie updated targeting develop by NetworkToCode Cookie Drift Manager Tool)
9599
env:
96100
INVOKE_PYNTC_PYTHON_VER: "${{ matrix.python-version }}"
97101
steps:
98102
- name: "Check out repository code"
99103
uses: "actions/checkout@v4"
100104
- name: "Setup environment"
105+
<<<<<<< HEAD
101106
uses: "networktocode/gh-action-setup-poetry-environment@v6"
102107
with:
103108
poetry-version: "2.1.3"
@@ -136,6 +141,9 @@ jobs:
136141
uses: "actions/checkout@v4"
137142
- name: "Setup environment"
138143
uses: "networktocode/gh-action-setup-poetry-environment@v6"
144+
=======
145+
uses: "networktocode/gh-action-setup-poetry-environment@v7"
146+
>>>>>>> 45de4a7 (Cookie updated targeting develop by NetworkToCode Cookie Drift Manager Tool)
139147
with:
140148
poetry-version: "2.1.3"
141149
- name: "Get image version"
@@ -156,6 +164,46 @@ jobs:
156164
cache-to: "type=gha,scope=${{ env.INVOKE_PYNTC_IMAGE_NAME }}-${{ env.INVOKE_PYNTC_IMAGE_VER }}-py${{ matrix.python-version }}"
157165
build-args: |
158166
PYTHON_VER=${{ matrix.python-version }}
167+
<<<<<<< HEAD
168+
=======
169+
- name: "Linting: Pylint"
170+
run: "poetry run invoke pylint"
171+
pytest:
172+
needs:
173+
- "check-in-docker"
174+
strategy:
175+
fail-fast: true
176+
matrix:
177+
python-version: ["3.10", "3.14"]
178+
runs-on: "ubuntu-latest"
179+
env:
180+
INVOKE_PYNTC_PYTHON_VER: "${{ matrix.python-version }}"
181+
steps:
182+
- name: "Check out repository code"
183+
uses: "actions/checkout@v4"
184+
- name: "Setup environment"
185+
uses: "networktocode/gh-action-setup-poetry-environment@v7"
186+
with:
187+
poetry-version: "2.1.3"
188+
- name: "Get image version"
189+
run: "echo INVOKE_PYNTC_IMAGE_VER=`poetry version -s`-py${{ matrix.python-version }} >> $GITHUB_ENV"
190+
- name: "Set up Docker Buildx"
191+
id: "buildx"
192+
uses: "docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2" # v3.10.0
193+
- name: "Build"
194+
uses: "docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25" # v5.4.0
195+
with:
196+
builder: "${{ steps.buildx.outputs.name }}"
197+
context: "./"
198+
push: false
199+
load: true
200+
tags: "${{ env.INVOKE_PYNTC_IMAGE_NAME }}:${{ env.INVOKE_PYNTC_IMAGE_VER }}"
201+
file: "./Dockerfile"
202+
cache-from: "type=gha,scope=${{ env.INVOKE_PYNTC_IMAGE_NAME }}-${{ env.INVOKE_PYNTC_IMAGE_VER }}-py${{ matrix.python-version }}"
203+
cache-to: "type=gha,scope=${{ env.INVOKE_PYNTC_IMAGE_NAME }}-${{ env.INVOKE_PYNTC_IMAGE_VER }}-py${{ matrix.python-version }}"
204+
build-args: |
205+
PYTHON_VER=${{ matrix.python-version }}
206+
>>>>>>> 45de4a7 (Cookie updated targeting develop by NetworkToCode Cookie Drift Manager Tool)
159207
- name: "Run Tests"
160208
run: "poetry run invoke pytest"
161209
changelog:
@@ -169,7 +217,7 @@ jobs:
169217
with:
170218
fetch-depth: "0"
171219
- name: "Setup environment"
172-
uses: "networktocode/gh-action-setup-poetry-environment@v6"
220+
uses: "networktocode/gh-action-setup-poetry-environment@v7"
173221
with:
174222
poetry-version: "2.1.3"
175223
- name: "Check for changelog entry"

.github/workflows/prepare_release.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ on: # yamllint disable-line rule:truthy rule:comments
2121
description: "Date of the release YYYY-MM-DD (defaults to today's date in the US Eastern TZ)."
2222
required: false
2323
default: ""
24+
<<<<<<< HEAD
25+
=======
26+
previous_version:
27+
description: "The previous version tag to use for generating release notes (defaults to the latest tag or initial commit if no tags exist)."
28+
required: false
29+
default: ""
30+
>>>>>>> 45de4a7 (Cookie updated targeting develop by NetworkToCode Cookie Drift Manager Tool)
2431

2532
jobs:
2633
prepare-release:
@@ -38,7 +45,11 @@ jobs:
3845
fetch-depth: 0 # Fetch all history for git tags
3946

4047
- name: "Setup environment"
48+
<<<<<<< HEAD
4149
uses: "networktocode/gh-action-setup-poetry-environment@v6"
50+
=======
51+
uses: "networktocode/gh-action-setup-poetry-environment@v7"
52+
>>>>>>> 45de4a7 (Cookie updated targeting develop by NetworkToCode Cookie Drift Manager Tool)
4253
with:
4354
poetry-version: "2.1.3"
4455
poetry-install-options: "--with dev"
@@ -53,7 +64,15 @@ jobs:
5364
5465
# 2. Try to get the previous version tag
5566
# If it fails (no tags), get the hash of the first commit
67+
<<<<<<< HEAD
5668
if PREV_TAG=$(git describe --tags --abbrev=0 2>/dev/null); then
69+
=======
70+
if [ -n "${{ github.event.inputs.previous_version }}" ]; then
71+
PREV_TAG="${{ github.event.inputs.previous_version }}"
72+
echo "Using user-specified previous version: $PREV_TAG"
73+
echo "PREVIOUS_TAG=$PREV_TAG" >> $GITHUB_ENV
74+
elif PREV_TAG=$(git describe --tags --abbrev=0 2>/dev/null); then
75+
>>>>>>> 45de4a7 (Cookie updated targeting develop by NetworkToCode Cookie Drift Manager Tool)
5776
echo "PREVIOUS_TAG=$PREV_TAG" >> $GITHUB_ENV
5877
echo "Found previous tag: $PREV_TAG"
5978
else
@@ -65,9 +84,31 @@ jobs:
6584

6685
- name: "Determine New Version"
6786
id: "versioning"
87+
<<<<<<< HEAD
6888
run: |
6989
# Perform the bump based on the user input
7090
poetry version ${{ github.event.inputs.bump_rule }}
91+
=======
92+
env:
93+
GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
94+
run: |
95+
# Bump the poetry version based on the user input
96+
CURRENT_POETRY_VER=$(poetry version --short)
97+
set +e # continue running if the next command fails
98+
GITHUB_RELEASE_EXISTS=$(gh release view v$CURRENT_POETRY_VER --json publishedAt --jq '.publishedAt')
99+
set -e
100+
# Unconditionally bump the version if the current version is alpha0 or beta0
101+
if [[ $CURRENT_POETRY_VER == *a0 || $CURRENT_POETRY_VER == *b0 || $CURRENT_POETRY_VER == *rc0 ]]; then
102+
poetry version ${{ github.event.inputs.bump_rule }}
103+
# If the bump rule is prerelease and a release doesn't already exist in github we don't bump the version
104+
105+
# This is because we've already bumped to the prerelease version after the previous release
106+
elif [[ "${{ github.event.inputs.bump_rule }}" == "prerelease" && "$CURRENT_POETRY_VER" =~ (a|b|rc)[0-9]+$ && -z "$GITHUB_RELEASE_EXISTS" ]]; then
107+
echo "Prerelease v$CURRENT_POETRY_VER does not exist in github, using this version"
108+
else
109+
poetry version ${{ github.event.inputs.bump_rule }}
110+
fi
111+
>>>>>>> 45de4a7 (Cookie updated targeting develop by NetworkToCode Cookie Drift Manager Tool)
71112

72113
# Capture the New version string for use in other steps
73114
NEW_VER=$(poetry version --short)
@@ -138,7 +179,11 @@ jobs:
138179
# 7. Save to a temporary file to avoid shell argument length limits
139180
echo "$FINAL_NOTES" > ../consolidated_notes.md
140181
182+
<<<<<<< HEAD
141183
- name: "Generate Release Notes"
184+
=======
185+
- name: "Generate App Release Notes and update mkdocs.yml"
186+
>>>>>>> 45de4a7 (Cookie updated targeting develop by NetworkToCode Cookie Drift Manager Tool)
142187
run: "poetry run inv generate-release-notes --version '${{ env.NEW_VERSION }}' --date '${{ env.RELEASE_DATE }}'"
143188

144189
- name: "Commit Changes and Push"

.github/workflows/release.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ on: # yamllint disable-line rule:truthy rule:comments
44
release:
55
types: ["published"]
66

7+
env:
8+
POETRY_VERSION: "2.1.3"
9+
PYTHON_VERSION: "3.12"
10+
711
jobs:
812
build:
913
name: "Build package with poetry"
@@ -14,9 +18,16 @@ jobs:
1418
- name: "Setup environment"
1519
uses: "networktocode/gh-action-setup-poetry-environment@v7"
1620
with:
21+
<<<<<<< HEAD
1722
poetry-version: "2.1.3"
1823
python-version: "3.12"
24+
=======
25+
poetry-version: "${{ env.POETRY_VERSION }}"
26+
python-version: "${{ env.PYTHON_VERSION }}"
27+
>>>>>>> 45de4a7 (Cookie updated targeting develop by NetworkToCode Cookie Drift Manager Tool)
1928
poetry-install-options: "--no-root"
29+
- name: "Build Documentation"
30+
run: "poetry run invoke build-and-check-docs"
2031
- name: "Run Poetry Build"
2132
run: "poetry build"
2233

@@ -56,15 +67,21 @@ jobs:
5667
if: "startsWith(github.ref, 'refs/tags/v')"
5768
needs: "build"
5869
environment: "pypi"
70+
<<<<<<< HEAD
5971
# IMPORTANT: this permission is mandatory for trusted publishing.
6072
permissions:
73+
=======
74+
permissions:
75+
# IMPORTANT: this permission is mandatory for Trusted Publishing
76+
>>>>>>> 45de4a7 (Cookie updated targeting develop by NetworkToCode Cookie Drift Manager Tool)
6177
id-token: "write"
6278
steps:
6379
- name: "Retrieve built package from cache"
6480
uses: "actions/download-artifact@v4"
6581
with:
6682
name: "distfiles"
6783
path: "dist/"
84+
6885
- name: "Publish package distributions to PyPI"
6986
uses: "pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e" # v1.13.0
7087

@@ -107,12 +124,17 @@ jobs:
107124
permissions:
108125
contents: "write"
109126
pull-requests: "write"
127+
<<<<<<< HEAD
110128
name: "Create a PR from main into develop"
129+
=======
130+
name: "${{ github.event.release.target_commitish == 'main' && 'Create a PR from main into develop' || format('Create a PR to merge into {0}', github.event.release.target_commitish) }}"
131+
>>>>>>> 45de4a7 (Cookie updated targeting develop by NetworkToCode Cookie Drift Manager Tool)
111132
needs:
112133
- "publish-github"
113134
- "publish-pypi"
114135
runs-on: "ubuntu-latest"
115136
steps:
137+
<<<<<<< HEAD
116138
- name: "Checkout main"
117139
uses: "actions/checkout@v4"
118140
with:
@@ -126,16 +148,45 @@ jobs:
126148
poetry-install-options: "--no-root"
127149

128150
- name: "Create release branch from main"
151+
=======
152+
- name: "Checkout source branch"
153+
uses: "actions/checkout@v4"
154+
with:
155+
ref: "${{ github.event.release.target_commitish }}"
156+
fetch-depth: 0
157+
158+
- name: "Setup environment"
159+
uses: "networktocode/gh-action-setup-poetry-environment@v7"
160+
with:
161+
poetry-version: "${{ env.POETRY_VERSION }}"
162+
poetry-install-options: "--no-root"
163+
164+
- name: "Create release branch and bump version"
165+
>>>>>>> 45de4a7 (Cookie updated targeting develop by NetworkToCode Cookie Drift Manager Tool)
129166
id: "branch"
130167
run: |
131168
132169
git config user.name "${{ github.actor }}"
133170
git config user.email "${{ github.actor }}@users.noreply.github.com"
134171
172+
<<<<<<< HEAD
135173
TAG_NAME="${{ github.event.release.tag_name }}"
136174
VERSION="${TAG_NAME#v}"
137175

138176
BRANCH_NAME="release-${VERSION}-to-develop"
177+
=======
178+
SOURCE_BRANCH="${{ github.event.release.target_commitish }}"
179+
if [ "$SOURCE_BRANCH" = "main" ]; then
180+
TARGET_BRANCH="develop"
181+
else
182+
TARGET_BRANCH="$SOURCE_BRANCH"
183+
fi
184+
185+
TAG_NAME="${{ github.event.release.tag_name }}"
186+
VERSION="${TAG_NAME#v}"
187+
188+
BRANCH_NAME="release-${VERSION}-to-${TARGET_BRANCH}"
189+
>>>>>>> 45de4a7 (Cookie updated targeting develop by NetworkToCode Cookie Drift Manager Tool)
139190

140191
# Ensure release branch doesn't already exist
141192
if git rev-parse --verify origin/$BRANCH_NAME > /dev/null 2>&1; then
@@ -145,18 +196,43 @@ jobs:
145196

146197
git checkout -b "$BRANCH_NAME"
147198

199+
<<<<<<< HEAD
148200
poetry version prepatch
201+
=======
202+
poetry version prerelease
203+
>>>>>>> 45de4a7 (Cookie updated targeting develop by NetworkToCode Cookie Drift Manager Tool)
149204
git add pyproject.toml && git commit -m "Bump version"
150205
git push origin "$BRANCH_NAME"
151206

152207
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
208+
<<<<<<< HEAD
153209

154210
- name: "Create Pull Request to develop"
211+
=======
212+
echo "target_branch=$TARGET_BRANCH" >> $GITHUB_OUTPUT
213+
214+
- name: "Create Pull Request"
215+
>>>>>>> 45de4a7 (Cookie updated targeting develop by NetworkToCode Cookie Drift Manager Tool)
155216
env:
156217
GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
157218
run: |
158219
gh pr create \
220+
<<<<<<< HEAD
159221
--title "Post release ${{ github.event.release.tag_name }} to develop" \
222+
=======
223+
--title "Post release ${{ github.event.release.tag_name }} to ${{ steps.branch.outputs.target_branch }}" \
224+
--body "Please do a merge commit." \
225+
--base "${{ steps.branch.outputs.target_branch }}" \
226+
--head "${{ steps.branch.outputs.branch_name }}"
227+
228+
- name: "Create Pull Request"
229+
if: "steps.branch.outputs.branch_name != ''"
230+
env:
231+
GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
232+
run: |
233+
gh pr create \
234+
--title "Sync release notes from ${{ github.event.release.target_commitish }} (${{ github.event.release.tag_name }}) to develop" \
235+
>>>>>>> 45de4a7 (Cookie updated targeting develop by NetworkToCode Cookie Drift Manager Tool)
160236
--body "Please do a merge commit." \
161237
--base "develop" \
162238
--head "${{ steps.branch.outputs.branch_name }}"

0 commit comments

Comments
 (0)