-
Notifications
You must be signed in to change notification settings - Fork 3
162 lines (139 loc) · 5.26 KB
/
build.yaml
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
name: Build & Push binaries
permissions:
contents: write
on:
pull_request:
push:
paths-ignore:
- '.gitignore'
- 'LICENSE'
- 'README.md'
jobs:
build:
strategy:
fail-fast: false
matrix:
platform:
- { runner: windows-latest, os: windows, arch: x64, archive_ext: .zip }
- { runner: ubuntu-latest, os: linux, arch: x86_64, archive_ext: .tar.gz }
- { runner: macos-12, os: macos, arch: x86_64, archive_ext: .tar.gz }
- { runner: macos-14, os: macos, arch: arm64, archive_ext: .tar.gz }
mode: [debug, releasedbg]
runs-on: ${{ matrix.platform.runner }}
steps:
- name: Get current date as package key
id: cache_key
run: echo "key=$(date +'%W')" >> $GITHUB_OUTPUT
shell: bash
- name: "Set OUTPUT_FILE variable"
run: echo "OUTPUT_FILE=${{ matrix.platform.os }}_${{ matrix.platform.arch }}_${{ matrix.mode }}${{ matrix.platform.archive_ext }}" >> $GITHUB_ENV
shell: bash
# Force xmake to a specific folder (for cache)
- name: Set xmake env
run: echo "XMAKE_GLOBALDIR=${{ runner.workspace }}/xmake-global" >> $GITHUB_ENV
shell: bash
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Clone the whole repository to get correct tags and branches
# Install xmake
- name: Setup xmake
uses: xmake-io/github-action-setup-xmake@v1
with:
xmake-version: branch@dev
actions-cache-folder: .xmake-cache-W${{ steps.cache_key.outputs.key }}
# Update xmake repository (in order to have the file that will be cached)
- name: Update xmake repository
run: xmake repo --update
# Fetch xmake dephash
- name: Retrieve dependencies hash
id: dep_hash
run: echo "hash=$(xmake l utils.ci.packageskey)" >> $GITHUB_OUTPUT
shell: bash
# Retrieve xmake dependencies
- name: Restore cached xmake dependencies
id: restore-depcache
uses: actions/cache/restore@v4
with:
path: ${{ env.XMAKE_GLOBALDIR }}/.xmake/packages
key: ${{ matrix.platform.os }}-${{ matrix.platform.arch }}-${{ matrix.mode }}-${{ steps.dep_hash.outputs.hash }}-W${{ steps.cache_key.outputs.key }}
- name: Configure xmake and install dependencies
run: xmake config --arch=${{ matrix.platform.arch }} --mode=${{ matrix.mode }} --yes --policies=package.precompiled:n
# Save dependencies
- name: Save cached xmake dependencies
if: ${{ !steps.restore-depcache.outputs.cache-hit }}
uses: actions/cache/save@v4
with:
path: ${{ env.XMAKE_GLOBALDIR }}/.xmake/packages
key: ${{ steps.restore-depcache.outputs.cache-primary-key }}
- name: Build
run: xmake
- name: Install
run: |
xmake install -vo dest/
if [ "$RUNNER_OS" == "Linux" ]; then
mv ./dest/lib/*.so* ./dest/bin/
elif [ "$RUNNER_OS" == "macOS" ]; then
mv ./dest/lib/*.dylib* ./dest/bin/
fi
rm -rf dest/include/
rm -rf dest/lib/
shell: bash
# For some reason macOS-14 doesn't seem to have Python
- uses: actions/setup-python@v5
if: ${{ matrix.platform.runner == 'macos-14' }}
with:
python-version: "3.11"
- name: Archive result
uses: ihiroky/archive-action@v1
with:
root_dir: dest/bin
file_path: ${{ env.OUTPUT_FILE }}
verbose: true
- name: Compute checksum of archive
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
sha256sum -b "$OUTPUT_FILE" > "$OUTPUT_FILE.sha256"
else
shasum -a 256 -b "$OUTPUT_FILE" > "$OUTPUT_FILE.sha256"
fi
shell: bash
# Nightly tags (for commits to dev branch)
- name: Upload binaries to release (Dev)
uses: svenstaro/upload-release-action@v2
if: ${{ (github.ref == 'refs/heads/dev') && github.event_name == 'push' }}
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ env.OUTPUT_FILE }}
asset_name: ${{ env.OUTPUT_FILE }}
tag: "0.0.0-nightly"
overwrite: true
- name: Upload checksum to release (Dev)
uses: svenstaro/upload-release-action@v2
if: ${{ (github.ref == 'refs/heads/dev') && github.event_name == 'push' }}
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ env.OUTPUT_FILE }}.sha256
asset_name: ${{ env.OUTPUT_FILE }}.sha256
tag: "0.0.0-nightly"
overwrite: true
body: "Dev branch"
# Release tags (for tags)
- name: Upload binaries to release (Tag)
uses: svenstaro/upload-release-action@v2
if: ${{ startsWith(github.event.ref, 'refs/tags/') && matrix.mode == 'releasedbg' }}
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ env.OUTPUT_FILE }}
asset_name: ${{ env.OUTPUT_FILE }}
tag: ${{ github.ref }}
overwrite: true
- name: Upload checksum to release (Tag)
uses: svenstaro/upload-release-action@v2
if: ${{ startsWith(github.event.ref, 'refs/tags/') && matrix.mode == 'releasedbg' }}
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ env.OUTPUT_FILE }}.sha256
asset_name: ${{ env.OUTPUT_FILE }}.sha256
tag: ${{ github.ref }}
overwrite: true