diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5db52a4e6f..3962e1046f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,8 +58,27 @@ jobs: with: java-version: 11 architecture: ${{ matrix.architecture }} + - name: Import Developer ID Certificate + uses: wpilibsuite/import-signing-certificate@v1 + with: + certificate-data: ${{ secrets.APPLE_CERTIFICATE_DATA }} + certificate-passphrase: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }} + keychain-password: ${{ secrets.APPLE_KEYCHAIN_PASSWORD }} + if: | + matrix.artifact-name == 'macOS' && (github.repository_owner == 'wpilibsuite' && + (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v'))) + - name: Set Keychain Lock Timeout + run: security set-keychain-settings -lut 3600 + if: | + matrix.artifact-name == 'macOS' && (github.repository_owner == 'wpilibsuite' && + (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v'))) - name: Build with Gradle run: ./gradlew build -PbuildServer + - name: Sign Libraries with Developer ID + run: ./gradlew build -PbuildServer -PdeveloperID=${{ secrets.APPLE_DEVELOPER_ID }} + if: | + matrix.artifact-name == 'macOS' && (github.repository_owner == 'wpilibsuite' && + (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v'))) - uses: actions/upload-artifact@v2 with: name: ${{ matrix.artifact-name }} diff --git a/build.gradle b/build.gradle index 53d4800394..544ca3414c 100644 --- a/build.gradle +++ b/build.gradle @@ -103,6 +103,26 @@ subprojects { } } } + + // Sign outputs with Developer ID + if (project.hasProperty("developerID")) { + tasks.withType(AbstractLinkTask) { task -> + // Don't sign any executables because codesign complains + // about relative rpath. + if (!(task instanceof LinkExecutable)) { + doLast { + // Get path to binary. + String path = task.getLinkedFile().getAsFile().get().getAbsolutePath() + exec { + workingDir rootDir + def args = ["sh", "-c", "codesign --force --strict --timestamp --options=runtime " + + "--verbose -s ${project.findProperty("developerID")} ${path}"] + commandLine args + } + } + } + } + } } ext.getCurrentArch = {