From f04bb93a423ba21ed627340e1946fc3710371e72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Wed, 18 Sep 2019 21:51:01 +0200 Subject: [PATCH 1/6] Extract code format validation to its own job It makes no sense to start building things if code validation is going to fail. --- azure-pipelines-windows-template.yml | 2 +- azure-pipelines.yml | 23 +++++++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/azure-pipelines-windows-template.yml b/azure-pipelines-windows-template.yml index 74b6d744..1e5bc4c9 100644 --- a/azure-pipelines-windows-template.yml +++ b/azure-pipelines-windows-template.yml @@ -10,7 +10,7 @@ parameters: jobs: - job: ${{ parameters.name }} - dependsOn: Initialization + dependsOn: CodeFormatValidation pool: vmImage: 'vs2017-win2016' steps: diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 4e6b7200..6faba04e 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -10,8 +10,21 @@ jobs: vmImage: 'vs2017-win2016' steps: - template: azure-pipelines-build-number.yml -- job: Linux +- job: CodeFormatValidation dependsOn: Initialization + pool: + vmImage: 'macOS-10.14' + steps: + - script: | + brew install clang-format + displayName: 'Install dependencies' + - script: | + cd $(Build.SourcesDirectory) + find . \( -name '*.h' -or -name '*.cpp' -or -name '*.c' -or -name '*.mm' -or -name '*.m' \) -print0 | xargs -0 clang-format -style=file -i + if [ "$(git diff $(Build.SourceVersion))" != "" ]; then exit 1; fi + displayName: 'clang-format' +- job: Linux + dependsOn: CodeFormatValidation pool: vmImage: 'ubuntu-16.04' steps: @@ -45,7 +58,7 @@ jobs: path: $(Build.ArtifactStagingDirectory) artifactName: src $(Build.BuildNumber) tarball - job: MacOS - dependsOn: Initialization + dependsOn: CodeFormatValidation variables: - group: macos-codesign pool: @@ -55,7 +68,6 @@ jobs: brew install qt brew link qt --force brew install create-dmg - brew install clang-format brew install node brew link --overwrite node npm install -g appdmg @@ -63,11 +75,6 @@ jobs: tar xjf $(Build.SourcesDirectory)/compressed_archive/p7zip_16.02_src_all.tar.bz2 -C $(Build.SourcesDirectory)/compressed_archive mv $(Build.SourcesDirectory)/compressed_archive/p7zip_16.02 $(Build.SourcesDirectory)/compressed_archive/libp7zip displayName: 'Install dependencies' - - script: | - cd $(Build.SourcesDirectory) - find . \( -name '*.h' -or -name '*.cpp' -or -name '*.c' -or -name '*.mm' -or -name '*.m' \) -print0 | xargs -0 clang-format -style=file -i - if [ "$(git diff $(Build.SourceVersion))" != "" ]; then exit 1; fi - displayName: 'Check format' - task: InstallAppleCertificate@2 inputs: certSecureFile: 'developerID_application.p12' From 8b923aeb18e54c41f7765e59784cd7a5e355b6dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Wed, 18 Sep 2019 22:19:54 +0200 Subject: [PATCH 2/6] Inline release script into compileOSX --- compileOSX.sh | 29 ++++++++++++++++++++++++++++- releaseOSX.sh | 32 -------------------------------- 2 files changed, 28 insertions(+), 33 deletions(-) delete mode 100755 releaseOSX.sh diff --git a/compileOSX.sh b/compileOSX.sh index 619b0d6a..d04c0d49 100755 --- a/compileOSX.sh +++ b/compileOSX.sh @@ -35,7 +35,34 @@ cp -R YACReader/YACReader.app YACReader.app cp -R YACReaderLibrary/YACReaderLibrary.app YACReaderLibrary.app cp -R YACReaderLibraryServer/YACReaderLibraryServer.app YACReaderLibraryServer.app -./releaseOSX.sh +hash macdeployqt 2>/dev/null || { echo >&2 "macdeployqt command not available. Please add the bin subfolder of your Qt installation to the PATH environment variable."; exit 1; } + +echo "Preparing apps for release ..." + +macdeployqt YACReader.app +macdeployqt YACReaderLibrary.app -qmldir=YACReaderLibrary/qml +macdeployqt YACReaderLibraryServer.app + +mkdir -p YACReader.app/Contents/MacOS/utils +mkdir -p YACReaderLibrary.app/Contents/MacOS/utils +mkdir -p YACReaderLibraryServer.app/Contents/MacOS/utils + +cp dependencies/qrencode/macx/libqrencode.4.0.0.dylib \ +YACReaderLibrary.app/Contents/MacOS/utils/libqrencode.dylib + +cp -R dependencies/7zip/macx/* YACReader.app/Contents/MacOS/utils/ +cp -R dependencies/7zip/macx/* YACReaderLibrary.app/Contents/MacOS/utils/ +cp -R dependencies/7zip/macx/* YACReaderLibraryServer.app/Contents/MacOS/utils/ + +cp -R release/server YACReaderLibrary.app/Contents/MacOS/ +cp -R release/server YACReaderLibraryServer.app/Contents/MacOS/ +cp -R release/languages YACReader.app/Contents/MacOS/ +cp -R release/languages YACReaderLibrary.app/Contents/MacOS/ +cp -R release/languages YACReaderLibraryServer.app/Contents/MacOS/ + +./signapps.sh + +echo "Preparing apps for release, Done." echo "Copying to destination folder" dest="YACReader-$VERSION.$BUILD_NUMBER MacOSX-Intel" diff --git a/releaseOSX.sh b/releaseOSX.sh deleted file mode 100755 index a5d77a73..00000000 --- a/releaseOSX.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash -set -e - -hash macdeployqt 2>/dev/null || { echo >&2 "macdeployqt command not available. Please add the bin subfolder of your Qt installation to the PATH environment variable."; exit 1; } - -echo "Preparing apps for release ..." - -macdeployqt YACReader.app -macdeployqt YACReaderLibrary.app -qmldir=YACReaderLibrary/qml -macdeployqt YACReaderLibraryServer.app - -mkdir -p YACReader.app/Contents/MacOS/utils -mkdir -p YACReaderLibrary.app/Contents/MacOS/utils -mkdir -p YACReaderLibraryServer.app/Contents/MacOS/utils - -cp dependencies/qrencode/macx/libqrencode.4.0.0.dylib \ -YACReaderLibrary.app/Contents/MacOS/utils/libqrencode.dylib - -cp -R dependencies/7zip/macx/* YACReader.app/Contents/MacOS/utils/ -cp -R dependencies/7zip/macx/* YACReaderLibrary.app/Contents/MacOS/utils/ -cp -R dependencies/7zip/macx/* YACReaderLibraryServer.app/Contents/MacOS/utils/ - -cp -R release/server YACReaderLibrary.app/Contents/MacOS/ -cp -R release/server YACReaderLibraryServer.app/Contents/MacOS/ -cp -R release/languages YACReader.app/Contents/MacOS/ -cp -R release/languages YACReaderLibrary.app/Contents/MacOS/ -cp -R release/languages YACReaderLibraryServer.app/Contents/MacOS/ - -./signapps.sh - -echo "Done." - From 7618cbea73149f0079bb596974b0b0d63de87f3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Wed, 18 Sep 2019 22:20:30 +0200 Subject: [PATCH 3/6] Add support for skipping codesign in compileOSX.sh --- compileOSX.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/compileOSX.sh b/compileOSX.sh index d04c0d49..dd589da5 100755 --- a/compileOSX.sh +++ b/compileOSX.sh @@ -5,7 +5,9 @@ VERSION=${1:-"9.5.0"} BUILD_NUMBER=${2:-"0"} -if [ "$3" == "clean" ]; then +SKIP_CODESIGN=${3:-false} + +if [ "$4" == "clean" ]; then ./cleanOSX.sh fi @@ -60,7 +62,9 @@ cp -R release/languages YACReader.app/Contents/MacOS/ cp -R release/languages YACReaderLibrary.app/Contents/MacOS/ cp -R release/languages YACReaderLibraryServer.app/Contents/MacOS/ +if [ "$SKIP_CODESIGN" = false ]; then ./signapps.sh +fi echo "Preparing apps for release, Done." @@ -88,6 +92,8 @@ sed -i'' -e "s/#VERSION#/$VERSION/g" dmg.json sed -i'' -e "s/#BUILD_NUMBER#/$BUILD_NUMBER/g" dmg.json appdmg dmg.json "$dest.dmg" +if [ "$SKIP_CODESIGN" = false ]; then codesign --force --deep --sign "Developer ID Application: LUIS ANGEL SAN MARTIN ROD (9B6KKVW3WM)" "./${dest}.dmg" +fi echo "Done!" From 9b994bbf1ed48c3b42b69e09cd85960ada76bca3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Wed, 18 Sep 2019 22:21:05 +0200 Subject: [PATCH 4/6] If PRs come from a fork do not codesign macos apps It fails in Azure Pipelines due to security reasons --- azure-pipelines.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 6faba04e..7b5543e0 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -82,7 +82,8 @@ jobs: - script: | cd $(Build.SourcesDirectory) VERSION="$(cat common/yacreader_global.h | grep '#define VERSION "' | tr -d '#define VERSION' | tr -d '"' )" - ./compileOSX.sh $VERSION $(Build.BuildNumber) + SKIP_CODESIGN=$(System.PullRequest.IsFork) + ./compileOSX.sh $VERSION $(Build.BuildNumber) $SKIP_CODESIGN displayName: 'Build' - task: CopyFiles@2 inputs: From fa874ddcd18140174cb952c8ac61ab52764fe25e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Wed, 18 Sep 2019 23:26:13 +0200 Subject: [PATCH 5/6] Keep track about codesign in the logs --- compileOSX.sh | 5 +++-- signapps.sh | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/compileOSX.sh b/compileOSX.sh index dd589da5..e28f47eb 100755 --- a/compileOSX.sh +++ b/compileOSX.sh @@ -63,7 +63,7 @@ cp -R release/languages YACReaderLibrary.app/Contents/MacOS/ cp -R release/languages YACReaderLibraryServer.app/Contents/MacOS/ if [ "$SKIP_CODESIGN" = false ]; then -./signapps.sh + ./signapps.sh fi echo "Preparing apps for release, Done." @@ -93,7 +93,8 @@ sed -i'' -e "s/#BUILD_NUMBER#/$BUILD_NUMBER/g" dmg.json appdmg dmg.json "$dest.dmg" if [ "$SKIP_CODESIGN" = false ]; then -codesign --force --deep --sign "Developer ID Application: LUIS ANGEL SAN MARTIN ROD (9B6KKVW3WM)" "./${dest}.dmg" + echo "Signing dmg" + codesign --force --deep --sign "Developer ID Application: LUIS ANGEL SAN MARTIN ROD (9B6KKVW3WM)" "./${dest}.dmg" fi echo "Done!" diff --git a/signapps.sh b/signapps.sh index 32685626..d3f6e71c 100755 --- a/signapps.sh +++ b/signapps.sh @@ -1,5 +1,7 @@ #!/bin/bash +echo "Signing apps" + codesign --force --deep --sign "Developer ID Application: LUIS ANGEL SAN MARTIN ROD (9B6KKVW3WM)" ./YACReader.app codesign --force --deep --sign "Developer ID Application: LUIS ANGEL SAN MARTIN ROD (9B6KKVW3WM)" ./YACReaderLibrary.app codesign --force --deep --sign "Developer ID Application: LUIS ANGEL SAN MARTIN ROD (9B6KKVW3WM)" ./YACReaderLibraryServer.app From 122806b0e37fcca3a86a8d28ac845618fde1ca5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Wed, 18 Sep 2019 23:26:55 +0200 Subject: [PATCH 6/6] Booleans are True/False in azure pipelines We need lower case --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 7b5543e0..831b074f 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -82,7 +82,7 @@ jobs: - script: | cd $(Build.SourcesDirectory) VERSION="$(cat common/yacreader_global.h | grep '#define VERSION "' | tr -d '#define VERSION' | tr -d '"' )" - SKIP_CODESIGN=$(System.PullRequest.IsFork) + SKIP_CODESIGN="$(tr [A-Z] [a-z] <<< "$(System.PullRequest.IsFork)")" ./compileOSX.sh $VERSION $(Build.BuildNumber) $SKIP_CODESIGN displayName: 'Build' - task: CopyFiles@2