-
Notifications
You must be signed in to change notification settings - Fork 5
188 lines (160 loc) · 6.93 KB
/
build.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
name: Pawn Compiler
on:
push:
branches: [master]
paths-ignore:
- '**.md'
pull_request:
types: [opened, reopened, synchronize]
release:
types: [published]
tags:
- "v*.*.*"
jobs:
build:
name: "Build"
runs-on: ubuntu-latest
outputs:
sha: ${{ steps.declare_sha.outputs.sha }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check dependencies
run: |
sudo apt-get update
sudo apt-get install -y git
- name: Declare SHA & package name
id: declare_sha
shell: bash
run: |
SHA=$(git rev-parse --short HEAD)
echo "COMMIT_SHA=${SHA}" >> $GITHUB_ENV
echo "sha=$SHA" >> $GITHUB_OUTPUT
- name: Setup AMXXPawn Compiler
uses: wopox1337/setup-amxxpawn@master
with:
version: "1.10.5461"
- name: Setup 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: Updating app version
working-directory: version/
run: |
VERSION_FILE=version.h
APPVERSION_FILE=../addons/amxmodx/scripting/include/mm_incs/version.inc
APPVERSION_FILE_NATIVES=../addons/amxmodx/scripting/include/multimod_manager_version.inc
GIT_DIR=../
MAJOR=$(cat "$VERSION_FILE" | grep -wi 'MM_VERSION_MAJOR' | sed -e 's/.*MM_VERSION_MAJOR.*[^0-9]\([0-9][0-9]*\).*/\1/i' -e 's/\r//g')
if [ $? -ne 0 -o "$MAJOR" = "" ]; then
MAJOR=0
fi
MINOR=$(cat "$VERSION_FILE" | grep -wi 'MM_VERSION_MINOR' | sed -e 's/.*MM_VERSION_MINOR.*[^0-9]\([0-9][0-9]*\).*/\1/i' -e 's/\r//g')
if [ $? -ne 0 -o "$MINOR" = "" ]; then
MINOR=0
fi
MAINTENANCE=$(cat "$VERSION_FILE" | grep -i 'MM_VERSION_MAINTENANCE' | sed -e 's/.*MM_VERSION_MAINTENANCE.*[^0-9]\([0-9][0-9]*\).*/\1/i' -e 's/\r//g')
if [ $? -ne 0 -o "$MAINTENANCE" = "" ]; then
MAINTENANCE=0
fi
BRANCH_NAME=$(git -C "$GIT_DIR" rev-parse --abbrev-ref HEAD)
if [ $? -ne 0 -o "$BRANCH_NAME" = "" ]; then
BRANCH_NAME=master
fi
COMMIT_COUNT=$(git -C "$GIT_DIR" rev-list --count $BRANCH_NAME)
if [ $? -ne 0 -o "$COMMIT_COUNT" = "" ]; then
COMMIT_COUNT=0
fi
NEW_VERSION_INC="$MAJOR$MINOR$MAINTENANCE$COMMIT_COUNT"
NEW_VERSION="$MAJOR.$MINOR.$MAINTENANCE.$COMMIT_COUNT"
echo "NEW_VERSION_INC=${NEW_VERSION_INC}" >> $GITHUB_ENV
echo "NEW_VERSION=${NEW_VERSION}" >> $GITHUB_ENV
echo Updating $APPVERSION_FILE, new version is '"'$NEW_VERSION'"'
echo -e "#if defined _mm_version_included_\r" > $APPVERSION_FILE
echo -e " #endinput\r" >> $APPVERSION_FILE
echo -e "#endif\r" >> $APPVERSION_FILE
echo -e "#define _mm_version_included_\r" >> $APPVERSION_FILE
echo -e "\r" >> $APPVERSION_FILE
echo -e "// MultiMod Manager version\r" >> $APPVERSION_FILE
echo -e "#define MM_VERSION $NEW_VERSION_INC\r" >> $APPVERSION_FILE
echo -e "#define MM_VERSION_MAJOR $MAJOR\r" >> $APPVERSION_FILE
echo -e "#define MM_VERSION_MINOR $MINOR\r" >> $APPVERSION_FILE
echo -e "#define MM_VERSION_MAINTENANCE $MAINTENANCE\r" >> $APPVERSION_FILE
echo -e "#define MM_VERSION_COMMIT $COMMIT_COUNT\r" >> $APPVERSION_FILE
echo -e "\r" >> $APPVERSION_FILE
echo -e "#define PLUGIN_VERSION fmt("v%d.%d.%d.%d", MM_VERSION_MAJOR, MM_VERSION_MINOR, MM_VERSION_MAINTENANCE, MM_VERSION_COMMIT)" >> $APPVERSION_FILE
echo Updating $APPVERSION_FILE_NATIVES, new version is '"'$NEW_VERSION'"'
echo -e "#if defined _multimod_manager_version_included_\r" > $APPVERSION_FILE_NATIVES
echo -e " #endinput\r" >> $APPVERSION_FILE_NATIVES
echo -e "#endif\r" >> $APPVERSION_FILE_NATIVES
echo -e "#define _multimod_manager_version_included_\r" >> $APPVERSION_FILE_NATIVES
echo -e "\r" >> $APPVERSION_FILE_NATIVES
echo -e "// MultiMod Manager version\r" >> $APPVERSION_FILE_NATIVES
echo -e "#define MM_VERSION $NEW_VERSION_INC\r" >> $APPVERSION_FILE_NATIVES
echo -e "#define MM_VERSION_MAJOR $MAJOR\r" >> $APPVERSION_FILE_NATIVES
echo -e "#define MM_VERSION_MINOR $MINOR\r" >> $APPVERSION_FILE_NATIVES
echo -e "#define MM_VERSION_MAINTENANCE $MAINTENANCE\r" >> $APPVERSION_FILE_NATIVES
echo -e "#define MM_VERSION_COMMIT $COMMIT_COUNT\r" >> $APPVERSION_FILE_NATIVES
echo -e "\r" >> $APPVERSION_FILE_NATIVES
echo -e "#define MM_NATIVES_API_VER fmt("v%d.%d.%d.%d", MM_VERSION_MAJOR, MM_VERSION_MINOR, MM_VERSION_MAINTENANCE, MM_VERSION_COMMIT)" >> $APPVERSION_FILE_NATIVES
- name: Compile AMXX plugins
working-directory: addons/amxmodx/scripting/
env:
REAPI_INCLUDE: ${{ env.REAPI_INCLUDE_PATH }}
run: |
mkdir ../plugins/
for sourcefile in *.sma;
do
amxxfile="`echo $sourcefile | sed -e 's/\.sma$/.amxx/'`"
echo -n "Compiling $sourcefile ... "
amxxpc $(basename $sourcefile) -o"../plugins/$(basename $amxxfile)" -i"include" -i"$REAPI_INCLUDE"
done
- name: Move files
run: |
mkdir publish
mv addons/ -t publish/
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: MultiModManagerCS-${{ env.COMMIT_SHA }}
path: publish/*
publish:
name: "Publish"
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Deploying resources artifacts
uses: actions/download-artifact@v4
with:
name: MultiModManagerCS-${{ needs.build.outputs.sha }}
- name: Packaging binaries
id: packaging-job
if: |
github.event_name == 'release' &&
github.event.action == 'published' &&
startsWith(github.ref, 'refs/tags/')
run: |
7z a -mm=Deflate -mfb=258 -mpass=15 -r MultiModManagerCS-v${{ env.NEW_VERSION }}.zip addons/
- name: Publish artifacts
uses: softprops/action-gh-release@v2
id: publish-job
if: |
startsWith(github.ref, 'refs/tags/') &&
steps.packaging-job.outcome == 'success'
with:
files: |
*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}