-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (71 loc) · 2.86 KB
/
cd.yaml
File metadata and controls
76 lines (71 loc) · 2.86 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
name: Release
on:
push:
branches: ["master"]
tags:
- v*
permissions:
contents: write
jobs:
build:
name: Build and Test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install dependencies
run: python -m pip install meson ninja pytest
- name: Configure Project
run: meson setup --wrap-mode=forcefallback -Denable-tests=true -Dbuildtype=release builddir/
env:
CC: g++
- name: Build Project
run: meson compile -C builddir/
- name: Run Tests
run: meson test -C builddir/ -v
- name: Package Executables (Unix)
if: runner.os != 'Windows'
run: |
mkdir -p release-${{ matrix.os }}
cp builddir/src/bin/cpplox builddir/src/bin/loxcrc builddir/src/bin/loxdump builddir/src/bin/loxvm release-${{ matrix.os }}/
cd release-${{ matrix.os }} && zip -r ../cpp-lox-${{ matrix.os }}.zip * && cd ..
- name: Package Executables (Windows)
if: runner.os == 'Windows'
run: |
mkdir release-${{ matrix.os }}
Copy-Item builddir\src\bin\cpplox.exe release-${{ matrix.os }}\
Copy-Item builddir\src\bin\loxcrc.exe release-${{ matrix.os }}\
Copy-Item builddir\src\bin\loxdump.exe release-${{ matrix.os }}\
Copy-Item builddir\src\bin\loxvm.exe release-${{ matrix.os }}\
Compress-Archive -Path release-${{ matrix.os }}\* -DestinationPath cpp-lox-${{ matrix.os }}.zip
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: cpp-lox-${{ matrix.os }}
path: cpp-lox-${{ matrix.os }}.zip
release:
name: Create Release
runs-on: ubuntu-24.04
needs: build
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Download Artifacts
uses: actions/download-artifact@v4
- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref_name }}
run: |
gh release create "$tag" \
--repo="$GITHUB_REPOSITORY" \
--title="${GITHUB_REPOSITORY#*/} ${tag#v}" \
--generate-notes \
cpp-lox-*/*.zip
# https://stackoverflow.com/questions/75679683