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