From 0caeb383ba9f26d0ed328becc8e8b0b19e8addbd Mon Sep 17 00:00:00 2001 From: Garrett Summerfield Date: Sun, 22 Sep 2024 01:43:32 -0500 Subject: [PATCH] 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. --- .github/workflows/build.yml | 232 +++++++++++++++++++++++++++------- .github/workflows/release.yml | 60 +++++---- config.gradle | 2 +- gradlew | 0 4 files changed, 219 insertions(+), 75 deletions(-) mode change 100644 => 100755 gradlew diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index aba5ea4..a93abf8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,96 +1,236 @@ name: Build on: - push: - branches: - - 'main' - pull_request: - branches: - - '*' + [push, pull_request] + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} + cancel-in-progress: false defaults: run: shell: bash jobs: - build: + # Use WPI provided Docker images to build for Linux ARM32 and ARM64 platforms + build-docker: + strategy: + fail-fast: false + matrix: + include: + - container: wpilib/aarch64-cross-ubuntu:bullseye-22.04 + name: LinuxARM64 + build-options: "-Ponlylinuxarm64" + platform-type: linuxarm64 + arch: arm64 + - container: wpilib/raspbian-cross-ubuntu:bullseye-22.04 + name: LinuxARM32 + build-options: "-Ponlylinuxarm32" + platform-type: linuxarm32 + arch: arm32 + runs-on: ubuntu-latest + name: "Build - ${{ matrix.name }}" + container: ${{ matrix.container }} + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ github.sha }} + + - name: Setup Java + uses: actions/setup-java@v4 + with: + distribution: 'zulu' + java-version: 11 + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + + - name: Build + run: | + ./gradlew outputVersions publish ${{ matrix.build-options }} -PreleaseMode + + - name: Download WPILib HAL artifacts and headers for ${{ matrix.platform-type }} + run : | + halVersion=$(cat wpiHalVersion.txt) + + halPlatformUrl=https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/hal/hal-cpp/"$halVersion"/hal-cpp-"$halVersion"-${{ matrix.platform-type }}.zip + utilPlatformUrl=https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/wpiutil/wpiutil-cpp/"$halVersion"/wpiutil-cpp-"$halVersion"-${{ matrix.platform-type }}.zip + + curl -o halPlatform.zip "$halPlatformUrl" + curl -o utilPlatform.zip "$utilPlatformUrl" + + - name: Unzip WPILib HAL artifacts and headers + run: | + unzip halPlatform.zip -d halPlatform + unzip utilPlatform.zip -d utilPlatform + mkdir -p CANBridge-artifacts + + # Put Linux ARM release files together in one directory + - name: Create Artifact + run: | + cp build/libs/cANBridge/static/release/libCANBridge.a CANBridge-artifacts/libCANBridge.a + cp build/libs/cANBridge/shared/release/libCANBridge.so CANBridge-artifacts/libCANBridge.so + cp halPlatform/linux/${{ matrix.arch }}/shared/libwpiHal.so CANBridge-artifacts/libwpiHal.so + cp utilPlatform/linux/${{ matrix.arch }}/shared/libwpiutil.so CANBridge-artifacts/libwpiutil.so + + # Upload build artifact + - name: Upload build artifact + uses: actions/upload-artifact@v4 + with: + name: CANBridge-${{ matrix.platform-type }}-${{ github.sha}} + path: CANBridge-artifacts/ + + # Use native runners to build for Windows, Linux, and macOS + build-native: timeout-minutes: 15 strategy: fail-fast: false matrix: include: - os: windows-latest - container: '' - name: windows64 - name: "build-${{ matrix.name }}" + name: Win64 + build-options: "" + platform-type: windowsx86-64 + - os: ubuntu-latest + name: Linux64 + platform-type: linuxx86-64 + build-options: "" + - os: macos-latest + name: macOS + platform-type: osxuniversal + build-options: "" + name: "Build - ${{ matrix.name }}" runs-on: ${{ matrix.os }} - container: ${{ matrix.container }} steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: ${{ github.sha }} - name: Setup Java - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: 'zulu' java-version: 11 + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + - name: Build run: | ./gradlew outputVersions publish ${{ matrix.build-options }} -PreleaseMode - - name: Download WPILib HAL artifacts and headers, gather all needed headers + - name: Download WPILib HAL artifacts and headers for ${{ matrix.platform-type }} run : | halVersion=$(cat wpiHalVersion.txt) - - # Download WPILib artifacts from Artifactory - halWindowsUrl=https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/hal/hal-cpp/"$halVersion"/hal-cpp-"$halVersion"-windowsx86-64.zip + + halPlatformUrl=https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/hal/hal-cpp/"$halVersion"/hal-cpp-"$halVersion"-${{ matrix.platform-type }}.zip + utilPlatformUrl=https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/wpiutil/wpiutil-cpp/"$halVersion"/wpiutil-cpp-"$halVersion"-${{ matrix.platform-type }}.zip + + curl -o halPlatform.zip "$halPlatformUrl" + curl -o utilPlatform.zip "$utilPlatformUrl" + + - name: Unzip WPILib HAL artifacts and headers + run: | + unzip halPlatform.zip -d halPlatform + unzip utilPlatform.zip -d utilPlatform + mkdir -p CANBridge-artifacts + + # Put release files together in one directory based on platform + - name: Create Artifact + run: | + mkdir -p CANBridge-artifacts + if [[ "${{ matrix.platform-type }}" == "windowsx86-64" ]]; then + cp build/libs/cANBridge/static/windowsx86-64/release/CANBridge.lib CANBridge-artifacts/CANBridge-static.lib + cp build/libs/cANBridge/shared/windowsx86-64/release/CANBridge.dll CANBridge-artifacts/CANBridge.dll + cp build/libs/cANBridge/shared/windowsx86-64/release/CANBridge.lib CANBridge-artifacts/CANBridge.lib + cp halPlatform/windows/x86-64/shared/wpiHal.dll CANBridge-artifacts/wpiHal.dll + cp halPlatform/windows/x86-64/shared/wpiHal.lib CANBridge-artifacts/wpiHal.lib + cp utilPlatform/windows/x86-64/shared/wpiutil.dll CANBridge-artifacts/wpiutil.dll + cp utilPlatform/windows/x86-64/shared/wpiutil.lib CANBridge-artifacts/wpiutil.lib + elif [[ "${{ matrix.platform-type }}" == "linuxx86-64" ]]; then + cp build/libs/cANBridge/static/linuxx86-64/release/libCANBridge.a CANBridge-artifacts/libCANBridge.a + cp build/libs/cANBridge/shared/linuxx86-64/release/libCANBridge.so CANBridge-artifacts/libCANBridge.so + cp halPlatform/linux/x86-64/shared/libwpiHal.so CANBridge-artifacts/libwpiHal.so + cp utilPlatform/linux/x86-64/shared/libwpiutil.so CANBridge-artifacts/libwpiutil.so + elif [[ "${{ matrix.platform-type }}" == "osxuniversal" ]]; then + cp build/libs/cANBridge/static/osxuniversal/release/libCANBridge.a CANBridge-artifacts/libCANBridge.a + cp build/libs/cANBridge/shared/osxuniversal/release/libCANBridge.dylib CANBridge-artifacts/libCANBridge.dylib + cp halPlatform/osx/universal/shared/libwpiHal.dylib CANBridge-artifacts/libwpiHal.dylib + cp utilPlatform/osx/universal/shared/libwpiutil.dylib CANBridge-artifacts/libwpiutil.dylib + fi + + # Upload build artifact + - name: Upload build artifact + uses: actions/upload-artifact@v4 + with: + name: CANBridge-${{ matrix.platform-type }}-${{ github.sha}} + path: CANBridge-artifacts/ + + # Upload combined headers for WPILib from HAL and WPIUtil + wpi-headers: + runs-on: ubuntu-latest + name: "WPILib Headers" + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ github.sha }} + - name: Download WPILib HAL artifacts and headers + run : | + halVersion=$(cat wpiHalVersion.txt) + halHeadersUrl=https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/hal/hal-cpp/"$halVersion"/hal-cpp-"$halVersion"-headers.zip - utilWindowsUrl=https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/wpiutil/wpiutil-cpp/"$halVersion"/wpiutil-cpp-"$halVersion"-windowsx86-64.zip utilHeadersUrl=https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/wpiutil/wpiutil-cpp/"$halVersion"/wpiutil-cpp-"$halVersion"-headers.zip - curl -o halWindows.zip "$halWindowsUrl" + curl -o halHeaders.zip "$halHeadersUrl" - curl -o utilWindows.zip "$utilWindowsUrl" curl -o utilHeaders.zip "$utilHeadersUrl" - unzip halWindows.zip -d halWindows + + - name: Unzip WPILib HAL artifacts and headers + run: | unzip halHeaders.zip -d halHeaders - unzip utilWindows.zip -d utilWindows unzip utilHeaders.zip -d utilHeaders - # Gather all of the the needed headers + - name: Gather all needed headers + run: | mkdir headers-for-artifact cp -r halHeaders/hal headers-for-artifact cp -r utilHeaders/wpi headers-for-artifact cp -r src/main/native/include/* headers-for-artifact - # Zip the needed headers and put them in the appropriate location for artifact upload - mkdir -p CANBridge-artifacts - 7z a CANBridge-artifacts/headers.zip ./headers-for-artifact/* - - # Put release files together in one directory - - name: Create Artifact - run: | - mkdir -p CANBridge-artifacts - cp build/libs/cANBridge/static/windowsx86-64/release/CANBridge.lib CANBridge-artifacts/CANBridge-static.lib - cp build/libs/cANBridge/shared/windowsx86-64/release/CANBridge.dll CANBridge-artifacts/CANBridge.dll - cp build/libs/cANBridge/shared/windowsx86-64/release/CANBridge.lib CANBridge-artifacts/CANBridge.lib - cp halWindows/windows/x86-64/shared/wpiHal.dll CANBridge-artifacts/wpiHal.dll - cp halWindows/windows/x86-64/shared/wpiHal.lib CANBridge-artifacts/wpiHal.lib - cp utilWindows/windows/x86-64/shared/wpiutil.dll CANBridge-artifacts/wpiutil.dll - cp utilWindows/windows/x86-64/shared/wpiutil.lib CANBridge-artifacts/wpiutil.lib - # Upload build artifact - name: Upload build artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: CANBridge-${{ github.sha }} - path: CANBridge-artifacts/ + path: headers-for-artifact + name: headers + + # Upload version file, used for versioning + version: + runs-on: ubuntu-latest + name: "Version" + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ github.sha }} + + - name: Setup Java + uses: actions/setup-java@v4 + with: + distribution: 'zulu' + java-version: 11 - # Upload version.txt - - name: Upload version artifact - uses: actions/upload-artifact@v3 + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + + - name: Build + run: | + ./gradlew outputVersions -PreleaseMode + + - name: Upload build artifact + uses: actions/upload-artifact@v4 with: name: version - path: build/allOutputs/version.txt + path: build/allOutputs/version.txt \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0c00949..d550195 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,33 +3,39 @@ name: Create release on: push: tags: - - 'v*' + - 'v**' + +permissions: + contents: write + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} + cancel-in-progress: false defaults: run: shell: bash jobs: - check-versions: + # Checks previous build workflow and gets the version from publish.gradle + check-build: + name: Check build and publish versions runs-on: ubuntu-latest outputs: TAG_NAME: ${{ env.TAG_NAME }} VERSION: ${{ steps.get_version.outputs.version }} steps: - - name: Wait for build to finish - uses: lewagon/wait-on-check-action@v1.3.1 + - name: Wait for build workflow to finish + uses: lewagon/wait-on-check-action@v1.3.4 with: ref: ${{ github.ref }} - check-name: 'build-windows64' + check-regexp: 'Build|WPILib Headers|Version' repo-token: ${{ secrets.GITHUB_TOKEN }} wait-interval: 10 - - name: Get tag name - run: | - echo "TAG_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV # Download artifacts from build workflow - name: Download workflow artifacts - uses: dawidd6/action-download-artifact@v2 + uses: dawidd6/action-download-artifact@v6 with: workflow: build.yml commit: ${{ github.sha }} @@ -37,38 +43,36 @@ jobs: # Get publish.gradle version - name: Get publish.gradle version - id: get_version + id: get-version run: | echo "version=$(cat version/version.txt)" >> $GITHUB_OUTPUT echo "expectedTagName=v$(cat version/version.txt)" >> $GITHUB_OUTPUT - # Check publish.gradle version - - name: publish.gradle version check FAILED - if: ${{ steps.get_version.outputs.expectedTagName != env.TAG_NAME }} - run: | - echo Tag name: ${{ env.TAG_NAME }} - echo publish.gradle version: ${{ steps.get_version.outputs.version }} - exit 1 - + # Creates a release draft with the artifacts from the build workflow prepare-release: + name: Prepare release runs-on: ubuntu-latest - needs: check-versions + needs: check-build steps: # Download API, docs, and version.txt - name: Download workflow artifacts - uses: dawidd6/action-download-artifact@v2 + uses: dawidd6/action-download-artifact@v6 with: workflow: build.yml commit: ${{ github.sha }} path: '.' + skip_unpack: true + + # This step is to check what files are downloaded and how they are structured, as well as binary sizes for releases + - name: List files + run: | + ls -Rlh # Create new release draft - name: Create release - id: create_release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - VERSION=${{ needs.check-versions.outputs.version }} - TAG=v$VERSION - ls --recursive -l - gh release create $TAG CANBridge-${{ github.sha }}/* --repo $GITHUB_REPOSITORY --draft --title "Version $VERSION" + uses: softprops/action-gh-release@v2 + with: + draft: true + generate_release_notes: true + files: | + **/** \ No newline at end of file diff --git a/config.gradle b/config.gradle index 7a59e9d..1c8fcb6 100644 --- a/config.gradle +++ b/config.gradle @@ -8,7 +8,7 @@ nativeUtils { // When updating WPILib, be sure to also update wpiHalVersion.txt wpiVersion = "2023.+" niLibVersion = "2023.3.0" - googleTestVersion = "1.11.0-3" + googleTestVersion = "1.11.0-4" } } } diff --git a/gradlew b/gradlew old mode 100644 new mode 100755