Skip to content

Commit d8ce64c

Browse files
Update GitHub Actions workflows, update GoogleTest dependency
Updated workflows from upstream main to include macOS, Linux, and ARM variants to build against. Added concurrency for the workflows and also split some workflows out for smaller individual artifact sizes. Updated actions to latest available. Changed build action to run on every commit pushed rather than only PR's and pushes to main. Updated GoogleTest dependency to resolve issue with the WPILib Artifactory, this was causing issues with builds on macOS where osxuniversal platform type was not available, and split between osxarm64 and osxx86-64.
1 parent 77162c1 commit d8ce64c

File tree

3 files changed

+219
-75
lines changed

3 files changed

+219
-75
lines changed

.github/workflows/build.yml

Lines changed: 186 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,236 @@
11
name: Build
22

33
on:
4-
push:
5-
branches:
6-
- 'main'
7-
pull_request:
8-
branches:
9-
- '*'
4+
[push, pull_request]
5+
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
8+
cancel-in-progress: false
109

1110
defaults:
1211
run:
1312
shell: bash
1413

1514
jobs:
16-
build:
15+
# Use WPI provided Docker images to build for Linux ARM32 and ARM64 platforms
16+
build-docker:
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
include:
21+
- container: wpilib/aarch64-cross-ubuntu:bullseye-22.04
22+
name: LinuxARM64
23+
build-options: "-Ponlylinuxarm64"
24+
platform-type: linuxarm64
25+
arch: arm64
26+
- container: wpilib/raspbian-cross-ubuntu:bullseye-22.04
27+
name: LinuxARM32
28+
build-options: "-Ponlylinuxarm32"
29+
platform-type: linuxarm32
30+
arch: arm32
31+
runs-on: ubuntu-latest
32+
name: "Build - ${{ matrix.name }}"
33+
container: ${{ matrix.container }}
34+
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v4
37+
with:
38+
ref: ${{ github.sha }}
39+
40+
- name: Setup Java
41+
uses: actions/setup-java@v4
42+
with:
43+
distribution: 'zulu'
44+
java-version: 11
45+
46+
- name: Setup Gradle
47+
uses: gradle/actions/setup-gradle@v4
48+
49+
- name: Build
50+
run: |
51+
./gradlew outputVersions publish ${{ matrix.build-options }} -PreleaseMode
52+
53+
- name: Download WPILib HAL artifacts and headers for ${{ matrix.platform-type }}
54+
run : |
55+
halVersion=$(cat wpiHalVersion.txt)
56+
57+
halPlatformUrl=https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/hal/hal-cpp/"$halVersion"/hal-cpp-"$halVersion"-${{ matrix.platform-type }}.zip
58+
utilPlatformUrl=https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/wpiutil/wpiutil-cpp/"$halVersion"/wpiutil-cpp-"$halVersion"-${{ matrix.platform-type }}.zip
59+
60+
curl -o halPlatform.zip "$halPlatformUrl"
61+
curl -o utilPlatform.zip "$utilPlatformUrl"
62+
63+
- name: Unzip WPILib HAL artifacts and headers
64+
run: |
65+
unzip halPlatform.zip -d halPlatform
66+
unzip utilPlatform.zip -d utilPlatform
67+
mkdir -p CANBridge-artifacts
68+
69+
# Put Linux ARM release files together in one directory
70+
- name: Create Artifact
71+
run: |
72+
cp build/libs/cANBridge/static/release/libCANBridge.a CANBridge-artifacts/libCANBridge.a
73+
cp build/libs/cANBridge/shared/release/libCANBridge.so CANBridge-artifacts/libCANBridge.so
74+
cp halPlatform/linux/${{ matrix.arch }}/shared/libwpiHal.so CANBridge-artifacts/libwpiHal.so
75+
cp utilPlatform/linux/${{ matrix.arch }}/shared/libwpiutil.so CANBridge-artifacts/libwpiutil.so
76+
77+
# Upload build artifact
78+
- name: Upload build artifact
79+
uses: actions/upload-artifact@v4
80+
with:
81+
name: CANBridge-${{ matrix.platform-type }}-${{ github.sha}}
82+
path: CANBridge-artifacts/
83+
84+
# Use native runners to build for Windows, Linux, and macOS
85+
build-native:
1786
timeout-minutes: 15
1887
strategy:
1988
fail-fast: false
2089
matrix:
2190
include:
2291
- os: windows-latest
23-
container: ''
24-
name: windows64
25-
name: "build-${{ matrix.name }}"
92+
name: Win64
93+
build-options: ""
94+
platform-type: windowsx86-64
95+
- os: ubuntu-latest
96+
name: Linux64
97+
platform-type: linuxx86-64
98+
build-options: ""
99+
- os: macos-latest
100+
name: macOS
101+
platform-type: osxuniversal
102+
build-options: ""
103+
name: "Build - ${{ matrix.name }}"
26104
runs-on: ${{ matrix.os }}
27-
container: ${{ matrix.container }}
28105
steps:
29106
- name: Checkout
30-
uses: actions/checkout@v3
107+
uses: actions/checkout@v4
31108
with:
32109
ref: ${{ github.sha }}
33110

34111
- name: Setup Java
35-
uses: actions/setup-java@v3
112+
uses: actions/setup-java@v4
36113
with:
37114
distribution: 'zulu'
38115
java-version: 11
39116

117+
- name: Setup Gradle
118+
uses: gradle/actions/setup-gradle@v4
119+
40120
- name: Build
41121
run: |
42122
./gradlew outputVersions publish ${{ matrix.build-options }} -PreleaseMode
43123
44-
- name: Download WPILib HAL artifacts and headers, gather all needed headers
124+
- name: Download WPILib HAL artifacts and headers for ${{ matrix.platform-type }}
45125
run : |
46126
halVersion=$(cat wpiHalVersion.txt)
47-
48-
# Download WPILib artifacts from Artifactory
49-
halWindowsUrl=https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/hal/hal-cpp/"$halVersion"/hal-cpp-"$halVersion"-windowsx86-64.zip
127+
128+
halPlatformUrl=https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/hal/hal-cpp/"$halVersion"/hal-cpp-"$halVersion"-${{ matrix.platform-type }}.zip
129+
utilPlatformUrl=https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/wpiutil/wpiutil-cpp/"$halVersion"/wpiutil-cpp-"$halVersion"-${{ matrix.platform-type }}.zip
130+
131+
curl -o halPlatform.zip "$halPlatformUrl"
132+
curl -o utilPlatform.zip "$utilPlatformUrl"
133+
134+
- name: Unzip WPILib HAL artifacts and headers
135+
run: |
136+
unzip halPlatform.zip -d halPlatform
137+
unzip utilPlatform.zip -d utilPlatform
138+
mkdir -p CANBridge-artifacts
139+
140+
# Put release files together in one directory based on platform
141+
- name: Create Artifact
142+
run: |
143+
mkdir -p CANBridge-artifacts
144+
if [[ "${{ matrix.platform-type }}" == "windowsx86-64" ]]; then
145+
cp build/libs/cANBridge/static/windowsx86-64/release/CANBridge.lib CANBridge-artifacts/CANBridge-static.lib
146+
cp build/libs/cANBridge/shared/windowsx86-64/release/CANBridge.dll CANBridge-artifacts/CANBridge.dll
147+
cp build/libs/cANBridge/shared/windowsx86-64/release/CANBridge.lib CANBridge-artifacts/CANBridge.lib
148+
cp halPlatform/windows/x86-64/shared/wpiHal.dll CANBridge-artifacts/wpiHal.dll
149+
cp halPlatform/windows/x86-64/shared/wpiHal.lib CANBridge-artifacts/wpiHal.lib
150+
cp utilPlatform/windows/x86-64/shared/wpiutil.dll CANBridge-artifacts/wpiutil.dll
151+
cp utilPlatform/windows/x86-64/shared/wpiutil.lib CANBridge-artifacts/wpiutil.lib
152+
elif [[ "${{ matrix.platform-type }}" == "linuxx86-64" ]]; then
153+
cp build/libs/cANBridge/static/linuxx86-64/release/libCANBridge.a CANBridge-artifacts/libCANBridge.a
154+
cp build/libs/cANBridge/shared/linuxx86-64/release/libCANBridge.so CANBridge-artifacts/libCANBridge.so
155+
cp halPlatform/linux/x86-64/shared/libwpiHal.so CANBridge-artifacts/libwpiHal.so
156+
cp utilPlatform/linux/x86-64/shared/libwpiutil.so CANBridge-artifacts/libwpiutil.so
157+
elif [[ "${{ matrix.platform-type }}" == "osxuniversal" ]]; then
158+
cp build/libs/cANBridge/static/osxuniversal/release/libCANBridge.a CANBridge-artifacts/libCANBridge.a
159+
cp build/libs/cANBridge/shared/osxuniversal/release/libCANBridge.dylib CANBridge-artifacts/libCANBridge.dylib
160+
cp halPlatform/osx/universal/shared/libwpiHal.dylib CANBridge-artifacts/libwpiHal.dylib
161+
cp utilPlatform/osx/universal/shared/libwpiutil.dylib CANBridge-artifacts/libwpiutil.dylib
162+
fi
163+
164+
# Upload build artifact
165+
- name: Upload build artifact
166+
uses: actions/upload-artifact@v4
167+
with:
168+
name: CANBridge-${{ matrix.platform-type }}-${{ github.sha}}
169+
path: CANBridge-artifacts/
170+
171+
# Upload combined headers for WPILib from HAL and WPIUtil
172+
wpi-headers:
173+
runs-on: ubuntu-latest
174+
name: "WPILib Headers"
175+
steps:
176+
- name: Checkout
177+
uses: actions/checkout@v4
178+
with:
179+
ref: ${{ github.sha }}
180+
- name: Download WPILib HAL artifacts and headers
181+
run : |
182+
halVersion=$(cat wpiHalVersion.txt)
183+
50184
halHeadersUrl=https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/hal/hal-cpp/"$halVersion"/hal-cpp-"$halVersion"-headers.zip
51-
utilWindowsUrl=https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/wpiutil/wpiutil-cpp/"$halVersion"/wpiutil-cpp-"$halVersion"-windowsx86-64.zip
52185
utilHeadersUrl=https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/wpiutil/wpiutil-cpp/"$halVersion"/wpiutil-cpp-"$halVersion"-headers.zip
53-
curl -o halWindows.zip "$halWindowsUrl"
186+
54187
curl -o halHeaders.zip "$halHeadersUrl"
55-
curl -o utilWindows.zip "$utilWindowsUrl"
56188
curl -o utilHeaders.zip "$utilHeadersUrl"
57-
unzip halWindows.zip -d halWindows
189+
190+
- name: Unzip WPILib HAL artifacts and headers
191+
run: |
58192
unzip halHeaders.zip -d halHeaders
59-
unzip utilWindows.zip -d utilWindows
60193
unzip utilHeaders.zip -d utilHeaders
61194
62-
# Gather all of the the needed headers
195+
- name: Gather all needed headers
196+
run: |
63197
mkdir headers-for-artifact
64198
cp -r halHeaders/hal headers-for-artifact
65199
cp -r utilHeaders/wpi headers-for-artifact
66200
cp -r src/main/native/include/* headers-for-artifact
67201
68-
# Zip the needed headers and put them in the appropriate location for artifact upload
69-
mkdir -p CANBridge-artifacts
70-
7z a CANBridge-artifacts/headers.zip ./headers-for-artifact/*
71-
72-
# Put release files together in one directory
73-
- name: Create Artifact
74-
run: |
75-
mkdir -p CANBridge-artifacts
76-
cp build/libs/cANBridge/static/windowsx86-64/release/CANBridge.lib CANBridge-artifacts/CANBridge-static.lib
77-
cp build/libs/cANBridge/shared/windowsx86-64/release/CANBridge.dll CANBridge-artifacts/CANBridge.dll
78-
cp build/libs/cANBridge/shared/windowsx86-64/release/CANBridge.lib CANBridge-artifacts/CANBridge.lib
79-
cp halWindows/windows/x86-64/shared/wpiHal.dll CANBridge-artifacts/wpiHal.dll
80-
cp halWindows/windows/x86-64/shared/wpiHal.lib CANBridge-artifacts/wpiHal.lib
81-
cp utilWindows/windows/x86-64/shared/wpiutil.dll CANBridge-artifacts/wpiutil.dll
82-
cp utilWindows/windows/x86-64/shared/wpiutil.lib CANBridge-artifacts/wpiutil.lib
83-
84202
# Upload build artifact
85203
- name: Upload build artifact
86-
uses: actions/upload-artifact@v3
204+
uses: actions/upload-artifact@v4
87205
with:
88-
name: CANBridge-${{ github.sha }}
89-
path: CANBridge-artifacts/
206+
path: headers-for-artifact
207+
name: headers
208+
209+
# Upload version file, used for versioning
210+
version:
211+
runs-on: ubuntu-latest
212+
name: "Version"
213+
steps:
214+
- name: Checkout
215+
uses: actions/checkout@v4
216+
with:
217+
ref: ${{ github.sha }}
218+
219+
- name: Setup Java
220+
uses: actions/setup-java@v4
221+
with:
222+
distribution: 'zulu'
223+
java-version: 11
90224

91-
# Upload version.txt
92-
- name: Upload version artifact
93-
uses: actions/upload-artifact@v3
225+
- name: Setup Gradle
226+
uses: gradle/actions/setup-gradle@v4
227+
228+
- name: Build
229+
run: |
230+
./gradlew outputVersions -PreleaseMode
231+
232+
- name: Upload build artifact
233+
uses: actions/upload-artifact@v4
94234
with:
95235
name: version
96-
path: build/allOutputs/version.txt
236+
path: build/allOutputs/version.txt

.github/workflows/release.yml

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,72 +3,76 @@ name: Create release
33
on:
44
push:
55
tags:
6-
- 'v*'
6+
- 'v**'
7+
8+
permissions:
9+
contents: write
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
13+
cancel-in-progress: false
714

815
defaults:
916
run:
1017
shell: bash
1118

1219
jobs:
13-
check-versions:
20+
# Checks previous build workflow and gets the version from publish.gradle
21+
check-build:
22+
name: Check build and publish versions
1423
runs-on: ubuntu-latest
1524
outputs:
1625
TAG_NAME: ${{ env.TAG_NAME }}
1726
VERSION: ${{ steps.get_version.outputs.version }}
1827
steps:
19-
- name: Wait for build to finish
20-
uses: lewagon/[email protected].1
28+
- name: Wait for build workflow to finish
29+
uses: lewagon/[email protected].4
2130
with:
2231
ref: ${{ github.ref }}
23-
check-name: 'build-windows64'
32+
check-regexp: 'Build|WPILib Headers|Version'
2433
repo-token: ${{ secrets.GITHUB_TOKEN }}
2534
wait-interval: 10
26-
- name: Get tag name
27-
run: |
28-
echo "TAG_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
2935

3036
# Download artifacts from build workflow
3137
- name: Download workflow artifacts
32-
uses: dawidd6/action-download-artifact@v2
38+
uses: dawidd6/action-download-artifact@v6
3339
with:
3440
workflow: build.yml
3541
commit: ${{ github.sha }}
3642
path: '.'
3743

3844
# Get publish.gradle version
3945
- name: Get publish.gradle version
40-
id: get_version
46+
id: get-version
4147
run: |
4248
echo "version=$(cat version/version.txt)" >> $GITHUB_OUTPUT
4349
echo "expectedTagName=v$(cat version/version.txt)" >> $GITHUB_OUTPUT
4450
45-
# Check publish.gradle version
46-
- name: publish.gradle version check FAILED
47-
if: ${{ steps.get_version.outputs.expectedTagName != env.TAG_NAME }}
48-
run: |
49-
echo Tag name: ${{ env.TAG_NAME }}
50-
echo publish.gradle version: ${{ steps.get_version.outputs.version }}
51-
exit 1
52-
51+
# Creates a release draft with the artifacts from the build workflow
5352
prepare-release:
53+
name: Prepare release
5454
runs-on: ubuntu-latest
55-
needs: check-versions
55+
needs: check-build
5656
steps:
5757
# Download API, docs, and version.txt
5858
- name: Download workflow artifacts
59-
uses: dawidd6/action-download-artifact@v2
59+
uses: dawidd6/action-download-artifact@v6
6060
with:
6161
workflow: build.yml
6262
commit: ${{ github.sha }}
6363
path: '.'
64+
skip_unpack: true
65+
66+
# This step is to check what files are downloaded and how they are structured, as well as binary sizes for releases
67+
- name: List files
68+
run: |
69+
ls -Rlh
6470
6571
# Create new release draft
6672
- name: Create release
67-
id: create_release
68-
env:
69-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70-
run: |
71-
VERSION=${{ needs.check-versions.outputs.version }}
72-
TAG=v$VERSION
73-
ls --recursive -l
74-
gh release create $TAG CANBridge-${{ github.sha }}/* --repo $GITHUB_REPOSITORY --draft --title "Version $VERSION"
73+
uses: softprops/action-gh-release@v2
74+
with:
75+
draft: true
76+
generate_release_notes: true
77+
files: |
78+
**/**

config.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ nativeUtils {
88
// When updating WPILib, be sure to also update wpiHalVersion.txt
99
wpiVersion = "2023.+"
1010
niLibVersion = "2023.3.0"
11-
googleTestVersion = "1.11.0-3"
11+
googleTestVersion = "1.11.0-4"
1212
}
1313
}
1414
}

0 commit comments

Comments
 (0)