Skip to content

Commit 1e258fd

Browse files
authored
Using matrix for workflow
1 parent 5e399f5 commit 1e258fd

1 file changed

Lines changed: 41 additions & 113 deletions

File tree

.github/workflows/main.yml

Lines changed: 41 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,29 @@ name: Build
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [main]
66
pull_request:
7-
branches: [ main ]
7+
branches: [main]
88

99
workflow_dispatch:
1010

1111
jobs:
12-
buildLinux:
13-
runs-on: ubuntu-latest
12+
build:
13+
strategy:
14+
matrix:
15+
include:
16+
- target: windows
17+
title: Windows
18+
runs-on: windows-latest
19+
- target: macos
20+
title: Mac
21+
runs-on: macos-14
22+
- target: linux
23+
title: Linux
24+
runs-on: ubuntu-latest
25+
26+
name: build${{ matrix.title }}
27+
runs-on: ${{ matrix.runs-on }}
1428

1529
steps:
1630
- uses: actions/checkout@main
@@ -25,138 +39,52 @@ jobs:
2539
with:
2640
path: |
2741
.haxelib/
28-
export/release/linux/haxe/
29-
export/release/linux/obj/
30-
key: cache-build-linux
42+
export/release/${{ matrix.target }}/haxe/
43+
export/release/${{ matrix.target }}/obj/
44+
key: cache-${{ matrix.target }}-release
3145

32-
- name: Installing Libraries
33-
run: haxe --interp -cp ./actions/libs-installer -D analyzer-optimize -main Main
34-
- name: Create Version Tag
35-
run: echo "${{github.run_id}}" > VERSION
36-
37-
- name: Compile
38-
run: haxelib run lime build linux
39-
40-
- name: Clear Previous Cache
41-
uses: actions/github-script@main
42-
with:
43-
script: await require('./actions/cache/clear-cache.js')({github, context}, 'cache-build-linux');
44-
45-
- name: Save Current Cache
46-
uses: actions/cache@main
47-
with:
48-
key: cache-build-linux
49-
path: |
50-
.haxelib/
51-
export/release/linux/haxe/
52-
export/release/linux/obj/
53-
restore-keys: |
54-
cache-build-linux
55-
56-
- name: Tar files
57-
run: tar -zcvf Template.tar.gz export/release/linux/bin
58-
- name: Publish Artifact
59-
uses: actions/upload-artifact@main
60-
with:
61-
name: linuxBuild
62-
path: Template.tar.gz
63-
buildWindows:
64-
runs-on: windows-latest
65-
66-
steps:
67-
- uses: actions/checkout@main
68-
69-
- uses: krdlab/setup-haxe@master
70-
with:
71-
haxe-version: 4.3.7
46+
- name: Set Cache Status | In Windows
47+
id: cache-status-windows
48+
if: matrix.target == 'windows'
49+
run: echo CACHE_HIT=${{ steps.cache-build-restore.outputs.cache-hit }} | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8
50+
shell: powershell
7251

73-
- name: Restore Previous Cache
74-
id: cache-build-restore
75-
uses: actions/cache/restore@main
76-
with:
77-
path: |
78-
.haxelib/
79-
export/release/windows/haxe/
80-
export/release/windows/obj/
81-
key: cache-build-windows
52+
- name: Set Cache Status | In Unix
53+
id: cache-status-unix
54+
if: matrix.target != 'windows'
55+
run: echo "CACHE_HIT=${{ steps.cache-build-restore.outputs.cache-hit }}" >> $GITHUB_ENV
8256

8357
- name: Installing Libraries
8458
run: haxe --interp -cp ./actions/libs-installer -D analyzer-optimize -main Main
85-
- name: Create Version Tag
86-
run: echo "${{github.run_id}}" > VERSION
8759

88-
- name: Compile
89-
run: haxelib run lime build windows
90-
91-
- name: Clear Previous Cache
92-
uses: actions/github-script@main
93-
with:
94-
script: await require('./actions/cache/clear-cache.js')({github, context}, 'cache-build-windows');
95-
96-
- name: Save Current Cache
97-
uses: actions/cache@main
98-
with:
99-
key: cache-build-windows
100-
path: |
101-
.haxelib/
102-
export/release/windows/haxe/
103-
export/release/windows/obj/
104-
restore-keys: |
105-
cache-build-windows
106-
107-
- name: Upload Artifact
108-
uses: actions/upload-artifact@main
109-
with:
110-
name: windowsBuild
111-
path: export/release/windows/bin
112-
buildMac:
113-
runs-on: macos-15
114-
115-
steps:
116-
- uses: actions/checkout@main
117-
118-
- uses: krdlab/setup-haxe@master
119-
with:
120-
haxe-version: 4.3.7
121-
122-
- name: Restore Previous Cache
123-
id: cache-build-restore
124-
uses: actions/cache/restore@main
125-
with:
126-
path: |
127-
.haxelib/
128-
export/release/macos/haxe/
129-
export/release/macos/obj/
130-
key: cache-build-mac
131-
132-
- name: Installing Libraries
133-
run: haxe --interp -cp ./actions/libs-installer -D analyzer-optimize -main Main
13460
- name: Create Version Tag
13561
run: echo "${{github.run_id}}" > VERSION
13662

13763
- name: Compile
138-
run: haxelib run lime build mac
64+
run: haxelib run lime build ${{ matrix.target }}
13965

14066
- name: Clear Previous Cache
14167
uses: actions/github-script@main
14268
with:
143-
script: await require('./actions/cache/clear-cache.js')({github, context}, 'cache-build-mac');
69+
script: await require('./actions/cache/clear-cache.js')({github, context}, 'cache-${{ matrix.target }}-release');
14470

14571
- name: Save Current Cache
14672
uses: actions/cache@main
14773
with:
148-
key: cache-build-mac
74+
key: cache-${{ matrix.target }}-release
14975
path: |
15076
.haxelib/
151-
export/release/macos/haxe/
152-
export/release/macos/obj/
77+
export/release/${{ matrix.target }}/haxe/
78+
export/release/${{ matrix.target }}/obj/
15379
restore-keys: |
154-
cache-build-mac
80+
cache-${{ matrix.target }}-release
15581
15682
- name: Tar files
83+
if: matrix.target == 'macos'
15784
run: tar -zcvf Template.tar.gz export/release/macos/bin
158-
- name: Publish Artifact
85+
86+
- name: Upload Artifact
15987
uses: actions/upload-artifact@main
16088
with:
161-
name: macBuild
162-
path: Template.tar.gz
89+
name: ${{ matrix.target }}Build
90+
path: export/release/${{ matrix.target }}/bin

0 commit comments

Comments
 (0)