|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [master] |
| 6 | + paths-ignore: |
| 7 | + - "**.md" |
| 8 | + |
| 9 | + pull_request: |
| 10 | + types: [opened, reopened, synchronize] |
| 11 | + release: |
| 12 | + types: [published] |
| 13 | + |
| 14 | +jobs: |
| 15 | + build: |
| 16 | + name: "Build" |
| 17 | + runs-on: ubuntu-latest |
| 18 | + outputs: |
| 19 | + sha: ${{ steps.declare_sha.outputs.sha }} |
| 20 | + semver: ${{ steps.declare_sha.outputs.semver }} |
| 21 | + steps: |
| 22 | + - name: Checkout |
| 23 | + uses: actions/checkout@v2 |
| 24 | + with: |
| 25 | + fetch-depth: 0 |
| 26 | + |
| 27 | + - name: Parse SemVer string (release) |
| 28 | + id: semver_parser |
| 29 | + if: | |
| 30 | + github.event_name == 'release' && |
| 31 | + github.event.action == 'published' && |
| 32 | + startsWith(github.ref, 'refs/tags/') |
| 33 | + uses: booxmedialtd/ws-action-parse-semver@v1 |
| 34 | + with: |
| 35 | + input_string: ${{ github.ref }} |
| 36 | + version_extractor_regex: '\/v(.*)$' |
| 37 | + |
| 38 | + - name: Declare SHA & package name |
| 39 | + id: declare_sha |
| 40 | + shell: bash |
| 41 | + run: | |
| 42 | + SHA=$(git rev-parse --short HEAD) |
| 43 | + echo "COMMIT_SHA=${SHA}" >> $GITHUB_ENV |
| 44 | + echo "::set-output name=sha::$SHA" |
| 45 | + echo "::set-output name=semver::${{ steps.semver_parser.outputs.fullversion }}" |
| 46 | +
|
| 47 | + - name: Setup latest AMXModX |
| 48 | + env: |
| 49 | + AMXMODX_VERSION_MINOR: "1.9" |
| 50 | + run: | |
| 51 | + LAST_VERSION_NAME=$( \ |
| 52 | + curl \ |
| 53 | + --silent \ |
| 54 | + https://www.amxmodx.org/amxxdrop/$AMXMODX_VERSION_MINOR/amxmodx-latest-base-linux \ |
| 55 | + ) |
| 56 | +
|
| 57 | + curl \ |
| 58 | + --remote-name \ |
| 59 | + --remote-header-name \ |
| 60 | + https://www.amxmodx.org/amxxdrop/$AMXMODX_VERSION_MINOR/$LAST_VERSION_NAME |
| 61 | +
|
| 62 | + tar xzf *.tar.gz |
| 63 | +
|
| 64 | + - name: Setup latest ReAPI includes |
| 65 | + env: |
| 66 | + REPO: "s1lentq/reapi" |
| 67 | + run: | |
| 68 | + curl \ |
| 69 | + --silent \ |
| 70 | + https://api.github.com/repos/$REPO/releases/latest | \ |
| 71 | + grep "browser_download_url" | \ |
| 72 | + grep -Eo 'https://[^\"]*' | \ |
| 73 | + xargs wget |
| 74 | +
|
| 75 | + 7z x *.zip |
| 76 | +
|
| 77 | + - name: Clean compiler |
| 78 | + run: | |
| 79 | + mkdir -p compiler/compiled |
| 80 | + cp -Rf addons/amxmodx/scripting/* compiler/ |
| 81 | + rm -rf compiler/*.sma |
| 82 | + rm -rf compiler/testsuite/ |
| 83 | +
|
| 84 | + rm -rf addons/ |
| 85 | +
|
| 86 | + - name: Update versions for plugins (release) |
| 87 | + if: | |
| 88 | + github.event_name == 'release' && |
| 89 | + github.event.action == 'published' && |
| 90 | + startsWith(github.ref, 'refs/tags/') |
| 91 | + env: |
| 92 | + PLUGIN_VERSION: "v${{ steps.semver_parser.outputs.fullversion }}" |
| 93 | + run: | |
| 94 | + cd cstrike/addons/amxmodx/scripting/include/ |
| 95 | + sed -i "s|%CA_VERSION%|$PLUGIN_VERSION|g" ChatAdditions.inc |
| 96 | +
|
| 97 | + - name: Update versions for plugins |
| 98 | + env: |
| 99 | + PLUGIN_VERSION: "${{ env.COMMIT_SHA }}" |
| 100 | + run: | |
| 101 | + cd cstrike/addons/amxmodx/scripting/include/ |
| 102 | + sed -i "s|%CA_VERSION%|$PLUGIN_VERSION|g" ChatAdditions.inc |
| 103 | +
|
| 104 | + - name: Build |
| 105 | + env: |
| 106 | + COMPILER_PATH: "compiler" |
| 107 | + run: | |
| 108 | + cp -Rf cstrike/addons/amxmodx/scripting/* compiler/ |
| 109 | + cd compiler |
| 110 | +
|
| 111 | + for sourcefile in *.sma; |
| 112 | + do |
| 113 | + amxxfile="`echo $sourcefile | sed -e 's/\.sma$/.amxx/'`" |
| 114 | + echo -n "Compiling $sourcefile ..." |
| 115 | + ./amxxpc $sourcefile -ocompiled/$amxxfile >> temp.txt |
| 116 | + echo "done" |
| 117 | + done |
| 118 | +
|
| 119 | + cat temp.txt |
| 120 | + rm temp.txt |
| 121 | +
|
| 122 | + - name: Move files |
| 123 | + run: | |
| 124 | + mkdir publish |
| 125 | + mv cstrike/ publish/ |
| 126 | + mv compiler/compiled/ publish/cstrike/addons/amxmodx/plugins/ |
| 127 | +
|
| 128 | + - name: Upload artifact |
| 129 | + uses: actions/upload-artifact@v2 |
| 130 | + with: |
| 131 | + name: ChatAdditions-${{ env.COMMIT_SHA }}-dev |
| 132 | + path: publish/* |
| 133 | + |
| 134 | + publish: |
| 135 | + name: "Publish" |
| 136 | + runs-on: ubuntu-latest |
| 137 | + needs: [build] |
| 138 | + if: | |
| 139 | + github.event_name == 'release' && |
| 140 | + github.event.action == 'published' && |
| 141 | + startsWith(github.ref, 'refs/tags/') |
| 142 | + steps: |
| 143 | + - name: Download artifacts |
| 144 | + uses: actions/download-artifact@v2 |
| 145 | + with: |
| 146 | + name: ChatAdditions-${{needs.build.outputs.sha}}-dev |
| 147 | + |
| 148 | + - name: Packaging binaries |
| 149 | + id: packaging |
| 150 | + run: 7z a -mm=Deflate -mfb=258 -mpass=15 -r ChatAdditions-v${{needs.build.outputs.semver}}.zip cstrike/ |
| 151 | + |
| 152 | + - name: Publish artifacts |
| 153 | + uses: softprops/action-gh-release@v1 |
| 154 | + id: publish-job |
| 155 | + if: | |
| 156 | + startsWith(github.ref, 'refs/tags/') && |
| 157 | + steps.packaging.outcome == 'success' |
| 158 | + env: |
| 159 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 160 | + with: |
| 161 | + files: | |
| 162 | + *.zip |
0 commit comments