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