diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index d2033cb..182309d 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -13,9 +13,9 @@ This repository contains **SaveLevel**, a SourcePawn plugin for SourceMod that s ## Technical Environment - **Language**: SourcePawn -- **Platform**: SourceMod 1.11.0+ (configured in sourceknight.yaml) -- **Build System**: SourceKnight (modern SourceMod build tool) -- **Compiler**: SourcePawn compiler (spcomp) via SourceKnight +- **Platform**: SourceMod 1.12.x +- **Build System**: Native GitHub Actions (rumblefrog/setup-sp) +- **Compiler**: SourcePawn compiler (spcomp) via GitHub Actions - **CI/CD**: GitHub Actions workflow (`.github/workflows/ci.yml`) ## Dependencies @@ -49,8 +49,6 @@ addons/sourcemod/ .github/ ├── workflows/ci.yml # Build and release automation └── dependabot.yml # Dependency management - -sourceknight.yaml # Build configuration ``` ## Code Architecture @@ -117,20 +115,24 @@ sourceknight.yaml # Build configuration ### Building the Plugin -**Using SourceKnight (Recommended):** -```bash -# Install SourceKnight if not already installed -npm install -g sourceknight +**Using GitHub Actions (Recommended):** +The plugin is built automatically by `.github/workflows/ci.yml` on every push, pull +request, or manual workflow dispatch. It sets up the SourcePawn compiler via +`rumblefrog/setup-sp` (SourceMod 1.12.x), clones the git dependencies +(MultiColors, OutputInfo, UtilsHelper) into `addons/sourcemod/scripting/include`, +and runs `spcomp` against `SaveLevel.sp`. -# Build the plugin -sourceknight build +**Building locally:** install `spcomp` matching SourceMod 1.12.x, place the +dependency includes under `addons/sourcemod/scripting/include`, then run: +```bash +spcomp -i include -o ../plugins/SaveLevel.smx SaveLevel.sp ``` **Output:** Compiled plugin will be in `addons/sourcemod/plugins/SaveLevel.smx` ### CI/CD Pipeline - **Trigger**: Push, PR, or manual workflow dispatch -- **Build**: Automated via GitHub Actions using SourceKnight +- **Build**: Native GitHub Actions job using `rumblefrog/setup-sp` - **Package**: Creates distributable tar.gz with plugin + configs - **Release**: Auto-releases on tags and main/master branch pushes @@ -258,15 +260,14 @@ while((Index = FindOutput(client, sValue, 0)) != -1) ## Files You Should NOT Modify - `.github/workflows/ci.yml` (unless changing build process) -- `sourceknight.yaml` dependencies (unless upgrading versions) - Existing map configuration files (unless fixing bugs) ## Getting Started Checklist When working on this repository: -1. **Setup**: Ensure SourceKnight is available for building -2. **Build**: Test compilation with `sourceknight build` +1. **Setup**: Rely on the GitHub Actions workflow to build and validate changes +2. **Build**: Open a PR/push and let CI compile the plugin, or build locally with `spcomp` 3. **Test Environment**: Set up development SourceMod server 4. **Map Configs**: Review existing configurations to understand patterns 5. **Code Review**: Focus on memory management and entity manipulation diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8bca33b..a35a0e1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,26 +4,41 @@ 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-ext-outputinfo.git deps/outputinfo + cp -R deps/outputinfo/package/addons/sourcemod/scripting/include/* addons/sourcemod/scripting/include/ + git clone --depth=1 https://github.com/srcdslab/sm-plugin-utilshelper.git deps/utilshelper + cp -R deps/utilshelper/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/SaveLevel.smx SaveLevel.sp - name: Create package run: | - mkdir -p /tmp/package - cp -R .sourceknight/package/* /tmp/package - cp -R addons/sourcemod/configs /tmp/package/common/addons/sourcemod/ + set -euo pipefail + mkdir -p /tmp/package/addons/sourcemod/plugins + cp addons/sourcemod/plugins/*.smx /tmp/package/addons/sourcemod/plugins/ + cp -R addons/sourcemod/configs /tmp/package/addons/sourcemod/ - name: Upload build archive for test runners uses: actions/upload-artifact@v7 @@ -34,13 +49,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 @@ -48,15 +62,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 @@ -67,25 +84,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 6f71d41..a933be3 100644 --- a/.gitignore +++ b/.gitignore @@ -6,5 +6,4 @@ release/ *.smx plugins/ -.sourceknight .venv diff --git a/sourceknight.yaml b/sourceknight.yaml deleted file mode 100644 index 30c0b23..0000000 --- a/sourceknight.yaml +++ /dev/null @@ -1,39 +0,0 @@ -project: - sourceknight: 0.3 - name: SaveLevel - - dependencies: - - name: sourcemod - type: tar - version: 1.12 - location: https://sm.alliedmods.net/smdrop/1.12/sourcemod-1.12.0-git7165-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: outputinfo - type: git - repo: https://github.com/srcdslab/sm-ext-outputinfo - unpack: - - source: /package/addons/sourcemod/scripting/include - dest: /addons/sourcemod/scripting/include - - - name: utilshelper - type: git - repo: https://github.com/srcdslab/sm-plugin-utilshelper - unpack: - - source: /addons - dest: /addons - - root: / - output: /addons/sourcemod/plugins - - targets: - - SaveLevel