|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: [push, pull_request] |
| 4 | + |
| 5 | +jobs: |
| 6 | + build: |
| 7 | + name: "Build" |
| 8 | + runs-on: ${{ matrix.os }} |
| 9 | + strategy: |
| 10 | + fail-fast: false |
| 11 | + matrix: |
| 12 | + os: [ubuntu-20.04] |
| 13 | + include: |
| 14 | + - os: ubuntu-20.04 |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v3 |
| 17 | + - name: Build sourcemod plugin |
| 18 | + uses: maxime1907/action-sourceknight@v1 |
| 19 | + with: |
| 20 | + cmd: build |
| 21 | + |
| 22 | + - name: Create package |
| 23 | + run: | |
| 24 | + mkdir -p /tmp/package |
| 25 | + cp -R .sourceknight/package/* /tmp/package |
| 26 | + cp -R game/addons/sourcemod/configs /tmp/package/common/addons/sourcemod/ |
| 27 | + cp -R game/addons/sourcemod/translations /tmp/package/common/addons/sourcemod/ |
| 28 | + - name: Upload build archive for test runners |
| 29 | + uses: actions/upload-artifact@v3 |
| 30 | + with: |
| 31 | + name: ${{ runner.os }} |
| 32 | + path: /tmp/package |
| 33 | + |
| 34 | + tag: |
| 35 | + name: Tag |
| 36 | + needs: build |
| 37 | + runs-on: ubuntu-latest |
| 38 | + steps: |
| 39 | + - uses: actions/checkout@v3 |
| 40 | + if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/php81' |
| 41 | + |
| 42 | + - uses: dev-drprasad/delete-tag-and-release@v0.2.1 |
| 43 | + if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/php81' |
| 44 | + with: |
| 45 | + delete_release: true |
| 46 | + tag_name: latest |
| 47 | + env: |
| 48 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 49 | + |
| 50 | + - uses: rickstaa/action-create-tag@v1 |
| 51 | + if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/php81' |
| 52 | + with: |
| 53 | + tag: "latest" |
| 54 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 55 | + |
| 56 | + release: |
| 57 | + name: Release |
| 58 | + if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/php81' |
| 59 | + needs: [build, tag] |
| 60 | + runs-on: ubuntu-latest |
| 61 | + steps: |
| 62 | + - name: Download artifacts |
| 63 | + uses: actions/download-artifact@v3 |
| 64 | + |
| 65 | + - name: Versioning |
| 66 | + run: | |
| 67 | + version="latest" |
| 68 | + if [[ "${{ github.ref_type }}" == 'tag' ]]; then |
| 69 | + version=`echo $GITHUB_REF | sed "s/refs\/tags\///"`; |
| 70 | + fi |
| 71 | + echo "RELEASE_VERSION=$version" >> $GITHUB_ENV |
| 72 | + - name: Package |
| 73 | + run: | |
| 74 | + ls -Rall |
| 75 | + if [ -d "./Linux/" ]; then |
| 76 | + cd ./Linux/ |
| 77 | + tar -czf ../${{ github.event.repository.name }}-${{ env.RELEASE_VERSION }}.tar.gz -T <(\ls -1) |
| 78 | + cd - |
| 79 | + fi |
| 80 | + - name: Release |
| 81 | + uses: svenstaro/upload-release-action@v2 |
| 82 | + with: |
| 83 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 84 | + file: '*.tar.gz' |
| 85 | + tag: ${{ env.RELEASE_VERSION }} |
| 86 | + file_glob: true |
| 87 | + overwrite: true |
0 commit comments