Skip to content

Commit

Permalink
Reorganize and clean up some build files (#168)
Browse files Browse the repository at this point in the history
* Reorganize and clean up some build files

* Revert to wpilibsuite
  • Loading branch information
prateekma authored Aug 13, 2021
1 parent 0d3b2a6 commit f953542
Show file tree
Hide file tree
Showing 7 changed files with 262 additions and 157 deletions.
124 changes: 42 additions & 82 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: CI

on: [push, pull_request]
on: [ push, pull_request ]

jobs:
build:
Expand All @@ -11,127 +11,87 @@ jobs:
- os: ubuntu-latest
artifact-name: Linux
build-options: "-PlinuxBuild"
- os: macos-latest
artifact-name: macOS
build-options: "-PmacBuild"
- os: windows-latest
artifact-name: Win64
build-options: ""
- os: windows-latest
artifact-name: Win32
build-options: "-Pwindows32"

name: "Build - ${{ matrix.artifact-name }}"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.100
- uses: actions/setup-java@v1
with:
java-version: 11
- name: Build Installer
shell: bash
run: ./gradlew generateInstallers -PjenkinsBuild ${{ matrix.build-options }}
- uses: actions/upload-artifact@v2
with:
name: ${{ matrix.artifact-name }}
path: build/pubOutputs/

build-macos:
name: Build - macOS
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-dotnet@v1
name: Setup .NET
with:
dotnet-version: 5.0.100
- uses: actions/setup-java@v1
with:
java-version: 11
- name: Build Installer
shell: bash
run: ./gradlew generateInstallers -PjenkinsBuild -PmacBuild
- name: Copy Installer and Resources to Build Directory
working-directory: build
run: |
mkdir -p pubOutputs
cp -R outputs/WPILibInstaller.app pubOutputs/WPILibInstaller.app
cp outputs/*.zip pubOutputs/WPILibInstaller.app/Contents/MacOS/
cp outputs/WPILibInstallerVersion.txt pubOutputs/WPILibInstaller.app/Contents/MacOS/
cp ../WPILibInstaller-Avalonia/wpilib.icns pubOutputs/WPILibInstaller.app/Contents/Resources/
cp ../Info.plist pubOutputs/WPILibInstaller.app/Contents/Info.plist
cp outputs/*.tar.gz pubOutputs/

- 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: |
github.repository_owner == 'wpilibsuite' &&
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
matrix.artifact-name == 'macOS' && github.repository_owner == 'wpilibsuite' &&
github.event_name == 'push'
- name: Set Keychain Lock Timeout
run: security set-keychain-settings -lut 2700
if: |
github.repository_owner == 'wpilibsuite' &&
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
matrix.artifact-name == 'macOS' && github.repository_owner == 'wpilibsuite' &&
github.event_name == 'push'
- name: Sign Installer with Developer ID
run: ./codesign.sh ${{ secrets.APPLE_DEVELOPER_ID }}
if: |
github.repository_owner == 'wpilibsuite' &&
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
- name: Notarize Installer
uses: wpilibsuite/xcode-notarize@v1
with:
product-path: "build/pubOutputs/WPILibInstaller.app"
primary-bundle-id: edu.wpi.first.wpilibinstaller
appstore-connect-username: ${{ secrets.APPLE_NOTARIZATION_USERNAME }}
appstore-connect-password: ${{ secrets.APPLE_NOTARIZATION_PASSWORD }}
if: |
github.repository_owner == 'wpilibsuite' &&
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
- name: Staple Notarization Ticket to Installer
run: xcrun stapler staple -v build/pubOutputs/WPILibInstaller.app
- name: Build Installer (PR)
shell: bash
run: ./gradlew generateInstallers -PjenkinsBuild ${{ matrix.build-options }}
if: |
github.repository_owner == 'wpilibsuite' &&
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
github.repository_owner != 'wpilibsuite' || github.event_name != 'push'
- name: Create DMG
working-directory: build
- name: Build Installer (Main)
shell: bash
run: |
hdiutil create -volname WPILibInstaller -srcfolder pubOutputs/ -format UDRO WPILib_macOS-`/usr/libexec/PlistBuddy -c "Print CFBundleVersion" pubOutputs/WPILibInstaller.app/Contents/Info.plist`.dmg
./gradlew generateInstallers -PjenkinsBuild ${{ matrix.build-options }} \
-PdeveloperID=${{ secrets.APPLE_DEVELOPER_ID }} \
-Pnotarization-username=${{ secrets.APPLE_NOTARIZATION_USERNAME }} \
-Pnotarization-password=${{ secrets.APPLE_NOTARIZATION_PASSWORD }}
if: |
github.repository_owner == 'wpilibsuite' && github.event_name == 'push'
- name: Upload Installer DMG
uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v2
with:
name: macOS
path: ${{ github.workspace }}/build/*.dmg
name: ${{ matrix.artifact-name }}
path: build/pubOutputs/

format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.100
- uses: actions/setup-python@v2
with:
python-version: 3.8
- uses: actions/checkout@v2
- uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.100
- uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Restore format tool
run: dotnet tool restore
- name: Restore format tool
run: dotnet tool restore

- name: Install black
run: pip3 install black
- name: Install black
run: pip3 install black

- name: Run dotnet format
run: dotnet format
- name: Run dotnet format
run: dotnet format

- name: Run black
run: black .
- name: Run black
run: black .

- name: Verify formatters made no changes
run: git --no-pager diff --exit-code HEAD
- name: Verify formatters made no changes
run: git --no-pager diff --exit-code HEAD
2 changes: 0 additions & 2 deletions WPILibInstaller-Avalonia/WPILibInstaller-Avalonia.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
<AssemblyName>WPILibInstaller</AssemblyName>
<RootNamespace>WPILibInstaller</RootNamespace>
<ApplicationIcon>wpilib-256.ico</ApplicationIcon>
<CFBundleIconFile>wpilib.icns</CFBundleIconFile>
<CFBundleVersion>2021.3.1</CFBundleVersion>
<Win32Resource />
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions codesign.sh → automation/macos_codesign.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
APP_NAME="build/pubOutputs/WPILibInstaller.app"
ENTITLEMENTS="WPILibInstaller.entitlements"
APP_NAME="$2"
ENTITLEMENTS="automation/macos_entitlements.entitlements"
SIGNING_IDENTITY="$1"

find "$APP_NAME/Contents/MacOS/"|while read fname; do
Expand Down
File renamed without changes.
78 changes: 78 additions & 0 deletions automation/macos_notarization.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import groovy.json.JsonSlurper

ext.notarize = { File application, String id, String username, String password ->
// Step 1: archive the application.
println "Archiving application..."
exec { commandLine "ditto", "-c", "-k", "--keepParent", application.getAbsolutePath(), "/tmp/archive.zip" }

// Step 2: submit application for notarization.
println "Submitting application to notarization service..."
def stdout = new ByteArrayOutputStream()
def result = exec {
commandLine "xcrun", "altool", "--output-format", "json", "--notarize-app", "-f", "/tmp/archive.zip",
"--primary-bundle-id", id, "-u", username, "-p", password
standardOutput = stdout
ignoreExitValue(true)
}

if (result.exitValue != 0) {
println stdout.toString()
return
}

// Step 3: process the request UUID.
def parser = new JsonSlurper()
def object = parser.parseText(stdout.toString())
def uuid = object["notarization-upload"]["RequestUUID"] as String
println "Submitted application with UUID: $uuid"

// Step 4: wait until notarization is complete.
def success = false
String[] args = ["xcrun", "altool", "--output-format", "json", "--notarization-info", uuid,
"-u", username, "-p", password]

for (int i = 0; i < 40; i++) {
stdout = new ByteArrayOutputStream()
result = exec {
commandLine args
standardOutput = stdout
ignoreExitValue(true)
}

if (result.exitValue != 0) {
println stdout.toString()
return
}

def response = parser.parseText(stdout.toString())["notarization-info"]
def exit = false

switch (response["Status"] as String) {
case "in progress":
println "Notarization is in progress..."
break
case "invalid":
exit = true
println "Notarization was invalid: ${response["Status Message"] as String}"
break
case "success":
exit = true
success = true
println "Notarization succeeded!"
break
default:
exit = true
println "Unknown status"
break
}

if (exit) break
Thread.sleep(30000)
}

if (!success) throw new GradleException("The notarization failed!")

// Step 5: staple the notarization ticket.
println "Stapling notarization ticket..."
exec { commandLine "xcrun", "stapler", "staple", "-v", application.getAbsolutePath() }
}
4 changes: 2 additions & 2 deletions Info.plist → automation/macos_plist.in
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleShortVersionString</key>
<string>2021.3.1</string>
<string>${wpilib_version}</string>
<key>CFBundleVersion</key>
<string>2021.3.1</string>
<string>${wpilib_version}</string>
<key>LSMinimumSystemVersion</key>
<string>10.11</string>
<key>NSHighResolutionCapable</key>
Expand Down
Loading

0 comments on commit f953542

Please sign in to comment.