Skip to content

Commit de2cf16

Browse files
committed
Modernize C++ example plugin template
- Simplify to two commands (/hello, /broadcast) demonstrating dynamic_cast sender checks and server broadcast - Simplify listener to player join/quit with event priority example - Rename source files (plugin.h, listener.h, plugin.cpp) - Remove fibonacci command and whoami/ServerLoadEvent examples - Rewrite README as practical template quickstart with renaming guide - Add release workflow with changelog, tagging, dual-platform builds - Add AGENTS.md for AI-assisted C++ plugin development - Add CHANGELOG.md, CONTRIBUTING.md, dependabot, issue templates - Update CI to Clang 18, checkout@v6
1 parent 084b408 commit de2cf16

File tree

17 files changed

+745
-244
lines changed

17 files changed

+745
-244
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Bug Report
2+
description: Report a problem with the example plugin template
3+
labels: ["bug"]
4+
body:
5+
- type: textarea
6+
id: description
7+
attributes:
8+
label: Description
9+
description: What happened? What did you expect to happen?
10+
validations:
11+
required: true
12+
- type: textarea
13+
id: steps
14+
attributes:
15+
label: Steps to Reproduce
16+
description: How can we reproduce the issue?
17+
placeholder: |
18+
1. Clone the template
19+
2. Run `cmake -B build`
20+
3. ...
21+
validations:
22+
required: true
23+
- type: dropdown
24+
id: platform
25+
attributes:
26+
label: Platform
27+
options:
28+
- Windows
29+
- Linux
30+
- Both
31+
validations:
32+
required: true
33+
- type: input
34+
id: compiler
35+
attributes:
36+
label: Compiler
37+
placeholder: "MSVC 19.38 / Clang 18"
38+
- type: input
39+
id: endstone-version
40+
attributes:
41+
label: Endstone Version
42+
placeholder: "0.11"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Feature Request
2+
description: Suggest an improvement to the example plugin template
3+
labels: ["enhancement"]
4+
body:
5+
- type: textarea
6+
id: description
7+
attributes:
8+
label: Description
9+
description: What would you like to see added or changed?
10+
validations:
11+
required: true
12+
- type: textarea
13+
id: motivation
14+
attributes:
15+
label: Motivation
16+
description: Why would this be useful? What problem does it solve?

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"

.github/workflows/build.yml

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ name: Build
22

33
on:
44
push:
5-
branches:
6-
- main
5+
branches: [ "main" ]
76
pull_request:
8-
workflow_dispatch:
7+
branches: [ "main" ]
98

109
jobs:
1110
build_windows:
@@ -14,7 +13,7 @@ jobs:
1413

1514
steps:
1615
- name: Checkout Code
17-
uses: actions/checkout@v4
16+
uses: actions/checkout@v6
1817

1918
- name: Set up MSVC
2019
uses: ilammy/msvc-dev-cmd@v1
@@ -26,30 +25,28 @@ jobs:
2625

2726
- name: Build with CMake
2827
run: |
29-
mkdir build
30-
cd build
31-
cmake -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo ..
32-
cmake --build .
28+
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo
29+
cmake --build build
3330
3431
- name: Upload Artifacts
3532
uses: actions/upload-artifact@v4
3633
with:
37-
name: example-plugin-windows
34+
name: plugin-windows
3835
path: |
3936
./build/endstone_*.dll
4037
./build/endstone_*.pdb
4138
4239
build_linux:
43-
name: Build on Ubuntu
40+
name: Build on Linux
4441
runs-on: ubuntu-22.04
4542

4643
steps:
4744
- name: Checkout Code
48-
uses: actions/checkout@v4
45+
uses: actions/checkout@v6
4946

50-
- name: Set up Clang 15
47+
- name: Set up Clang 18
5148
env:
52-
LLVM_VERSION: 15
49+
LLVM_VERSION: 18
5350
run: |
5451
sudo apt-get update -y -q
5552
sudo apt-get install -y -q lsb-release wget software-properties-common gnupg
@@ -65,13 +62,11 @@ jobs:
6562

6663
- name: Build with CMake
6764
run: |
68-
mkdir build
69-
cd build
70-
cmake -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo ..
71-
cmake --build .
65+
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo
66+
cmake --build build
7267
7368
- name: Upload Artifacts
7469
uses: actions/upload-artifact@v4
7570
with:
76-
name: example-plugin-linux
77-
path: ./build/endstone_*.so
71+
name: plugin-linux
72+
path: ./build/endstone_*.so

.github/workflows/release.yml

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: "Version to release (e.g. 0.1.0)"
8+
required: true
9+
type: string
10+
dry_run:
11+
description: "Preview without making changes"
12+
required: false
13+
type: boolean
14+
default: false
15+
16+
jobs:
17+
release:
18+
if: github.repository == 'EndstoneMC/cpp-example-plugin'
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: write
22+
steps:
23+
- name: Checkout Code
24+
uses: actions/checkout@v6
25+
with:
26+
fetch-depth: 0
27+
28+
- name: Validate version
29+
run: |
30+
VERSION="${{ inputs.version }}"
31+
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
32+
echo "::error::Invalid version format: $VERSION (expected X.Y.Z)"
33+
exit 1
34+
fi
35+
if git tag -l "v$VERSION" | grep -q .; then
36+
echo "::error::Tag v$VERSION already exists"
37+
exit 1
38+
fi
39+
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
40+
41+
- name: Extract unreleased changelog
42+
run: |
43+
BODY=$(sed -n '/^## \[Unreleased\]/,/^## \[/{/^## \[/d; p}' CHANGELOG.md)
44+
BODY=$(echo "$BODY" | sed '/./,$!d' | sed -e :a -e '/^\n*$/{$d;N;ba}')
45+
if [ -z "$BODY" ]; then
46+
echo "::error::Unreleased section in CHANGELOG.md is empty"
47+
exit 1
48+
fi
49+
echo "$BODY" > /tmp/release_body.md
50+
echo "Extracted changelog:"
51+
echo "$BODY"
52+
53+
- name: Preview
54+
if: inputs.dry_run
55+
run: |
56+
DATE=$(date -u +%Y-%m-%d)
57+
echo "=== Dry Run ==="
58+
echo "Version: $VERSION"
59+
echo "Tag: v$VERSION"
60+
echo "Date: $DATE"
61+
echo ""
62+
echo "=== Release Body ==="
63+
cat /tmp/release_body.md
64+
65+
- name: Update CHANGELOG.md
66+
if: ${{ !inputs.dry_run }}
67+
run: |
68+
DATE=$(date -u +%Y-%m-%d)
69+
sed -i "s/^## \[Unreleased\]/## [Unreleased]\n\n## [$VERSION] - $DATE/" CHANGELOG.md
70+
71+
- name: Commit and tag
72+
if: ${{ !inputs.dry_run }}
73+
run: |
74+
git config user.name "github-actions[bot]"
75+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
76+
git add CHANGELOG.md
77+
git commit -m "Release $VERSION"
78+
git tag "v$VERSION"
79+
80+
- name: Push
81+
if: ${{ !inputs.dry_run }}
82+
run: |
83+
git push origin main
84+
git push origin "v$VERSION"
85+
86+
- name: Create GitHub release
87+
if: ${{ !inputs.dry_run }}
88+
env:
89+
GH_TOKEN: ${{ github.token }}
90+
run: |
91+
PREV_TAG=$(git tag --sort=-v:refname | sed -n '2p')
92+
if [ -n "$PREV_TAG" ]; then
93+
printf '\n**Full Changelog**: https://github.com/%s/compare/%s...v%s\n' \
94+
"${{ github.repository }}" "$PREV_TAG" "$VERSION" >> /tmp/release_body.md
95+
fi
96+
gh release create "v$VERSION" \
97+
--title "v$VERSION" \
98+
--notes-file /tmp/release_body.md
99+
100+
build_windows:
101+
if: ${{ !inputs.dry_run }}
102+
needs: [ release ]
103+
runs-on: windows-2022
104+
permissions:
105+
contents: write
106+
steps:
107+
- name: Checkout Code
108+
uses: actions/checkout@v6
109+
with:
110+
ref: v${{ inputs.version }}
111+
112+
- name: Set up MSVC
113+
uses: ilammy/msvc-dev-cmd@v1
114+
with:
115+
arch: x86_64
116+
117+
- name: Set up CMake and Ninja
118+
uses: lukka/get-cmake@latest
119+
120+
- name: Build with CMake
121+
run: |
122+
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo
123+
cmake --build build
124+
125+
- name: Attach to release
126+
env:
127+
GH_TOKEN: ${{ github.token }}
128+
run: |
129+
gh release upload "v${{ inputs.version }}" build/endstone_*.dll build/endstone_*.pdb
130+
131+
build_linux:
132+
if: ${{ !inputs.dry_run }}
133+
needs: [ release ]
134+
runs-on: ubuntu-22.04
135+
permissions:
136+
contents: write
137+
steps:
138+
- name: Checkout Code
139+
uses: actions/checkout@v6
140+
with:
141+
ref: v${{ inputs.version }}
142+
143+
- name: Set up Clang 18
144+
env:
145+
LLVM_VERSION: 18
146+
run: |
147+
sudo apt-get update -y -q
148+
sudo apt-get install -y -q lsb-release wget software-properties-common gnupg
149+
sudo wget https://apt.llvm.org/llvm.sh
150+
sudo chmod +x llvm.sh
151+
sudo ./llvm.sh ${LLVM_VERSION}
152+
sudo apt-get install -y -q libc++-${LLVM_VERSION}-dev libc++abi-${LLVM_VERSION}-dev
153+
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/clang-${LLVM_VERSION} 100
154+
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++-${LLVM_VERSION} 100
155+
156+
- name: Set up CMake and Ninja
157+
uses: lukka/get-cmake@latest
158+
159+
- name: Build with CMake
160+
run: |
161+
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo
162+
cmake --build build
163+
164+
- name: Attach to release
165+
env:
166+
GH_TOKEN: ${{ github.token }}
167+
run: gh release upload "v${{ inputs.version }}" build/endstone_*.so

0 commit comments

Comments
 (0)