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..831b074f 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' @@ -75,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="$(tr [A-Z] [a-z] <<< "$(System.PullRequest.IsFork)")" + ./compileOSX.sh $VERSION $(Build.BuildNumber) $SKIP_CODESIGN displayName: 'Build' - task: CopyFiles@2 inputs: diff --git a/compileOSX.sh b/compileOSX.sh index 619b0d6a..e28f47eb 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 @@ -35,7 +37,36 @@ 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/ + +if [ "$SKIP_CODESIGN" = false ]; then + ./signapps.sh +fi + +echo "Preparing apps for release, Done." echo "Copying to destination folder" dest="YACReader-$VERSION.$BUILD_NUMBER MacOSX-Intel" @@ -61,6 +92,9 @@ 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" -codesign --force --deep --sign "Developer ID Application: LUIS ANGEL SAN MARTIN ROD (9B6KKVW3WM)" "./${dest}.dmg" +if [ "$SKIP_CODESIGN" = false ]; then + echo "Signing dmg" + codesign --force --deep --sign "Developer ID Application: LUIS ANGEL SAN MARTIN ROD (9B6KKVW3WM)" "./${dest}.dmg" +fi echo "Done!" 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." - 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