-
Notifications
You must be signed in to change notification settings - Fork 0
240 lines (192 loc) · 7.02 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
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
name: CI
on:
push:
paths-ignore:
- "**.md"
- "docs/**"
pull_request:
paths-ignore:
- "**.md"
- "docs/**"
env:
ROCKSPEC_VERSION: 0.0.4
DEV_ROCKSPEC: lua-uuid-dev-1.rockspec
jobs:
build:
name: Build
runs-on: ${{ matrix.os }}
defaults:
run:
shell: pwsh
strategy:
matrix:
lua-version:
- 5.1
- 5.2
- 5.3
- 5.4
- luajit
os:
- windows-latest
- ubuntu-latest
- macos-latest
exclude:
- os: macos-latest
lua-version: luajit
steps:
- name: Set environment variable to hold the rockspec name
run: |
if ("${{ github.repository }}" -eq "luau-project/lua-uuid" -and "${{ github.ref_name }}" -eq "v${{ env.ROCKSPEC_VERSION }}" -and "${{ github.ref }}" -eq "refs/tags/v${{ env.ROCKSPEC_VERSION }}")
{
Add-Content "${{ github.env }}" "ROCKSPEC=lua-uuid-${{ env.ROCKSPEC_VERSION }}-0.rockspec";
}
else
{
Add-Content "${{ github.env }}" "ROCKSPEC=${{ env.DEV_ROCKSPEC }}";
}
- name: Checkout
uses: actions/checkout@v4
with:
path: lua-uuid
- name: Install libuuid-dev
if: ${{ matrix.os == 'ubuntu-latest' }}
run: sudo apt install -y uuid-dev
- name: Setup MSVC dev-prompt
if: ${{ matrix.os == 'windows-latest' && matrix.lua-version != 'luajit' }}
uses: ilammy/msvc-dev-cmd@v1
- name: Setup Lua
uses: luarocks/gh-actions-lua@v10
with:
luaVersion: ${{ matrix.lua-version }}
- name: Setup LuaRocks
uses: luarocks/gh-actions-luarocks@v5
- name: Build lua-uuid
working-directory: lua-uuid
run: |
$rockspec = Get-ChildItem . -Recurse -File |
Where-Object Name -EQ "${{ env.ROCKSPEC }}" |
Select-Object -ExpandProperty FullName -First 1;
$color = (0x1b -as [char]) + "[36m";
Write-Host "Building rockspec file: ${color}${rockspec}";
luarocks make $rockspec;
- name: Run samples
working-directory: lua-uuid
run: |
Get-ChildItem "samples" -Recurse -File |
Where-Object Extension -EQ ".lua" |
Select-Object -ExpandProperty FullName |
Foreach-Object {
$color = (0x1b -as [char]) + "[36m";
Write-Host "Running sample file: ${color}$_";
lua "$_";
};
msys2-build:
name: MSYS2 Build
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}
strategy:
matrix:
MSYS2_CONFIG:
- { sys: mingw64, env: x86_64 }
- { sys: ucrt64, env: ucrt-x86_64 }
- { sys: clang64, env: clang-x86_64 }
Lua:
- { version: '5.4', msys2-pkg-name: 'lua', msys2-lua-interpreter: 'lua' }
- { version: '5.3', msys2-pkg-name: 'lua53', msys2-lua-interpreter: 'lua5.3' }
- { version: '5.1', msys2-pkg-name: 'lua51', msys2-lua-interpreter: 'lua5.1' }
- { version: '5.1', msys2-pkg-name: 'luajit', msys2-lua-interpreter: 'luajit' }
env:
LUA_INTERPRETER: /${{ matrix.MSYS2_CONFIG.sys }}/bin/${{ matrix.Lua.msys2-lua-interpreter }}
steps:
- name: Setup MSYS2
uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.MSYS2_CONFIG.sys }}
install: |
base-devel
git
mingw-w64-${{ matrix.MSYS2_CONFIG.env }}-cc
mingw-w64-${{ matrix.MSYS2_CONFIG.env }}-${{ matrix.Lua.msys2-pkg-name }}
mingw-w64-${{ matrix.MSYS2_CONFIG.env }}-lua-luarocks
- name: Set environment variable to hold the rockspec name
run: |
if [[ "${{ github.repository }}" == "luau-project/lua-uuid" ]] && [[ "${{ github.ref_name }}" == "v${{ env.ROCKSPEC_VERSION }}" ]] && [[ "${{ github.ref }}" == "refs/tags/v${{ env.ROCKSPEC_VERSION }}" ]];
then
echo "ROCKSPEC=lua-uuid-${{ env.ROCKSPEC_VERSION }}-0.rockspec" >> "${{ github.env }}";
else
echo "ROCKSPEC=${{ env.DEV_ROCKSPEC }}" >> "${{ github.env }}";
fi;
- name: Configure LuaRocks
run: |
source /etc/makepkg_mingw.conf
echo "CC=/${{ matrix.MSYS2_CONFIG.sys }}/bin/${CC}" >> "${{ github.env }}"
echo "CFLAGS=${CFLAGS}" >> "${{ github.env }}"
luarocks config lua_version "${{ matrix.Lua.version }}"
luarocks config lua_dir "/${{ matrix.MSYS2_CONFIG.sys }}"
- name: Checkout
uses: actions/checkout@v4
with:
path: lua-uuid
- name: Build lua-uuid
working-directory: lua-uuid
run: |
rockspec="rockspecs/${{ env.ROCKSPEC }}"
echo -e "Building rockspec: \e[36m${rockspec}\e[0m"
luarocks make ${rockspec}
- name: Run samples
working-directory: lua-uuid
run: |
for sample in samples/*.lua;
do
echo -e "Running sample file: \e[36m${sample}\e[0m"
${{ env.LUA_INTERPRETER }} $sample;
done;
upload-rockspec:
name: Upload rockspec
runs-on: ubuntu-latest
if: ${{ github.repository == 'luau-project/lua-uuid' && startsWith(github.ref, 'refs/tags/') }}
needs:
- build
- msys2-build
defaults:
run:
shell: pwsh
steps:
- name: Set environment variable to hold the rockspec name
run: |
if ("${{ github.repository }}" -eq "luau-project/lua-uuid" -and "${{ github.ref_name }}" -eq "v${{ env.ROCKSPEC_VERSION }}" -and "${{ github.ref }}" -eq "refs/tags/v${{ env.ROCKSPEC_VERSION }}")
{
Add-Content "${{ github.env }}" "ROCKSPEC=lua-uuid-${{ env.ROCKSPEC_VERSION }}-0.rockspec";
}
else
{
Add-Content "${{ github.env }}" "ROCKSPEC=${{ env.DEV_ROCKSPEC }}";
}
- name: Checkout
uses: actions/checkout@v4
with:
path: lua-uuid
- name: Install libuuid-dev
run: sudo apt install -y uuid-dev libssl-dev
- name: Setup Lua
uses: luarocks/gh-actions-lua@v10
- name: Setup LuaRocks
uses: luarocks/gh-actions-luarocks@v5
- name: Install dependencies
run: |
luarocks install dkjson
luarocks install luasocket
luarocks install luasec
- name: Upload rockspec to LuaRocks
working-directory: lua-uuid
env:
UPLOAD_KEY: ${{ secrets.LUAROCKS_APIKEY }}
run: |
$rockspec = Get-ChildItem . -Recurse -File |
Where-Object Name -EQ "${{ env.ROCKSPEC }}" |
Select-Object -ExpandProperty FullName -First 1;
$color = (0x1b -as [char]) + "[36m";
Write-Host "Uploading rockspec: ${color}${rockspec}";
luarocks upload $rockspec "--api-key=$env:UPLOAD_KEY" --skip-pack