Skip to content

Commit ee86eab

Browse files
committed
split docs into two workflows
1 parent d4106c0 commit ee86eab

File tree

6 files changed

+107
-19
lines changed

6 files changed

+107
-19
lines changed

.github/workflows/build-docs.yml

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,24 @@ name: Build Docs
33
on:
44
workflow_dispatch:
55
inputs:
6-
publish:
7-
description: "Publish docs"
8-
required: false
9-
type: boolean
10-
default: false
116
branch:
12-
description: "Branch to build"
7+
description: "Branch to build from"
138
required: false
149
type: string
10+
version:
11+
description: "Version to build from"
12+
required: true
13+
type: string
1514
workflow_call:
1615
inputs:
17-
publish:
18-
description: "Publish docs"
19-
required: false
20-
type: boolean
21-
default: false
2216
branch:
2317
description: "Branch to build from"
2418
required: false
2519
type: string
20+
version:
21+
description: "Version to build from"
22+
required: true
23+
type: string
2624

2725
jobs:
2826
build-docs:
@@ -33,11 +31,26 @@ jobs:
3331
with:
3432
ref: ${{ inputs.branch }}
3533

34+
- name: Configure Git
35+
run: |
36+
git config user.name "github-actions"
37+
git config user.email "[email protected]"
38+
3639
- name: Setup Python
3740
uses: actions/setup-python@v5
3841
with:
3942
python-version: "3.12"
4043

44+
- name: Get previous version
45+
id: get_previous_version
46+
run: |
47+
previous_version=$(git tag --sort=-version:refname | sed -n '2p')
48+
echo "previous_version=${previous_version}" >> $GITHUB_OUTPUT
49+
50+
- name: Update changelog
51+
run: |
52+
./scripts/update_changelog.sh "${{ steps.get_previous_version.outputs.previous_version }}" "v${{ inputs.version }}"
53+
4154
- name: Install dependencies
4255
run: |
4356
pip install pydoc-markdown mkdocs
@@ -46,8 +59,9 @@ jobs:
4659
run: |
4760
pydoc-markdown
4861
mkdocs build
49-
50-
- name: Publish docs
51-
if: ${{ inputs.publish }}
62+
63+
- name: Push changes to release branch
5264
run: |
53-
mkdocs gh-deploy
65+
git add docs/
66+
git commit -m "Update docs for v${{ inputs.version }}"
67+
git push origin ${{ inputs.branch }}

.github/workflows/create-github-release.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,9 @@ jobs:
3434
- name: Generate Changelog
3535
id: changelog
3636
run: |
37+
changelog=$(./scripts/get_changelog.sh "${{ steps.get_previous_version.outputs.previous_version }}" "v${{ inputs.version }}")
3738
echo "CHANGELOG<<EOF" >> $GITHUB_OUTPUT
38-
echo "## What's Changed" >> $GITHUB_OUTPUT
39-
git log --pretty=format:"* %s" "v${{ steps.get_previous_version.outputs.previous_version }}..v${{ inputs.version }}" | \
40-
grep -E ".*\(#[0-9]+\).*$" >> $GITHUB_OUTPUT
39+
echo -e "$changelog" >> $GITHUB_OUTPUT
4140
echo "EOF" >> $GITHUB_OUTPUT
4241
4342
- name: Create GitHub Release

.github/workflows/publish-docs.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Publish Docs
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
publish-docs:
8+
runs-on: ["ubuntu-latest"]
9+
steps:
10+
- name: Checkout code
11+
uses: actions/checkout@v4
12+
with:
13+
ref: ${{ github.ref }}
14+
15+
- name: Setup Python
16+
uses: actions/setup-python@v5
17+
with:
18+
python-version: "3.12"
19+
20+
- name: Install dependencies
21+
run: |
22+
pip install pydoc-markdown mkdocs
23+
24+
- name: Publish docs
25+
run: |
26+
mkdocs gh-deploy

.github/workflows/release.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ jobs:
4040
git config user.name "github-actions"
4141
git config user.email "[email protected]"
4242
43+
- name: Setup GitHub CLI
44+
run: |
45+
type -p curl >/dev/null || (sudo apt update && sudo apt install curl -y)
46+
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
47+
&& sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
48+
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
49+
&& sudo apt update \
50+
&& sudo apt install gh -y
51+
4352
- name: Create Release Branch
4453
id: create_release_branch
4554
run: |
@@ -126,8 +135,8 @@ jobs:
126135
uses: ./.github/workflows/build-docs.yml
127136
if: ${{ inputs.build_docs == true }}
128137
with:
129-
publish: ${{ inputs.test == false }}
130138
branch: ${{ needs.create-release-branch.outputs.RELEASE_BRANCH }}
139+
version: ${{ inputs.version }}
131140
secrets: inherit
132141

133142
create-github-release:

scripts/get_changelog.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
# Initialize changelog with header
4+
CHANGELOG="## What's Changed"
5+
6+
# Get commits with PR numbers and append them to changelog
7+
while IFS= read -r line; do
8+
CHANGELOG="${CHANGELOG}\n${line}"
9+
done < <(git log --pretty=format:"* %s" "$1..$2" | grep -E ".*\(#[0-9]+\).*$")
10+
11+
# Output in GitHub Actions format
12+
echo -e "$CHANGELOG"

scripts/update_changelog.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
3+
# Get the new changes from get_changelog.sh
4+
changelog=$(./scripts/get_changelog.sh "$1" "$2")
5+
6+
# Get today's date in the format Month DD, YYYY
7+
today=$(date "+%B %d, %Y")
8+
9+
# Create the new section with version and date
10+
new_section="## v$3 - ${today}\n\n### Features and improvements\n\n${changelog}\n"
11+
12+
# Create a temporary file
13+
temp_file=$(mktemp)
14+
15+
# Read the first line (# Changelog) and write it to temp file
16+
head -n 1 docs/changelog.md > "$temp_file"
17+
18+
# Add a blank line after the header
19+
echo "" >> "$temp_file"
20+
21+
# Add the new section
22+
echo -e "$new_section" >> "$temp_file"
23+
24+
# Add the rest of the original file (skipping the first line)
25+
tail -n +2 docs/changelog.md >> "$temp_file"
26+
27+
# Replace the original file with the new content
28+
mv "$temp_file" docs/changelog.md

0 commit comments

Comments
 (0)