diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ec78128..429a164 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,56 +1,65 @@ name: CI -on: - push: - branches: - - main - - master - tags: - - '*' - pull_request: - branches: - - main - - master +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-DynamicChannels.git deps/dynamicchannels + cp -R deps/dynamicchannels/scripting/include/* addons/sourcemod/scripting/include/ + git clone --depth=1 https://github.com/srcdslab/sm-plugin-zombiereloaded.git deps/zombiereloaded + cp -R deps/zombiereloaded/src/addons/sourcemod/scripting/include/* addons/sourcemod/scripting/include/ + git clone --depth=1 https://github.com/srcdslab/sm-plugin-KnockbackRestrict.git deps/knockbackrestrict + cp -R deps/knockbackrestrict/addons/sourcemod/scripting/include/* addons/sourcemod/scripting/include/ + git clone --depth=1 https://github.com/srcdslab/sm-plugin-EntWatch.git deps/entwatch + cp -R deps/entwatch/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/FunModes.smx FunModes.sp - name: Create package run: | - mkdir -p /tmp/package - cp -R .sourceknight/package/* /tmp/package - cp -R addons/sourcemod/translations /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/ + cp -R addons/sourcemod/translations /tmp/package/addons/sourcemod/ - name: Upload build archive for test runners uses: actions/upload-artifact@v7 with: - name: package + 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 - 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 @@ -58,44 +67,47 @@ 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 uses: actions/download-artifact@v8 with: - path: package + name: ${{ runner.os }} + path: artifacts - 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: | - ls -Rall - if [ -d "./package/" ]; then - cd ./package/ - tar -czf ../${{ github.event.repository.name }}-${{ env.RELEASE_VERSION }}.tar.gz -T <(\ls -1) - cd - - fi + 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' + file: "*.tar.gz" tag: ${{ env.RELEASE_VERSION }} file_glob: true overwrite: true diff --git a/sourceknight.yaml b/sourceknight.yaml deleted file mode 100644 index 9633412..0000000 --- a/sourceknight.yaml +++ /dev/null @@ -1,51 +0,0 @@ -project: - sourceknight: 0.3 - name: FunModes - dependencies: - - name: sourcemod - type: tar - version: 1.12.0-git7221 - location: https://sm.alliedmods.net/smdrop/1.12/sourcemod-1.12.0-git7221-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: dynamicchannels - type: git - repo: https://github.com/srcdslab/sm-plugin-DynamicChannels - unpack: - - source: /scripting/include - dest: /addons/sourcemod/scripting/include - - - name: zombiereloaded - type: git - repo: https://github.com/srcdslab/sm-plugin-zombiereloaded - unpack: - - source: /src/addons/sourcemod/scripting/include - dest: /addons/sourcemod/scripting/include - - - name: KnockbackRestrict - type: git - repo: https://github.com/srcdslab/sm-plugin-KnockbackRestrict - unpack: - - source: /addons/sourcemod/scripting/include - dest: /addons/sourcemod/scripting/include - - - name: EntWatch - type: git - repo: https://github.com/srcdslab/sm-plugin-EntWatch - unpack: - - source: /addons/sourcemod/scripting/include - dest: /addons/sourcemod/scripting/include - - root: / - output: /addons/sourcemod/plugins - targets: - - FunModes