Skip to content

Commit b059348

Browse files
authored
chore(ci): automatic tag and release (#969)
1 parent cdfb4e2 commit b059348

File tree

1 file changed

+73
-3
lines changed

1 file changed

+73
-3
lines changed

.github/workflows/plugin.yml

Lines changed: 73 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
name: CI
22

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
416

517
jobs:
618
build:
@@ -13,7 +25,7 @@ jobs:
1325
include:
1426
- os: ubuntu-20.04
1527
steps:
16-
- uses: actions/checkout@v3
28+
- uses: actions/checkout@v4
1729
- name: Build sourcemod plugin
1830
uses: maxime1907/action-sourceknight@v1
1931
with:
@@ -25,8 +37,66 @@ jobs:
2537
cp -R .sourceknight/package/* /tmp/package
2638
cp -R game/addons/sourcemod/configs /tmp/package/common/addons/sourcemod/
2739
cp -R game/addons/sourcemod/translations /tmp/package/common/addons/sourcemod/
40+
2841
- name: Upload build archive for test runners
29-
uses: actions/upload-artifact@v3
42+
uses: actions/upload-artifact@v4
3043
with:
3144
name: ${{ runner.os }}
3245
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

Comments
 (0)