forked from widberg/bgfx.cmake
-
Notifications
You must be signed in to change notification settings - Fork 112
178 lines (167 loc) · 6.79 KB
/
release.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
# https://github.com/openblack/bgfx.cmake/blob/master/.github/workflows/release.yml
name: Release
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
version:
name: version
runs-on: ubuntu-latest
outputs:
revision: ${{ steps.version.outputs.revision }}
sha: ${{ steps.version.outputs.sha }}
tag: ${{ steps.version.outputs.tag }}
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- id: version
run: |
API_VERSION=$(grep -Eo "BGFX_API_VERSION UINT32_C\([0-9]+\)" bgfx/include/bgfx/defines.h | grep -Eo "[0-9]+" | tail -1)
BGFX_REVISION=$(cd bgfx && git rev-list HEAD --count)
BGFX_CMAKE_REVISION=$(git rev-list HEAD --count)
SHA=$(cd bgfx && git rev-parse HEAD)
TAG="v1.${API_VERSION}.${BGFX_REVISION}-${BGFX_CMAKE_REVISION}"
echo "revision=${BGFX_REVISION}" >> $GITHUB_OUTPUT
echo "sha=${SHA}" >> $GITHUB_OUTPUT
echo "tag=${TAG}" >> $GITHUB_OUTPUT
build:
name: ${{ matrix.os }}
needs: [ version ]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
- os: ubuntu-latest
- os: macos-latest
env:
# Indicates the CMake build directory where project files and binaries are being produced.
CMAKE_BUILD_DIR: ${{ github.workspace }}/build/
CMAKE_INSTALL_DIR: ${{ github.workspace }}/install/
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Install Linux dependencies
run: |
sudo apt-get update
sudo apt install -y libgl1-mesa-dev
if: matrix.os == 'ubuntu-latest'
# Setup the build machine with the most recent versions of CMake and Ninja. Both are cached if not already: on subsequent runs both will be quickly restored from GitHub cache service.
- uses: lukka/get-cmake@latest
# On Windows runners, let's ensure to have the Developer Command Prompt environment setup correctly. As used here the Developer Command Prompt created is targeting x64 and using the default the Windows SDK.
- uses: ilammy/msvc-dev-cmd@v1
# Update version
- name: Update version.h
run: |
sed "s/ BGFX_REV_NUMBER .*/ BGFX_REV_NUMBER ${{ needs.version.outputs.revision }}/g" bgfx/src/version.h > version.tmp && mv version.tmp bgfx/src/version.h
sed "s/ BGFX_REV_SHA1 .*/ BGFX_REV_SHA1 \"${{ needs.version.outputs.sha }}\"/g" bgfx/src/version.h > version.tmp && mv version.tmp bgfx/src/version.h
shell: bash
# Run CMake to generate project files
- name: Generate project files
run: |
cmake -B "${{ env.CMAKE_BUILD_DIR }}" "-DCMAKE_INSTALL_PREFIX=${{ env.CMAKE_INSTALL_DIR }}" -DCMAKE_DEBUG_POSTFIX=d -DBGFX_BUILD_EXAMPLES=OFF -DBGFX_BUILD_TOOLS=ON -DBGFX_INSTALL=ON -DBGFX_AMALGAMATED=ON -DCMAKE_BUILD_TYPE=Release
# Build the install targets
- name: Build
run: |
cmake --build "${{ env.CMAKE_BUILD_DIR }}" --target install --config Release
- uses: actions/upload-artifact@v3
with:
name: ${{ matrix.os }}
path: ${{ github.workspace }}/install/
release:
name: release
runs-on: ubuntu-latest
needs: [ version, build ]
if: github.repository == 'bkaradzic/bgfx.cmake' && github.event_name == 'push'
permissions:
contents: write
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
path: src/bgfx.cmake
- run: |
find src/bgfx.cmake -name ".git*" -exec rm -rf {} +
find src/bgfx.cmake -name ".editorconfig" -delete
rm src/bgfx.cmake/.cmake-format.py
- uses: actions/download-artifact@v3
with:
name: windows-latest
path: ${{ github.workspace }}/install/windows/bgfx.cmake
- uses: actions/download-artifact@v3
with:
name: ubuntu-latest
path: ${{ github.workspace }}/install/linux/bgfx.cmake
- uses: actions/download-artifact@v3
with:
name: macos-latest
path: ${{ github.workspace }}/install/macos/bgfx.cmake
- name: Create Source Zip
uses: thedoctor0/[email protected]
with:
type: 'zip'
filename: 'bgfx.cmake.${{ needs.version.outputs.tag }}.zip'
directory: 'src'
path: 'bgfx.cmake'
- name: Create Source Tar
uses: thedoctor0/[email protected]
with:
type: 'tar'
filename: 'bgfx.cmake.${{ needs.version.outputs.tag }}.tar.gz'
directory: 'src'
path: 'bgfx.cmake'
- name: Create Windows Zip
uses: thedoctor0/[email protected]
with:
type: 'zip'
filename: 'bgfx.cmake.binary.windows.${{ needs.version.outputs.tag }}.zip'
directory: 'install/windows'
path: 'bgfx.cmake'
- name: Create Windows Tar
uses: thedoctor0/[email protected]
with:
type: 'tar'
filename: 'bgfx.cmake.binary.windows.${{ needs.version.outputs.tag }}.tar.gz'
directory: 'install/windows'
path: 'bgfx.cmake'
- name: Create Linux Zip
uses: thedoctor0/[email protected]
with:
type: 'zip'
filename: 'bgfx.cmake.binary.linux.${{ needs.version.outputs.tag }}.zip'
directory: 'install/linux'
path: 'bgfx.cmake'
- name: Create Linux Tar
uses: thedoctor0/[email protected]
with:
type: 'tar'
filename: 'bgfx.cmake.binary.linux.${{ needs.version.outputs.tag }}.tar.gz'
directory: 'install/linux'
path: 'bgfx.cmake'
- name: Create MacOS Zip
uses: thedoctor0/[email protected]
with:
type: 'zip'
filename: 'bgfx.cmake.binary.macos.${{ needs.version.outputs.tag }}.zip'
directory: 'install/macos'
path: 'bgfx.cmake'
- name: Create MacOS Tar
uses: thedoctor0/[email protected]
with:
type: 'tar'
filename: 'bgfx.cmake.binary.macos.${{ needs.version.outputs.tag }}.tar.gz'
directory: 'install/macos'
path: 'bgfx.cmake'
- name: Create Release
uses: ncipollo/release-action@v1
with:
tag: ${{ needs.version.outputs.tag }}
artifacts: "src/bgfx.cmake.${{ needs.version.outputs.tag }}.zip,src/bgfx.cmake.${{ needs.version.outputs.tag }}.tar.gz,install/*/*.${{ needs.version.outputs.tag }}.zip,install/*/*.${{ needs.version.outputs.tag }}.tar.gz"
generateReleaseNotes: true