|
| 1 | +name: Compile and Package |
| 2 | + |
| 3 | +env: |
| 4 | + PLUGIN_NAME: hwn_cosmetic_enabler |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - master |
| 10 | + pull_request: |
| 11 | + branches: |
| 12 | + - master |
| 13 | + |
| 14 | +jobs: |
| 15 | + build: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + strategy: |
| 18 | + matrix: |
| 19 | + sourcemod-version: [ '1.11' ] |
| 20 | + |
| 21 | + steps: |
| 22 | + - name: Checkout repository |
| 23 | + uses: actions/checkout@v4 |
| 24 | + |
| 25 | + - name: Cache SourceMod distribution |
| 26 | + id: cache |
| 27 | + uses: actions/cache@v3 |
| 28 | + with: |
| 29 | + path: sourcemod_dist |
| 30 | + key: sourcemod-${{ matrix.sourcemod-version }} |
| 31 | + |
| 32 | + - name: Download SourceMod |
| 33 | + if: steps.cache.outputs.cache-hit != 'true' |
| 34 | + run: | |
| 35 | + mkdir sourcemod_dist |
| 36 | + cd sourcemod_dist |
| 37 | + filename=$(curl -s https://sm.alliedmods.net/smdrop/${{ matrix.sourcemod-version }}/sourcemod-latest-linux) |
| 38 | + curl -O https://sm.alliedmods.net/smdrop/${{ matrix.sourcemod-version }}/$filename |
| 39 | + tar -xzf $filename |
| 40 | +
|
| 41 | + - name: Extract plugin version |
| 42 | + id: version |
| 43 | + run: | |
| 44 | + VERSION=$(grep -oP '#define PLUGIN_VERSION "\K[^"]+' addons/sourcemod/scripting/${{ env.PLUGIN_NAME }}.sp) |
| 45 | + echo "PLUGIN_VERSION=$VERSION" >> $GITHUB_ENV |
| 46 | +
|
| 47 | + - name: Compile plugin |
| 48 | + run: | |
| 49 | + chmod +x sourcemod_dist/addons/sourcemod/scripting/spcomp |
| 50 | + mkdir -p addons/sourcemod/plugins |
| 51 | + ./sourcemod_dist/addons/sourcemod/scripting/spcomp -E addons/sourcemod/scripting/${{ env.PLUGIN_NAME }}.sp -o addons/sourcemod/plugins/${{ env.PLUGIN_NAME }}.smx |
| 52 | +
|
| 53 | + - name: Create release archive |
| 54 | + run: | |
| 55 | + zip -r ${{ env.PLUGIN_NAME }}-${{ env.PLUGIN_VERSION }}.zip addons/ |
| 56 | +
|
| 57 | + - name: Create GitHub release |
| 58 | + run: | |
| 59 | + gh auth login --with-token <<< ${{ secrets.GITHUB_TOKEN }} |
| 60 | + gh config set git_protocol ssh |
| 61 | + if ! gh release view ${{ env.PLUGIN_VERSION }} --repo ${{ github.repository }} > /dev/null 2>&1; then |
| 62 | + gh release create ${{ env.PLUGIN_VERSION }} ./${{ env.PLUGIN_NAME }}-${{ env.PLUGIN_VERSION }}.zip -t "${{ env.PLUGIN_VERSION }}" --repo ${{ github.repository }} |
| 63 | + fi |
0 commit comments