-
Notifications
You must be signed in to change notification settings - Fork 13
151 lines (144 loc) · 5.71 KB
/
main.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
name: Tetris AI DLL CI
permissions: write-all
on:
push:
branches: [ botris, ci-*, master ]
tags: [ pre*, v* ]
pull_request:
branches: [ master ]
jobs:
get-info:
runs-on: ubuntu-latest
outputs:
branchName: ${{ steps.git-info.outputs.branchName }}
commitHash: ${{ steps.git-info.outputs.commitHash }}
steps:
- uses: actions/checkout@v4
- name: Get git info
id: git-info
shell: bash
run: |
BRANCH_NAME=$(git branch --show-current)
COMMIT_HASH=$(git rev-parse --short ${{ GITHUB.SHA }})
echo "branchName=$BRANCH_NAME" >> $GITHUB_OUTPUT
echo "commitHash=$COMMIT_HASH" >> $GITHUB_OUTPUT
build-linux:
runs-on: ubuntu-24.04
needs: get-info
env:
OUTPUT_FOLDER: ./build
PROJECT_NAME: tetris_ai
RELEASE_FOLDER: ./release
strategy:
matrix:
config: [ Debug, Release ]
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Setup CMake
uses: lukka/get-cmake@latest
- name: CMake Configure and Build
env:
CC: gcc-14
CXX: g++-14
run: |
cmake -S "${{ github.workspace }}" -B "${{ github.workspace }}/${{ env.OUTPUT_FOLDER }}" -DCMAKE_BUILD_TYPE=${{ matrix.config }}
cmake --build "${{ github.workspace }}/${{ env.OUTPUT_FOLDER }}" --target ${{ env.PROJECT_NAME }}
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ env.PROJECT_NAME }}_${{ needs.get-info.outputs.branchName }}_${{ needs.get-info.outputs.commitHash }}_${{ GITHUB.RUN_NUMBER }}_Linux_${{ matrix.config }}
path: "${{ env.OUTPUT_FOLDER }}/*.so"
- name: Prepare for release
if: ${{ (startsWith(github.ref, 'refs/tags/pre') || startsWith(github.ref, 'refs/tags/v')) && matrix.config == 'Release'}}
shell: bash
run: |
mkdir -p ${{ env.RELEASE_FOLDER }}
cp ${{ env.OUTPUT_FOLDER }}/*.so ${{ env.RELEASE_FOLDER }}
- name: Upload release
if: ${{ (startsWith(github.ref, 'refs/tags/pre') || startsWith(github.ref, 'refs/tags/v')) && matrix.config == 'Release'}}
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: |
${{ env.RELEASE_FOLDER }}/*
prerelease: ${{ startsWith(github.ref, 'refs/tags/pre') }}
build-macos:
runs-on: macos-latest
needs: get-info
env:
OUTPUT_FOLDER: ./build
PROJECT_NAME: tetris_ai
RELEASE_FOLDER: ./release
strategy:
matrix:
config: [ Debug, Release ]
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Setup CMake
uses: lukka/get-cmake@latest
- name: CMake Configure and Build
run: |
cmake -S "${{ github.workspace }}" -B "${{ github.workspace }}/${{ env.OUTPUT_FOLDER }}" -DCMAKE_BUILD_TYPE=${{ matrix.config }}
cmake --build "${{ github.workspace }}/${{ env.OUTPUT_FOLDER }}" --target ${{ env.PROJECT_NAME }}
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ env.PROJECT_NAME }}_${{ needs.get-info.outputs.branchName }}_${{ needs.get-info.outputs.commitHash }}_${{ GITHUB.RUN_NUMBER }}_macOS_${{ matrix.config }}
path: "${{ env.OUTPUT_FOLDER }}/*.dylib"
- name: Prepare for release
if: ${{ (startsWith(github.ref, 'refs/tags/pre') || startsWith(github.ref, 'refs/tags/v')) && matrix.config == 'Release'}}
shell: bash
run: |
mkdir -p ${{ env.RELEASE_FOLDER }}
cp ${{ env.OUTPUT_FOLDER }}/*.dylib ${{ env.RELEASE_FOLDER }}
- name: Upload release
if: ${{ (startsWith(github.ref, 'refs/tags/pre') || startsWith(github.ref, 'refs/tags/v')) && matrix.config == 'Release'}}
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: |
${{ env.RELEASE_FOLDER }}/*
prerelease: ${{ startsWith(github.ref, 'refs/tags/pre') }}
build-windows:
runs-on: windows-latest
needs: get-info
env:
OUTPUT_FOLDER: ./build
PROJECT_NAME: tetris_ai
RELEASE_FOLDER: ./release
strategy:
matrix:
config: [ Debug, Release ]
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Setup CMake
uses: lukka/get-cmake@latest
- name: CMake Configure and Build
run: |
cmake -S "${{ github.workspace }}" -B "${{ github.workspace }}/${{ env.OUTPUT_FOLDER }}"
cmake --build "${{ github.workspace }}/${{ env.OUTPUT_FOLDER }}" --config ${{ matrix.config }} --target ${{ env.PROJECT_NAME }}
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ env.PROJECT_NAME }}_${{ needs.get-info.outputs.branchName }}_${{ needs.get-info.outputs.commitHash }}_${{ GITHUB.RUN_NUMBER }}_Windows_${{ matrix.config }}
path: "${{ env.OUTPUT_FOLDER }}/${{ matrix.config }}/*.dll"
- name: Prepare for release
if: ${{ (startsWith(github.ref, 'refs/tags/pre') || startsWith(github.ref, 'refs/tags/v')) && matrix.config == 'Release'}}
shell: bash
run: |
mkdir -p ${{ env.RELEASE_FOLDER }}
cp ${{ env.OUTPUT_FOLDER }}/${{ matrix.config }}/*.dll ${{ env.RELEASE_FOLDER }}
- name: Upload release
if: ${{ (startsWith(github.ref, 'refs/tags/pre') || startsWith(github.ref, 'refs/tags/v')) && matrix.config == 'Release'}}
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: |
${{ env.RELEASE_FOLDER }}/*
prerelease: ${{ startsWith(github.ref, 'refs/tags/pre') }}