-
Notifications
You must be signed in to change notification settings - Fork 2
135 lines (113 loc) · 5 KB
/
build.yaml
File metadata and controls
135 lines (113 loc) · 5 KB
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
name: Builds
on:
push:
branches:
- master
pull_request:
branches:
- master
workflow_dispatch:
permissions:
contents: read
jobs:
build:
name: Build (${{ matrix.target }})
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact_name: spiritus
sdl2_install: sudo apt-get install -y libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev libsdl2-gfx-dev
- os: macos-15
target: aarch64-apple-darwin
artifact_name: spiritus
sdl2_install: brew install sdl2 sdl2_image sdl2_mixer sdl2_ttf sdl2_gfx
- os: windows-latest
target: x86_64-pc-windows-gnu
artifact_name: spiritus.exe
sdl2_install: ""
runs-on: ${{ matrix.os }}
env:
SDL2: 2.30.2
SDL2_TTF: 2.22.0
SDL2_MIXER: 2.8.0
SDL2_IMAGE: 2.8.2
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Update apt package index
if: runner.os == 'Linux'
run: sudo apt-get update
- name: Install SDL2 packages (apt/brew)
if: matrix.sdl2_install != ''
run: ${{ matrix.sdl2_install }}
- name: Set Homebrew library paths
if: runner.os == 'macOS'
run: |
echo "LIBRARY_PATH=$(brew --prefix)/lib" >> $GITHUB_ENV
echo "CPATH=$(brew --prefix)/include" >> $GITHUB_ENV
- name: Download SDL2 libraries (Windows)
if: runner.os == 'Windows'
run: |
curl -L "https://github.com/libsdl-org/SDL/releases/download/release-${{ env.SDL2 }}/SDL2-devel-${{ env.SDL2 }}-VC.zip" -o "sdl2_devel.zip"
curl -L "https://github.com/libsdl-org/SDL_mixer/releases/download/release-${{ env.SDL2_MIXER }}/SDL2_mixer-devel-${{ env.SDL2_MIXER }}-VC.zip" -o "sdl2_mixer_devel.zip"
curl -L "https://github.com/libsdl-org/SDL_ttf/releases/download/release-${{ env.SDL2_TTF }}/SDL2_ttf-devel-${{ env.SDL2_TTF }}-VC.zip" -o "sdl2_ttf_devel.zip"
curl -L "https://github.com/libsdl-org/SDL_image/releases/download/release-${{ env.SDL2_IMAGE }}/SDL2_image-devel-${{ env.SDL2_IMAGE }}-VC.zip" -o "sdl2_image_devel.zip"
- name: Extract SDL2 DLLs (Windows)
if: runner.os == 'Windows'
run: |
7z x ./sdl2_devel.zip -o"./tmp/"
mv ./tmp/SDL2-${{ env.SDL2 }}/lib/x64/SDL2.dll ./
mv ./tmp/SDL2-${{ env.SDL2 }}/lib/x64/SDL2.lib ./
7z x ./sdl2_mixer_devel.zip -o"./tmp/"
mv ./tmp/SDL2_mixer-${{ env.SDL2_MIXER }}/lib/x64/SDL2_mixer.dll ./
mv ./tmp/SDL2_mixer-${{ env.SDL2_MIXER }}/lib/x64/SDL2_mixer.lib ./
7z x ./sdl2_ttf_devel.zip -o"./tmp/"
mv ./tmp/SDL2_ttf-${{ env.SDL2_TTF }}/lib/x64/SDL2_ttf.dll ./
mv ./tmp/SDL2_ttf-${{ env.SDL2_TTF }}/lib/x64/SDL2_ttf.lib ./
7z x ./sdl2_image_devel.zip -o"./tmp/"
mv ./tmp/SDL2_image-${{ env.SDL2_IMAGE }}/lib/x64/SDL2_image.dll ./
mv ./tmp/SDL2_image-${{ env.SDL2_IMAGE }}/lib/x64/SDL2_image.lib ./
- name: Install SDL2_gfx (Windows)
if: runner.os == 'Windows'
run: |
C:\vcpkg\vcpkg.exe install sdl2-gfx:x64-windows-release
cp C:\vcpkg\packages\sdl2-gfx_x64-windows-release\bin\SDL2_gfx.dll ./
cp C:\vcpkg\packages\sdl2-gfx_x64-windows-release\lib\SDL2_gfx.lib ./
- name: Install Rust toolchain
uses: mkroening/rust-toolchain-toml@main
- name: Add target
run: rustup target add ${{ matrix.target }}
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Build
run: cargo build --release
- name: Acquire Package Version
id: get_version
shell: bash
run: |
set -euo pipefail
echo "version=$(cargo metadata --format-version 1 --no-deps | jq '.packages[0].version' -r)" >> $GITHUB_OUTPUT
- name: Assemble archive (Unix)
if: runner.os != 'Windows'
run: |
mkdir -p /tmp/spiritus/assets
cp ./target/release/${{ matrix.artifact_name }} /tmp/spiritus/
chmod a+x /tmp/spiritus/${{ matrix.artifact_name }}
cp ./assets/TerminalVector.ttf ./assets/fruit.png /tmp/spiritus/assets
- name: Assemble archive (Windows)
if: runner.os == 'Windows'
run: |
New-Item -Type Directory ./release/assets/
Move-Item -Path ./target/release/${{ matrix.artifact_name }} -Destination ./release/
Move-Item -Path ./SDL2.dll, ./SDL2_image.dll, ./SDL2_ttf.dll, ./SDL2_mixer.dll, ./SDL2_gfx.dll -Destination ./release/
Move-Item -Path ./assets/TerminalVector.ttf, ./assets/fruit.png -Destination ./release/assets/
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: "spiritus-${{ steps.get_version.outputs.version }}-${{ matrix.target }}"
path: ${{ runner.os == 'Windows' && './release/' || '/tmp/spiritus/' }}
retention-days: 7
if-no-files-found: error