-
Notifications
You must be signed in to change notification settings - Fork 0
277 lines (263 loc) · 10.5 KB
/
mame-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
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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
# Requires repo secret: PERSONAL_ACCESS_TOKEN with permissions:
# Contents: read and write
# Pull Requests: read and write
name: MAME Build
on:
workflow_dispatch:
inputs:
mame_ref:
description: 'MAME GitHub branch, tag, or SHA (e.g. "mame0262")'
required: true
type: string
auto-merge:
description: 'Auto-merge pull request?'
required: true
type: boolean
default: true
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
env:
MAME_REF: ${{ inputs.mame_ref || 'mame0262' }}
# `make` options
EMULATOR: 0
TOOLS: 1
TESTS: 0
IGNORE_GIT: 1
NOWERROR: 1
DEBUG: 0
SYMBOLS:
OPTIMIZE: s
jobs:
build-linux:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- apt_architecture: amd64
nodejs_arch: x64
- apt_architecture: i386
cc: i686-linux-gnu-gcc-11
cxx: i686-linux-gnu-g++-11
strip: i686-gnu-strip
nodejs_arch: ia32
- apt_architecture: armhf
cc: arm-linux-gnueabihf-gcc-11
cxx: arm-linux-gnueabihf-g++-11
archopts: -mfpu=neon
strip: arm-linux-gnueabihf-strip
nodejs_arch: arm
- apt_architecture: arm64
cc: aarch64-linux-gnu-gcc-11
cxx: aarch64-linux-gnu-g++-11
strip: aarch64-linux-gnu-strip
nodejs_arch: arm64
steps:
- uses: actions/checkout@v4
with:
repository: mamedev/mame
ref: ${{ env.MAME_REF }}
- name: Install dependencies
run: |
# https://docs.mamedev.org/initialsetup/compilingmame.html#debian-and-ubuntu-including-raspberry-pi-and-odroid-devices
sudo apt-get update
sudo apt-get install -y git build-essential python3 libsdl2-dev libsdl2-ttf-dev libfontconfig-dev libpulse-dev qtbase5-dev qtbase5-dev-tools qtchooser qt5-qmake \
sudo apt-get install -y software-properties-common
sudo dpkg --add-architecture i386
sudo add-apt-repository --yes --no-update "deb [arch=amd64,i386] http://archive.ubuntu.com/ubuntu/ $(lsb_release --codename | awk '{print $2}') main multiverse restricted universe"
sudo add-apt-repository --yes --no-update "deb [arch=amd64,i386] http://archive.ubuntu.com/ubuntu/ $(lsb_release --codename | awk '{print $2}')-updates main multiverse restricted universe"
sudo dpkg --add-architecture armhf
sudo dpkg --add-architecture arm64
sudo add-apt-repository --yes --no-update "deb [arch=armhf,arm64,ppc64el,riscv64,s390x] http://ports.ubuntu.com/ubuntu-ports/ $(lsb_release --codename | awk '{print $2}') main multiverse restricted universe"
sudo add-apt-repository --yes --no-update "deb [arch=armhf,arm64,ppc64el,riscv64,s390x] http://ports.ubuntu.com/ubuntu-ports/ $(lsb_release --codename | awk '{print $2}')-updates main multiverse restricted universe"
sudo apt-get update || true
sudo apt-get install -y crossbuild-essential-${{ matrix.apt_architecture }} libsdl2-dev:${{ matrix.apt_architecture }}
- name: Build
env:
OVERRIDE_CC: ${{ matrix.cc || 'gcc' }}
OVERRIDE_CXX: ${{ matrix.cxx || 'g++' }}
ARCHOPTS: -U_FORTIFY_SOURCE ${{ matrix.archopts }}
TARGETOS: linux
run: |
make "-j$(nproc)" -r
file chdman
- name: Strip binary
run: |
sudo apt-get install -y binutils binutils-i686-gnu binutils-arm-linux-gnueabihf binutils-aarch64-linux-gnu
ls -al chdman
${{ matrix.strip || 'strip' }} chdman
ls -al chdman
- name: Rename binary
run: |
dir="artifacts/bin/linux/${{ matrix.nodejs_arch }}"
mkdir -p "${dir}"
mv chdman "${dir}/"
- uses: actions/upload-artifact@v4
with:
name: ${{ runner.os }}-${{ matrix.apt_architecture }}-${{ github.sha }}
path: artifacts/**/chdman
if-no-files-found: error
# https://github.com/mamedev/mame/blob/4505d5459fed086d35f08d7572cb55cd661cd707/.github/workflows/ci-macos.yml
build-macos:
strategy:
matrix:
os: [macos-13, macos-14]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
repository: mamedev/mame
ref: ${{ env.MAME_REF }}
- name: Install dependencies
run: brew install --overwrite python3 sdl2
- name: Build
env:
USE_LIBSDL: 1
run: |
make "-j$(sysctl -n hw.physicalcpu)" -r
file chdman
- name: Strip binary
run: |
ls -al chdman
strip chdman
ls -al chdman
- uses: actions/setup-node@v4
- name: Rename binary
run: |
# shellcheck disable=SC2016
dir="artifacts/bin/$(node --eval 'console.log(`${process.platform}/${process.arch}`)')"
mkdir -p "${dir}"
mv chdman "${dir}/"
- uses: actions/upload-artifact@v4
with:
name: ${{ runner.os }}-${{ matrix.os }}-${{ github.sha }}
path: artifacts/**/chdman
if-no-files-found: error
# https://github.com/mamedev/mame/blob/4505d5459fed086d35f08d7572cb55cd661cd707/.github/workflows/ci-windows.yml
build-windows:
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}
strategy:
matrix:
msystem: [mingw64, mingw32]
include:
- msystem: mingw64
nodejs_arch: x64
- msystem: mingw32
nodejs_arch: ia32
# - msystem: clangarm64
# nodejs_arch: arm64
steps:
- uses: actions/checkout@v4
with:
repository: mamedev/mame
ref: ${{ env.MAME_REF }}
- uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.msystem }}
install: curl git make
pacboy: clang:p gcc:p libc++:p lld:p python:p llvm:p
- run: |
# https://docs.mamedev.org/initialsetup/compilingmame.html#using-a-standard-msys2-installation
if [[ "${{ matrix.msystem }}" == "mingw64" ]]; then
echo "MINGW64=/mingw64" >> "${GITHUB_ENV}"
echo "MINGW32=" >> "${GITHUB_ENV}"
elif [[ "${{ matrix.msystem }}" == "mingw32" ]]; then
echo "MINGW64=" >> "${GITHUB_ENV}"
echo "MINGW32=/mingw32" >> "${GITHUB_ENV}"
else
echo "MINGW64=" >> "${GITHUB_ENV}"
echo "MINGW32=" >> "${GITHUB_ENV}"
fi
- name: Build
env:
OVERRIDE_AR: "llvm-ar"
OVERRIDE_CC: clang
OVERRIDE_CXX: clang++
ARCHOPTS: "-fuse-ld=lld"
run: make -j$(nproc) -r
- name: Strip binary
run: |
ls -al chdman.exe
strip chdman.exe
ls -al chdman.exe
- name: Rename binary
run: |
dir="artifacts/bin/win32/${{ matrix.nodejs_arch }}"
mkdir -p "${dir}"
mv chdman.exe "${dir}/"
- uses: actions/upload-artifact@v4
with:
name: ${{ runner.os }}-${{ matrix.msystem }}-${{ github.sha }}
path: artifacts/**/chdman.exe
if-no-files-found: error
git-update:
needs:
- build-linux
- build-macos
- build-windows
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
merge-multiple: true
- uses: actions/setup-node@v4
- id: bump-and-commit
run: |
package_name=$(jq --raw-output '.name' package.json)
major_version=$(npm show "${package_name}" --json | jq --raw-output '.versions | .[]' | sed 's/\.[0-9]*//g' | sort | tail -1)
# shellcheck disable=SC2001
minor_version=$(echo "${MAME_REF}" | sed 's/[^0-9]*//g' | sed 's/^0*//')
previous_version=$(npm show "${package_name}" --json | jq --raw-output '.versions | .[]' | grep "${minor_version}" | tail -1)
if [[ "${previous_version}" != "" ]]; then
# shellcheck disable=SC2001
new_patch_version=$(echo "$(echo "${previous_version}" | sed 's/[0-9]*\.//g') + 1" | bc)
new_version="${major_version}.${minor_version}.${new_patch_version}"
else
new_version="${major_version}.${minor_version}.0"
fi
npm version "${new_version}" --no-git-tag-version || true
chmod +x bin/**/*
ls -alR
git add package*.json bin
USER_EMAIL="${GITHUB_ACTOR_ID}+${GITHUB_ACTOR}@users.noreply.github.com"
echo "USER_EMAIL=${USER_EMAIL}" >> "${GITHUB_OUTPUT}"
git config --global user.email "${USER_EMAIL}"
USER_NAME="$(gh api "/users/${GITHUB_ACTOR}" | jq .name -r)"
echo "USER_NAME=${USER_NAME}" >> "${GITHUB_OUTPUT}"
git config --global user.name "${USER_NAME}"
PACKAGE_VERSION="$(jq --raw-output '.version' package.json)"
echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >> "${GITHUB_OUTPUT}"
git commit -m "v${PACKAGE_VERSION}"
env:
GH_TOKEN: ${{ github.token }}
# Create the pull request, and optionally mark it as auto-merge
- id: create-pull-request
uses: peter-evans/create-pull-request@v6
with:
# GitHub won't run workflows off of events from the `github-actions` user
# But also, I want the PR to be created under my name for cosmetic reasons
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
author: ${{ steps.bump-and-commit.outputs.USER_NAME }} <${{ steps.bump-and-commit.outputs.USER_EMAIL }}>
branch: ${{ github.actor }}/${{ steps.bump-and-commit.outputs.PACKAGE_VERSION }}
delete-branch: true
title: v${{ steps.bump-and-commit.outputs.PACKAGE_VERSION }}
assignees: ${{ !inputs.auto-merge && github.repository_owner || '' }}
reviewers: ${{ (!inputs.auto-merge && github.repository_owner != github.actor) && github.repository_owner || '' }}
- if: ${{ steps.create-pull-request.outputs.pull-request-number }}
run: |
{
echo "# v${{ steps.bump-and-commit.outputs.PACKAGE_VERSION }}"
echo ""
echo "${{ steps.create-pull-request.outputs.pull-request-url }}"
} >> "${GITHUB_STEP_SUMMARY}"
- if: ${{ steps.create-pull-request.outputs.pull-request-number && inputs.auto-merge }}
run: gh pr merge "${{ steps.create-pull-request.outputs.pull-request-number }}" --squash --auto
env:
GH_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}