Skip to content

Commit 27a3576

Browse files
authored
Merge pull request #130 from netboxlabs/feature/versioning-system
Feature: Add semantic versioning support for NetBox Enterprise documentation
2 parents beaa8dd + b19e500 commit 27a3576

File tree

5 files changed

+441
-19
lines changed

5 files changed

+441
-19
lines changed

.github/workflows/version-deploy.yml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: Deploy Documentation Version
2+
3+
permissions:
4+
contents: write
5+
actions: read
6+
7+
on:
8+
push:
9+
tags: ['v*']
10+
workflow_dispatch:
11+
inputs:
12+
version:
13+
description: 'Version to deploy (e.g., v1.11.2)'
14+
required: true
15+
type: string
16+
17+
jobs:
18+
deploy-version:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
27+
- name: Set up Python
28+
uses: actions/setup-python@v4
29+
with:
30+
python-version: '3.11'
31+
32+
- name: Install dependencies
33+
run: |
34+
python -m pip install --upgrade pip
35+
pip install -r requirements.txt
36+
pip install mike
37+
38+
- name: Extract version info
39+
id: version
40+
run: |
41+
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
42+
VERSION="${{ github.event.inputs.version }}"
43+
else
44+
VERSION=${GITHUB_REF#refs/tags/}
45+
fi
46+
47+
# Extract major.minor from version (e.g., v1.11.2 -> v1.11)
48+
MAJOR_MINOR=$(echo $VERSION | sed -E 's/^v([0-9]+\.[0-9]+)\.[0-9]+$/v\1/')
49+
50+
echo "full_version=$VERSION" >> $GITHUB_OUTPUT
51+
echo "major_minor=$MAJOR_MINOR" >> $GITHUB_OUTPUT
52+
53+
# Determine if this is latest
54+
LATEST_VERSION="v1.9"
55+
if [ "$MAJOR_MINOR" == "$LATEST_VERSION" ]; then
56+
echo "is_latest=true" >> $GITHUB_OUTPUT
57+
else
58+
echo "is_latest=false" >> $GITHUB_OUTPUT
59+
fi
60+
61+
- name: Deploy with Mike
62+
run: |
63+
git config --global user.name "github-actions[bot]"
64+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
65+
66+
VERSION="${{ steps.version.outputs.major_minor }}"
67+
FULL_VERSION="${{ steps.version.outputs.full_version }}"
68+
69+
# Deploy the version
70+
if [ "${{ steps.version.outputs.is_latest }}" == "true" ]; then
71+
mike deploy $VERSION latest --title="$VERSION (Latest)" --push --update-aliases
72+
mike set-default latest --push
73+
else
74+
mike deploy $VERSION --title="$VERSION" --push
75+
fi
76+
77+
- name: Trigger Dochub Integration
78+
env:
79+
DOCHUB_WEBHOOK_URL: ${{ secrets.DOCHUB_WEBHOOK_URL }}
80+
run: |
81+
if [ -n "$DOCHUB_WEBHOOK_URL" ]; then
82+
curl -X POST "$DOCHUB_WEBHOOK_URL" \
83+
-H "Content-Type: application/json" \
84+
-d '{
85+
"version": "${{ steps.version.outputs.major_minor }}",
86+
"full_version": "${{ steps.version.outputs.full_version }}",
87+
"repository": "console-docs",
88+
"is_latest": ${{ steps.version.outputs.is_latest }}
89+
}'
90+
fi
91+
92+
- name: Create Release Notes
93+
env:
94+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
95+
run: |
96+
gh release create "${{ steps.version.outputs.full_version }}" \
97+
--title "NetBox Enterprise Documentation ${{ steps.version.outputs.full_version }}" \
98+
--notes "## NetBox Enterprise Documentation ${{ steps.version.outputs.full_version }}
99+
100+
Documentation for NetBox Enterprise ${{ steps.version.outputs.major_minor }}.
101+
102+
### View Documentation
103+
- [Latest Documentation](https://netboxlabs.com/docs/)
104+
- [Version ${{ steps.version.outputs.major_minor }} Documentation](https://netboxlabs.com/docs/${{ steps.version.outputs.major_minor }}/)
105+
106+
### Changes
107+
This release includes documentation updates for NetBox Enterprise ${{ steps.version.outputs.full_version }}."

0 commit comments

Comments
 (0)