diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 3ca9bee..3dfaa36 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -5,9 +5,9 @@ This repository contains a SourceMod plugin for Source engine games that automat ## Technical Environment - **Language**: SourcePawn (.sp files) -- **Platform**: SourceMod 1.11+ (see sourceknight.yaml for exact version) +- **Platform**: SourceMod 1.12.x (see .github/workflows/ci.yml for exact version) - **Target Game**: CS:GO/CS2 (Counter-Strike games) -- **Build System**: SourceKnight (Docker-based compilation) +- **Build System**: Native GitHub Actions (rumblefrog/setup-sp) - **CI/CD**: GitHub Actions with automated building and releases ## Project Structure @@ -19,18 +19,17 @@ This repository contains a SourceMod plugin for Source engine games that automat │ ├── addons/sourcemod/configs/ # Configuration files │ │ └── countryflags.cfg # Country code to flag mappings │ └── materials/panorama/ # UI assets (flag images) -├── .github/workflows/ci.yml # CI/CD pipeline -└── sourceknight.yaml # Build configuration +└── .github/workflows/ci.yml # CI/CD pipeline ``` ## Build System -The project uses **SourceKnight** for compilation: -- Build configuration in `sourceknight.yaml` -- Dependencies: SourceMod 1.11.0-git6934, MultiColors plugin +The project uses native **GitHub Actions** for compilation: +- Build configuration in `.github/workflows/ci.yml` +- Dependencies: SourceMod 1.12.x, MultiColors plugin - Output: Compiled .smx files in `/addons/sourcemod/plugins` - CI builds automatically on push/PR and creates releases -To build locally, use the SourceKnight Docker action or compatible toolchain. +To build locally, install the SourcePawn compiler (spcomp) matching the version in `.github/workflows/ci.yml` and compile `addons/sourcemod/scripting/CountryTags.sp`. ## Core Functionality The plugin (`CountryTags.sp`): @@ -125,7 +124,7 @@ Maps country codes to flag indices for display: - Both commands require cached client cookies and allow players to hide their country flags ## Testing & Validation -- **Build Testing**: Ensure compilation succeeds with SourceKnight +- **Build Testing**: Ensure compilation succeeds via the GitHub Actions CI workflow - **Runtime Testing**: Test on development server with multiple scenarios: - Players joining different teams - Late loading scenarios @@ -148,8 +147,7 @@ Maps country codes to flag indices for display: ## Key Files to Understand 1. `CountryTags.sp` - Main plugin logic -2. `sourceknight.yaml` - Build dependencies and configuration +2. `.github/workflows/ci.yml` - Build dependencies, configuration, and release automation 3. `countryflags.cfg` - Country to flag ID mappings -4. `.github/workflows/ci.yml` - Build and release automation When working on this plugin, prioritize stability and performance since it affects all players on a server. Always test changes thoroughly and consider the impact on server performance. \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9eb3a37..8176c7b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,91 +1,104 @@ -name: CI - -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 - steps: - - uses: actions/checkout@v7 - - name: Build sourcemod plugin - uses: maxime1907/action-sourceknight@v1 - with: - cmd: build - - - name: Create package - run: | - mkdir -p /tmp/package - cp -R .sourceknight/package/* /tmp/package - cp -R csgo /tmp/package/ - - - name: Upload build archive for test runners - uses: actions/upload-artifact@v7 - with: - name: ${{ runner.os }} - path: /tmp/package - - tag: - name: Tag - needs: build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v7 - if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' - - - uses: dev-drprasad/delete-tag-and-release@v1.1 - if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' - with: - delete_release: true - tag_name: latest - env: - 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" - 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] - runs-on: ubuntu-latest - steps: - - name: Download artifacts - uses: actions/download-artifact@v8 - with: - name: ${{ runner.os }} - path: artifacts - - - name: Versioning - run: | - version="latest" - if [[ "${{ github.ref_type }}" == 'tag' ]]; then - version=`echo $GITHUB_REF | sed "s/refs\/tags\///"`; - fi - echo "RELEASE_VERSION=$version" >> $GITHUB_ENV - - - name: Package - run: | - cd artifacts - ls -Rall - 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' - tag: ${{ env.RELEASE_VERSION }} - file_glob: true - overwrite: true +name: CI + +on: [push, pull_request, workflow_dispatch] + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + + - name: Setup SourcePawn compiler + uses: rumblefrog/setup-sp@v1.3.1 + with: + version: "1.12.x" + github-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Install dependencies + run: | + set -euo pipefail + mkdir -p addons/sourcemod/scripting/include deps/multicolors + 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/ + + - name: Build sourcemod plugin + working-directory: addons/sourcemod/scripting + run: | + set -euo pipefail + mkdir -p ../plugins + spcomp -i include -o ../plugins/CountryTags.smx CountryTags.sp + + - name: Create package + run: | + set -euo pipefail + mkdir -p /tmp/package/addons/sourcemod/plugins + cp addons/sourcemod/plugins/*.smx /tmp/package/addons/sourcemod/plugins/ + cp -R csgo/* /tmp/package/ + + - name: Upload build archive for test runners + uses: actions/upload-artifact@v7 + with: + name: ${{ runner.os }} + path: /tmp/package + + 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 + + - uses: dev-drprasad/delete-tag-and-release@v1.1 + with: + delete_release: true + tag_name: latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - uses: rickstaa/action-create-tag@v1 + with: + tag: latest + github_token: ${{ secrets.GITHUB_TOKEN }} + + release: + name: Release + 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 + uses: actions/download-artifact@v8 + with: + name: ${{ runner.os }} + path: artifacts + + - name: Versioning + run: | + set -euo pipefail + version="latest" + if [[ "${{ github.ref_type }}" == "tag" ]]; then + version="${GITHUB_REF_NAME}" + fi + echo "RELEASE_VERSION=$version" >> "$GITHUB_ENV" + + - name: Package + run: | + set -euo pipefail + cd artifacts + tar -czf "../${{ github.event.repository.name }}-${{ env.RELEASE_VERSION }}.tar.gz" . + cd .. + + - name: Release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: "*.tar.gz" + tag: ${{ env.RELEASE_VERSION }} + file_glob: true + overwrite: true diff --git a/.gitignore b/.gitignore index 40f37f1..8c492ac 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 b5f57a8..0000000 --- a/sourceknight.yaml +++ /dev/null @@ -1,25 +0,0 @@ -project: - sourceknight: 0.3 - name: CountryTags - - 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 - - root: / - output: /addons/sourcemod/plugins - - targets: - - CountryTags