-
-
Notifications
You must be signed in to change notification settings - Fork 8
145 lines (124 loc) · 4.21 KB
/
CI.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: CI
on:
push:
branches: [master]
paths-ignore:
- "**.md"
pull_request:
types: [opened, reopened, synchronize]
release:
types: [published]
jobs:
build:
name: "Build"
runs-on: ubuntu-20.04
outputs:
COMMIT_SHA: ${{ steps.declare_sha.outputs.COMMIT_SHA }}
SEMVER: ${{ steps.declare_sha.outputs.SEMVER }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Parse SemVer string (release)
id: semver_parser
if: |
github.event_name == 'release' &&
github.event.action == 'published' &&
startsWith(github.ref, 'refs/tags/')
uses: booxmedialtd/[email protected]
with:
input_string: ${{ github.ref }}
version_extractor_regex: 'refs\/tags\/(.*)$'
- name: Declare SHA & package name
id: declare_sha
shell: bash
run: |
SHA=$(git rev-parse --short HEAD)
echo "COMMIT_SHA=$SHA" >> $GITHUB_OUTPUT
echo "SEMVER=${{ steps.semver_parser.outputs.fullversion }}" >> $GITHUB_OUTPUT
- name: Setup latest ReAPI includes
env:
REPO: "s1lentq/reapi"
run: |
mkdir -p dep/reapi
cd dep/reapi
curl \
--silent \
https://api.github.com/repos/$REPO/releases/latest | \
grep "browser_download_url" | \
grep -Eo 'https://[^\"]*' | \
xargs wget
7z x *.zip
echo "REAPI_INCLUDE_PATH=$(pwd)/addons/amxmodx/scripting/include" >> $GITHUB_ENV
- name: Update versions for plugins (release)
working-directory: cstrike/addons/amxmodx/scripting/include/
if: |
github.event_name == 'release' &&
github.event.action == 'published' &&
startsWith(github.ref, 'refs/tags/')
env:
PLUGIN_VERSION: "${{ steps.declare_sha.outputs.SEMVER }}"
run: sed -i "s|%VERSION%|$PLUGIN_VERSION|g" redm.inc
- name: Update versions for plugins (only for artifacts builds)
working-directory: cstrike/addons/amxmodx/scripting/include/
env:
PLUGIN_VERSION: "${{ steps.declare_sha.outputs.COMMIT_SHA }}"
run: sed -i "s|%VERSION%|$PLUGIN_VERSION|g" redm.inc
- name: Setup AMXXPawn Compiler
uses: wopox1337/setup-amxxpawn@v1
with:
version: "1.10.5428"
- name: Compile plugins
working-directory: cstrike/addons/amxmodx/scripting/
env:
REAPI_INCLUDE: ${{ env.REAPI_INCLUDE_PATH }}
run: |
compile() {
sourcefile=$1
amxxfile="$(echo $sourcefile | sed -e 's/\.sma$/.amxx/')"
output_path="../plugins/$amxxfile"
mkdir -p $(dirname $output_path)
echo -n "Compiling $sourcefile ... "
amxxpc $sourcefile -o"$output_path" \
-i"include" \
-i"$REAPI_INCLUDE"
}
export -f compile
find * -type f -name "*.sma" -exec bash -c 'compile "$0"' {} \;
- name: Move files
run: |
mkdir publish
mv cstrike/ publish/
- name: Deploy artifact
uses: actions/[email protected]
with:
name: ReDeathmatch-${{ steps.declare_sha.outputs.COMMIT_SHA }}-dev
path: publish/*
publish:
name: "Publish release"
runs-on: ubuntu-20.04
needs: [build]
if: |
github.event_name == 'release' &&
github.event.action == 'published' &&
startsWith(github.ref, 'refs/tags/')
steps:
- name: Download artifact
uses: actions/[email protected]
with:
name: ReDeathmatch-${{ needs.build.outputs.COMMIT_SHA }}-dev
- name: Packaging binaries
id: packaging
run: 7z a -mm=Deflate -mfb=258 -mpass=15 -r ReDeathmatch-${{ needs.build.outputs.SEMVER }}.zip cstrike/
- name: Publish artifacts
uses: softprops/action-gh-release@v1
id: publish-job
if: |
startsWith(github.ref, 'refs/tags/') &&
steps.packaging.outcome == 'success'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: |
*.zip