diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index aea735d..11d4215 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -15,8 +15,8 @@ This repository contains a SourcePawn plugin for SourceMod that implements a **F ## Technical Environment - **Language**: SourcePawn (.sp files) -- **Platform**: SourceMod 1.11.0+ (currently using 1.11.0-git6934) -- **Build System**: SourceKnight for dependency management and compilation +- **Platform**: SourceMod 1.12.x +- **Build System**: Native GitHub Actions (rumblefrog/setup-sp) for dependency management and compilation - **Target Output**: Compiled .smx plugin files - **Dependencies**: - `sourcemod` (core framework) @@ -38,47 +38,33 @@ addons/sourcemod/scripting/ ├── dependabot.yml # Dependency updates configuration └── copilot-instructions.md # This file - coding agent instructions -sourceknight.yaml # Build configuration and dependencies .gitignore # Excludes build artifacts, .smx files ``` **Generated Files** (not in repository): - `cfg/sourcemod/VIP_FreeVIPGiveaway.cfg` - Auto-generated ConVar configuration -- `.sourceknight/` - Build cache and output directory ## Build Process -### Using SourceKnight (Recommended) -The repository uses SourceKnight for automated dependency management and building: - -```bash -# Install SourceKnight if not already available -pip install sourceknight - -# Build the plugin (handles dependency downloads automatically) -sourceknight build - -# Output will be in .sourceknight/package/addons/sourcemod/plugins/ -``` - -**Note**: SourceKnight installation may fail on some systems due to dependency issues. The CI/CD pipeline uses Docker containers with SourceKnight pre-installed. +### Using GitHub Actions (Recommended) +The repository builds natively via GitHub Actions using `rumblefrog/setup-sp` to install the SourcePawn compiler (SourceMod 1.12.x), clones the `MultiColors` and `VIP-Core` include dependencies, and compiles with `spcomp`. Just push or open a PR and CI will build the plugin. ### Manual Build Process -If SourceKnight installation fails, you can build manually: +You can also build manually: ```bash # 1. Download dependencies manually: -# - SourceMod 1.11.0-git6934 from https://sm.alliedmods.net/smdrop/1.11/sourcemod-1.11.0-git6934-linux.tar.gz +# - SourceMod 1.12.x from https://sm.alliedmods.net/smdrop/1.12/ # - MultiColors include from https://github.com/srcdslab/sm-plugin-MultiColors # - VIP Core include from https://github.com/srcdslab/sm-plugin-VIP-Core # 2. Place include files in addons/sourcemod/scripting/include/ # 3. Compile using SourceMod compiler -spcomp addons/sourcemod/scripting/VIP_FreeVIPGiveaway.sp -o VIP_FreeVIPGiveaway.smx +spcomp -i addons/sourcemod/scripting/include addons/sourcemod/scripting/VIP_FreeVIPGiveaway.sp -o VIP_FreeVIPGiveaway.smx ``` ### CI/CD Pipeline - **Trigger**: Push, pull request, or manual dispatch -- **Build**: Uses maxime1907/action-sourceknight@v1 +- **Build**: Native GitHub Actions workflow (`.github/workflows/ci.yml`) using `rumblefrog/setup-sp` - **Output**: Creates tar.gz releases with compiled plugins - **Versioning**: Uses git tags or "latest" for main/master branch @@ -184,7 +170,7 @@ db.Query(CallbackFunction, query, clientId); ### Local Testing 1. **Build Verification**: ```bash - sourceknight build + spcomp -i addons/sourcemod/scripting/include addons/sourcemod/scripting/VIP_FreeVIPGiveaway.sp -o VIP_FreeVIPGiveaway.smx # Verify no compilation errors ``` diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7f4150c..3b368c9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,25 +4,38 @@ on: [push, pull_request, workflow_dispatch] jobs: build: - name: "Build" - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-24.04] - include: - - os: ubuntu-24.04 + name: Build + runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 - - name: Build sourcemod plugin - uses: maxime1907/action-sourceknight@v1 + + - name: Setup SourcePawn compiler + uses: rumblefrog/setup-sp@v1.3.1 with: - cmd: build + version: "1.12.x" + github-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Install dependencies + run: | + set -euo pipefail + mkdir -p addons/sourcemod/scripting/include deps + git clone --depth=1 https://github.com/srcdslab/sm-plugin-MultiColors.git deps/multicolors + cp -R deps/multicolors/addons/sourcemod/scripting/include/* addons/sourcemod/scripting/include/ + git clone --depth=1 https://github.com/srcdslab/sm-plugin-VIP-Core.git deps/vip_core + cp -R deps/vip_core/addons/sourcemod/scripting/include/* addons/sourcemod/scripting/include/ + + - name: Build sourcemod plugin + working-directory: addons/sourcemod/scripting + run: | + set -euo pipefail + mkdir -p ../plugins + spcomp -i include -o ../plugins/VIP_FreeVIPGiveaway.smx VIP_FreeVIPGiveaway.sp - name: Create package run: | - mkdir -p /tmp/package - cp -R .sourceknight/package/* /tmp/package + set -euo pipefail + mkdir -p /tmp/package/addons/sourcemod/plugins + cp addons/sourcemod/plugins/*.smx /tmp/package/addons/sourcemod/plugins/ - name: Upload build archive for test runners uses: actions/upload-artifact@v7 @@ -33,13 +46,12 @@ jobs: tag: name: Tag needs: build + if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 - if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' - name: Delete existing "latest" release and tag - if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' run: | set -euo pipefail gh release delete latest --cleanup-tag --yes || true @@ -47,15 +59,18 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - uses: rickstaa/action-create-tag@v1 - if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' with: - tag: "latest" + tag: latest github_token: ${{ secrets.GITHUB_TOKEN }} release: name: Release - if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' needs: [build, tag] + if: | + always() && + needs.build.result == 'success' && + (needs.tag.result == 'success' || needs.tag.result == 'skipped') && + (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main') runs-on: ubuntu-latest steps: - name: Download artifacts @@ -66,25 +81,25 @@ jobs: - name: Versioning run: | + set -euo pipefail version="latest" - if [[ "${{ github.ref_type }}" == 'tag' ]]; then - version=`echo $GITHUB_REF | sed "s/refs\/tags\///"`; + if [[ "${{ github.ref_type }}" == "tag" ]]; then + version="${GITHUB_REF_NAME}" fi - echo "RELEASE_VERSION=$version" >> $GITHUB_ENV + echo "RELEASE_VERSION=$version" >> "$GITHUB_ENV" - name: Package run: | + set -euo pipefail cd artifacts - ls -Rall - tar -czf ../${{ github.event.repository.name }}-${{ env.RELEASE_VERSION }}.tar.gz . + tar -czf "../${{ github.event.repository.name }}-${{ env.RELEASE_VERSION }}.tar.gz" . cd .. - ls -la *.tar.gz - name: Release uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: '*.tar.gz' + file: "*.tar.gz" tag: ${{ env.RELEASE_VERSION }} file_glob: true overwrite: true diff --git a/.gitignore b/.gitignore index 2a04272..a393459 100644 --- a/.gitignore +++ b/.gitignore @@ -6,5 +6,4 @@ release/ *.smx plugins/ -.sourceknight .venv \ No newline at end of file diff --git a/sourceknight.yaml b/sourceknight.yaml deleted file mode 100644 index 8759b24..0000000 --- a/sourceknight.yaml +++ /dev/null @@ -1,32 +0,0 @@ -project: - sourceknight: 0.3 - name: VIP_FreeVIPGiveaway - - dependencies: - - name: sourcemod - type: tar - version: 1.12 - location: https://sm.alliedmods.net/smdrop/1.12/sourcemod-1.12.0-git7223-linux.tar.gz - unpack: - - source: /addons - dest: /addons - - - name: multicolors - type: git - repo: https://github.com/srcdslab/sm-plugin-MultiColors - unpack: - - source: /addons/sourcemod/scripting/include - dest: /addons/sourcemod/scripting/include - - - name: vip_core - type: git - repo: https://github.com/srcdslab/sm-plugin-VIP-Core - unpack: - - source: /addons/sourcemod/scripting/include - dest: /addons/sourcemod/scripting/include - - root: / - output: /addons/sourcemod/plugins - - targets: - - VIP_FreeVIPGiveaway