From 4f1baf0e6a920ca82215daf873e30bdf5d8183c1 Mon Sep 17 00:00:00 2001 From: Mikusch Date: Thu, 22 Feb 2024 14:59:19 +0100 Subject: [PATCH] Update CI --- .github/workflows/compile.yml | 63 ------------------------------- .github/workflows/main.yml | 71 +++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 63 deletions(-) delete mode 100644 .github/workflows/compile.yml create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml deleted file mode 100644 index 4d73b32..0000000 --- a/.github/workflows/compile.yml +++ /dev/null @@ -1,63 +0,0 @@ -name: Compile and Package - -env: - PLUGIN_NAME: hwn_cosmetic_enabler - -on: - push: - branches: - - master - pull_request: - branches: - - master - -jobs: - build: - runs-on: ubuntu-latest - strategy: - matrix: - sourcemod-version: [ '1.11' ] - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Cache SourceMod distribution - id: cache - uses: actions/cache@v3 - with: - path: sourcemod_dist - key: sourcemod-${{ matrix.sourcemod-version }} - - - name: Download SourceMod - if: steps.cache.outputs.cache-hit != 'true' - run: | - mkdir sourcemod_dist - cd sourcemod_dist - filename=$(curl -s https://sm.alliedmods.net/smdrop/${{ matrix.sourcemod-version }}/sourcemod-latest-linux) - curl -O https://sm.alliedmods.net/smdrop/${{ matrix.sourcemod-version }}/$filename - tar -xzf $filename - - - name: Extract plugin version - id: version - run: | - VERSION=$(grep -oP '#define PLUGIN_VERSION\s+"\K[^"]+' addons/sourcemod/scripting/${{ env.PLUGIN_NAME }}.sp) - echo "PLUGIN_VERSION=$VERSION" >> $GITHUB_ENV - - - name: Compile plugin - run: | - chmod +x sourcemod_dist/addons/sourcemod/scripting/spcomp - mkdir -p addons/sourcemod/plugins - ./sourcemod_dist/addons/sourcemod/scripting/spcomp -E addons/sourcemod/scripting/${{ env.PLUGIN_NAME }}.sp -o addons/sourcemod/plugins/${{ env.PLUGIN_NAME }}.smx - - - name: Create release archive - run: | - zip -r ${{ env.PLUGIN_NAME }}-${{ env.PLUGIN_VERSION }}.zip addons/ - - - name: Create GitHub release - run: | - gh auth login --with-token <<< ${{ secrets.GITHUB_TOKEN }} - gh config set git_protocol ssh - if ! gh release view ${{ env.PLUGIN_VERSION }} --repo ${{ github.repository }} > /dev/null 2>&1; then - gh release create ${{ env.PLUGIN_VERSION }} ./${{ env.PLUGIN_NAME }}-${{ env.PLUGIN_VERSION }}.zip -t "${{ env.PLUGIN_VERSION }}" --repo ${{ github.repository }} - fi diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..70cb725 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,71 @@ +name: Compile and release + +on: + push: + branches: + master + +env: + PLUGIN_NAME: hwn_cosmetic_enabler + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + sm-version: [ '1.11.x' ] + permissions: + contents: write + + steps: + - uses: actions/checkout@v4 + + - name: Set environment variables + run: echo SCRIPTS_PATH=$(pwd) >> $GITHUB_ENV + + - name: Setup SourcePawn Compiler ${{ matrix.sm-version }} + id: setup_sp + uses: rumblefrog/setup-sp@master + with: + version: ${{ matrix.sm-version }} + version-file: ./addons/sourcemod/scripting/${{ env.PLUGIN_NAME }}.sp + define-name: PLUGIN_VERSION + + - name: Compile plugins + run: | + mkdir ../plugins + spcomp -v2 -E -i "include" -o"../plugins/${{ env.PLUGIN_NAME }}.smx" ${{ env.PLUGIN_NAME }}.sp + echo "===OUT FILES===" + ls ../plugins + echo "===VERSION===" + echo ${{ steps.setup_sp.outputs.plugin-version }} + working-directory: ${{ env.SCRIPTS_PATH }}/addons/sourcemod/scripting + + - name: Install zip + uses: montudor/action-zip@v1 + + - name: Zip output + run: | + zip -qq -y -r ${{ github.event.repository.name }}.zip configs plugins scripting extensions gamedata translations data + working-directory: ${{ env.SCRIPTS_PATH }}/addons/sourcemod + + - name: List files in the directory + run: ls -R + working-directory: ${{ env.SCRIPTS_PATH }}/addons/sourcemod + + - name: List files in the zip + run: unzip -l ${{ github.event.repository.name }}.zip + working-directory: ${{ env.SCRIPTS_PATH }}/addons/sourcemod + + - name: Create Release + uses: ncipollo/release-action@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + token: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ steps.setup_sp.outputs.plugin-version }} + artifacts: addons/sourcemod/${{ github.event.repository.name }}.zip + draft: true + allowUpdates: true + updateOnlyUnreleased: true + skipIfReleaseExists: true