-
Notifications
You must be signed in to change notification settings - Fork 0
133 lines (114 loc) · 4.26 KB
/
Copy pathbuild_binary.yml
File metadata and controls
133 lines (114 loc) · 4.26 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
name: 'Build Binary'
description: |
This workflow builds the binary files for Linux. The build binaries are stored as artifact
and may be reused by other workflows.
on:
push:
branches: [ 'main' ]
tags: [ '*' ]
pull_request:
branches: [ '*' ]
jobs:
build-binary:
name: 'Build binary'
runs-on: ubuntu-latest
env:
ASTREIN_VERSION: '1.1.0'
ASTREIN_SHA256: 'd5964319ea5a3742e4d7223ee5963d6aa3b24c8f67ef75c61d591c635f413497'
permissions:
contents: write
steps:
- name: 'Checkout repository'
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 'Setup GCC'
uses: egor-tensin/setup-gcc@v2
with:
version: '16'
platform: 'x64'
- name: 'Download ASTrein'
run: |
curl --fail --location \
--output "${RUNNER_TEMP}/astrein-linux-x86_64.tar.gz" \
"https://github.com/Katze719/ASTrein/releases/download/v${ASTREIN_VERSION}/astrein-linux-x86_64.tar.gz"
echo "${ASTREIN_SHA256} ${RUNNER_TEMP}/astrein-linux-x86_64.tar.gz" \
| sha256sum --check -
mkdir -p "${RUNNER_TEMP}/astrein"
tar -xzf "${RUNNER_TEMP}/astrein-linux-x86_64.tar.gz" \
-C "${RUNNER_TEMP}/astrein" \
--strip-components=1
"${RUNNER_TEMP}/astrein/bin/astrein" --version
- name: 'Setup CMake'
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: '3.31.x'
- name: 'Configure CMake'
run: |
cmake --preset linux-gcc-release \
-DCMAKE_C_COMPILER=gcc-16 \
-DCMAKE_CXX_COMPILER=g++-16 \
-DCPP_BINDINGS_LINUX_ENABLE_FFI_JSON_EXPORT=ON \
-DCPP_BINDINGS_LINUX_ASTREIN_EXECUTABLE="${RUNNER_TEMP}/astrein/bin/astrein"
- name: 'Build'
run: |
cmake --build --preset linux-gcc-release \
--target cpp_bindings_linux cpp_bindings_linux_ffi_json
- name: 'Set PACKAGE_VERSION from env.sh'
id: version
run: |
. build/env.sh
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_OUTPUT
- name: 'Check tag'
id: 'check-tag'
env:
PACKAGE_VERSION: ${{ steps.version.outputs.PACKAGE_VERSION }}
run: |
if [[ "$PACKAGE_VERSION" =~ ^(0|[1-9][[:digit:]]*)\.(0|[1-9][[:digit:]]*)\.(0|[1-9][[:digit:]]*)(-(alpha|rc|beta|experimental)\.[1-9][[:digit:]]*)?$ ]]; then
echo "Version \"$PACKAGE_VERSION\" is a valid package version."
echo "IS_VALID_PACKAGE_VERSION=true" >> $GITHUB_OUTPUT
else
echo "Version \"$PACKAGE_VERSION\" is not a valid package version."
echo "IS_VALID_PACKAGE_VERSION=false" >> $GITHUB_OUTPUT
fi
- name: 'Upload artifacts'
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: libcpp_bindings_linux
path: |
build/libcpp_bindings_linux.so
build/cpp_bindings_linux.ffi.json
- name: 'Create GitHub Release'
if: github.ref_type == 'tag' && steps.check-tag.outputs.IS_VALID_PACKAGE_VERSION == 'true'
uses: softprops/action-gh-release@v2
with:
name: 'v${{ steps.version.outputs.PACKAGE_VERSION }}'
tag_name: ${{ github.ref_name }}
generate_release_notes: true
files: |
build/libcpp_bindings_windows.so
build/cpp_bindings_linux.ffi.json
outputs:
package_version: ${{ steps.version.outputs.PACKAGE_VERSION }}
is_valid_package_version: ${{ steps.check-tag.outputs.IS_VALID_PACKAGE_VERSION }}
test-unit-cpp:
name: 'Run: Test Unit C++'
needs: ['build-binary']
uses: './.github/workflows/test_unit_cpp.yml'
with:
artifact-name: libcpp_bindings_linux
permissions:
contents: read
checks: write
publish-jsr:
name: 'Run: Publish JSR'
needs: ['build-binary', 'test-unit-cpp']
uses: './.github/workflows/publish_jsr.yml'
with:
publish: ${{ needs.build-binary.outputs.is_valid_package_version == 'true' }}
version: ${{ needs.build-binary.outputs.package_version }}
artifact-name: libcpp_bindings_linux
permissions:
contents: read
id-token: write