From dcd662027f839acb3d34d8e7edc99ff6e20b54e0 Mon Sep 17 00:00:00 2001 From: Mikusch Date: Sat, 7 Oct 2023 18:37:36 +0200 Subject: [PATCH] Add workflow file --- .github/workflows/compile.yml | 63 +++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .github/workflows/compile.yml diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml new file mode 100644 index 0000000..1605514 --- /dev/null +++ b/.github/workflows/compile.yml @@ -0,0 +1,63 @@ +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 "\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