diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c369aacb6..9e8666981 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -23,18 +23,11 @@ env: jobs: backend_bench: - name: Backend Benchmarks - strategy: matrix: - os: - - ubuntu-20.04 - - macos-11 - - windows-2019 - + os: [ ubuntu-20.04, macos-11, windows-2019 ] runs-on: ${{ matrix.os }} - steps: - name: Checkout source @@ -107,11 +100,8 @@ jobs: run: cargo make backend-benches checks: - name: Code Quality Checks - runs-on: ubuntu-20.04 - steps: - name: Checkout source uses: actions/checkout@v2 @@ -155,12 +145,10 @@ jobs: - name: Install ImageMagick shell: bash - run: | - cargo make install-imagemagick + run: cargo make install-imagemagick - name: Set up python builder - run: | - cargo make setup-builder + run: cargo make setup-builder env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -186,710 +174,33 @@ jobs: retry_on: error command: cargo make tests - build: - - name: Build Binaries - - needs: - - checks - - backend_bench - - strategy: - matrix: - os: - - {name: ubuntu-20.04, exe_suffix: "", short_name: "linux"} - - {name: macos-11, exe_suffix: "", short_name: "macos"} - - {name: windows-2019, exe_suffix: ".exe", short_name: "windows"} - - runs-on: ${{ matrix.os.name }} - - steps: - - - name: Checkout source - uses: actions/checkout@v2 - with: - submodules: recursive - ssh-key: ${{ secrets.SSH_KEY }} - ssh-strict: false - - - uses: webfactory/ssh-agent@v0.5.0 - with: - ssh-private-key: ${{ secrets.SSH_KEY }} - - - name: Run ssh-keyscan - run: ssh-keyscan github.com >> ~/.ssh/known_hosts - - - name: Setup SSH for Windows Git LFS - run: | - & "C:\\Program Files\\Git\\bin\\sh.exe" -c "ssh-keyscan github.com >> ~/.ssh/known_hosts" - & "C:\\Program Files\\Git\\bin\\sh.exe" -c "echo '${{ secrets.SSH_KEY }}' >> ~/.ssh/id_rsa" - if: matrix.os.name == 'windows-2019' - - - name: Install ${{ runner.os }} Dependencies. - shell: bash - run: | - if [ "$RUNNER_OS" == "Linux" ]; then - sudo apt-get update - sudo apt-get install -y \ - capnproto \ - libxcb-icccm4 \ - libxcb-image0 \ - libxcb-keysyms1 \ - libxcb-randr0 \ - libxcb-render-util0 \ - libxcb-render0 \ - libxcb-shape0 \ - libxcb-shm0 \ - libxcb-sync1 \ - libxcb-util1 \ - libxcb-xfixes0 \ - libxcb-xinerama0 \ - libxcb-xkb1 \ - libxkbcommon-x11-0 \ - ruby \ - ruby-dev \ - rubygems \ - build-essential \ - libudev-dev \ - libssl-dev - sudo gem install public_suffix -v 4.0.7 # This is a fix for U18. - sudo gem install --no-document fpm - elif [ "$RUNNER_OS" == "macOS" ]; then - brew install capnp llvm create-dmg - elif [ "$RUNNER_OS" == "Windows" ]; then - choco install capnproto nsis - echo "LIBCLANG_PATH=${{ env.LIBCLANG_PATH_WIN }}" >> $GITHUB_ENV - fi - - - name: Install stable Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - override: true - components: rustfmt, clippy - - - uses: Swatinem/rust-cache@v1 - with: - key: ${{ secrets.CACHE_VERSION }} - - - uses: davidB/rust-cargo-make@v1 - with: - version: ${{ env.CARGO_MAKE_VERSION }} - - - name: Install ImageMagick - shell: bash - run: cargo make install-imagemagick - - - name: Cache pip - uses: actions/cache@v2 - with: - path: ${{ env.PIP_CACHE_DIR }} - key: ${{ runner.os }}-pyproject-toml-${{ secrets.CACHE_VERSION }}-${{ hashFiles('pyproject.toml') }} - - - name: Pull Git LFS objects - run: git lfs pull - env: - GIT_SSH_COMMAND: ssh -o StrictHostKeyChecking=no - - - name: Set up python builder - shell: bash - run: cargo make setup-builder - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Store git tag vars. - shell: bash - run: echo "VERSION=${GITHUB_REF##*/}" >> $GITHUB_ENV - - - name: Build ${{ runner.os }} Binaries. - shell: bash - run: cargo make create-dist - - - name: Create ${{ runner.os }} Installers. - shell: bash - run: | - cargo make dist-to-installer - if [ "$RUNNER_OS" == "Linux" ]; then - INSTALLER_ARCHIVE=$(find installers/Linux -maxdepth 1 -iname "*.deb") - elif [ "$RUNNER_OS" == "Windows" ]; then - INSTALLER_ARCHIVE=$(find installers/Windows -maxdepth 1 -iname "*.exe") - elif [ "$RUNNER_OS" == "macOS" ]; then - mv installers/macOS/*.dmg . - INSTALLER_ARCHIVE=$(find . -maxdepth 1 -iname "*.dmg") - fi - echo $INSTALLER_ARCHIVE >installer-archive.filename - echo "INSTALLER_ARCHIVE=$(cat installer-archive.filename)" >>$GITHUB_ENV - if: github.event_name == 'push' && contains(github.ref, 'refs/tags') && runner.os == 'Linux' - - - name: Build ${{ runner.os }} swift-files binary. - run: cargo build --release --bin swift-files --no-default-features --features env_logger,indicatif - - - name: Build ${{ runner.os }} swift-settings binary. - run: cargo build --release --bin swift-settings --no-default-features --features env_logger - - - name: Build ${{ runner.os }} swift-updater binary. - run: cargo build --release --bin swift-updater --no-default-features - - - name: Pull Git LFS objects - run: git lfs pull - env: - GIT_SSH_COMMAND: ssh -o StrictHostKeyChecking=no - - name: Archive ${{ runner.os }} Binaries. - env: - OS_NAME: ${{ runner.os }} - shell: bash - run: | - mkdir bench - cp -r console_backend/tests/data bench - cp utils/bench_runner.py bench - cd bench - 7z a -tzip "../$OS_NAME.zip" *; - cd .. - echo "${OS_NAME}.zip" >bench-archive.filename; - echo "BENCH_ARCHIVE=$(cat bench-archive.filename)" >>$GITHUB_ENV - RELEASE_ARCHIVE=$(find . -maxdepth 1 -iname "*.tar.xz" ! -iname "*-debug*") - DEBUG_ARCHIVE=$(find . -maxdepth 1 -iname "*-debug.tar.xz") - echo $RELEASE_ARCHIVE >release-archive.filename - echo "RELEASE_ARCHIVE=$(cat release-archive.filename)" >>$GITHUB_ENV - echo $DEBUG_ARCHIVE >debug-archive.filename - echo "DEBUG_ARCHIVE=$(cat debug-archive.filename)" >>$GITHUB_ENV - - uses: actions/upload-artifact@v2 - with: - name: ${{ runner.os }}-artifacts - path: | - ${{ env.RELEASE_ARCHIVE }} - release-archive.filename - - uses: actions/upload-artifact@v2 - with: - name: swift-files_${{ matrix.os.short_name }} - path: ./target/release/swift-files${{ matrix.os.exe_suffix }} - - uses: actions/upload-artifact@v2 - with: - name: swift-settings_${{ matrix.os.short_name }} - path: ./target/release/swift-settings${{ matrix.os.exe_suffix }} - - uses: actions/upload-artifact@v2 - with: - name: swift-updater_${{ matrix.os.short_name }} - path: ./target/release/swift-updater${{ matrix.os.exe_suffix }} - - uses: actions/upload-artifact@v2 - with: - name: ${{ runner.os }}-installer - path: | - ${{ env.INSTALLER_ARCHIVE }} - installer-archive.filename - if: github.event_name == 'push' && contains(github.ref, 'refs/tags') && runner.os == 'Linux' - - uses: actions/upload-artifact@v2 - with: - name: ${{ runner.os }}-artifacts-debug - path: | - ${{ env.DEBUG_ARCHIVE }} - debug-archive.filename - - uses: actions/upload-artifact@v2 - with: - name: ${{ runner.os }}-artifacts-bench - path: | - ${{ env.BENCH_ARCHIVE }} - bench-archive.filename - - name: ${{ runner.os }} Installer Size Benchmark. - env: - OS_NAME: ${{ runner.os }} - shell: bash - continue-on-error: true - run: cargo make disk-usage-bench - - sign_application: - name: Sign Application - timeout-minutes: 30 - needs: - - build - if: github.event_name == 'push' && contains(github.ref, 'refs/tags') - strategy: - matrix: - os: - - macOS - - Windows - runs-on: [self-hosted, '${{ matrix.os }}', code-signer] - steps: - - - name: Remove previous build. - shell: bash - continue-on-error: true - run: rm -rf application - - - name: Checkout source. - uses: actions/checkout@v2 - with: - path: application - lfs: true - - - uses: actions/download-artifact@v2 - with: - name: ${{ matrix.os }}-artifacts - path: application - - - name: Unzip release artifact. - shell: bash - run: | - cd application - mkdir -p py39-dist - if [ "$RUNNER_OS" == "Windows" ]; then - 7z x -so $(cat release-archive.filename) | 7z x -ttar -si -y -opy39-dist - elif [ "$RUNNER_OS" == "macOS" ]; then - tar -xvf "$(cat release-archive.filename)" -C py39-dist - fi - - - name: Build .app bundle. - shell: bash - run: | - cd application - cargo make dist-to-installer-app - if: matrix.os == 'macOS' - - - name: Sign application (${{ matrix.os }}). - shell: bash - run: | - cd "application/target/installer/Swift Console.app" - - for f in $(find Contents/Resources/lib/ -name '*.dylib' -or -name '*.so') - do - codesign -vvvv \ - -s "${{ secrets.APPLE_DEVELOPER_ID }}" \ - --timestamp \ - "$f" - done - - for f in $(ls -d Contents/Resources/lib/python3.9/site-packages/**/Qt/lib/*.framework/Versions/A/*) - do - codesign -vvvv \ - -s "${{ secrets.APPLE_DEVELOPER_ID }}" \ - --timestamp \ - "$f" - done - - cd ../../../ - - codesign -vvvv \ - -s "${{ secrets.APPLE_DEVELOPER_ID }}" --deep \ - --entitlements installers/macOS/entitlements.plist \ - --timestamp \ - --options=runtime \ - "target/installer/Swift Console.app" - if: matrix.os == 'macOS' - - - name: Sign application (${{ matrix.os }}). - shell: cmd - run: | - cd application - "${{ env.CODE_SIGNER_PATH_WIN }}" sign ^ - /debug /v /td SHA256 ^ - /n "Swift Navigation, Inc." /a ^ - /tr http://rfc3161timestamp.globalsign.com/advanced ^ - py39-dist/swift-console.exe - if: matrix.os == 'Windows' - - - name: Create Installer (${{ matrix.os }}) - shell: bash - run: | - cd application - cargo make store-version - if [ "$RUNNER_OS" == "Windows" ]; then - cargo make dist-to-installer - elif [ "$RUNNER_OS" == "macOS" ]; then - cargo make dist-to-installer-dmg - fi - - - name: Add archive to path. - shell: bash - run: | - if [ "$RUNNER_OS" == "Windows" ]; then - INSTALLER_ARCHIVE="$(dir application/installers/Windows/*.exe)" - elif [ "$RUNNER_OS" == "macOS" ]; then - mv application/installers/macOS/*.dmg application - INSTALLER_ARCHIVE=$(find application -maxdepth 1 -iname "*.dmg") - fi - echo $INSTALLER_ARCHIVE >installer-archive.filename - echo "INSTALLER_ARCHIVE=$(cat installer-archive.filename)" >>$GITHUB_ENV - - - name: Sign installer (macOS) - if: matrix.os == 'macOS' - shell: bash - run: | - codesign -vvvv \ - -s "${{ secrets.APPLE_DEVELOPER_ID }}" \ - -f --timestamp \ - $(cat installer-archive.filename) - - xcrun altool \ - --verbose \ - --notarize-app \ - --file $(cat installer-archive.filename) \ - --primary-bundle-id ${{ env.APP_BUNDLE_ID }} \ - --apiKey ${{ secrets.APPLE_KEY_ID }} \ - --apiIssuer ${{ secrets.APPLE_ISSUER_ID }} | tee notarize.log - - REQUEST_UUID=$(cat notarize.log | grep RequestUUID | awk '{print $3}') - - echo "REQUEST_UUID=$REQUEST_UUID" >>$GITHUB_ENV - - - name: Check notarization (macOS) - if: matrix.os == 'macOS' - uses: nick-invision/retry@v2 - with: - shell: bash - timeout_minutes: 3 - retry_wait_seconds: 120 - max_attempts: 10 - retry_on: error - command: | - xcrun altool \ - --verbose \ - --notarization-info ${{ env.REQUEST_UUID }} \ - --apiKey ${{ secrets.APPLE_KEY_ID }} \ - --apiIssuer ${{ secrets.APPLE_ISSUER_ID }} | tee notarize_status.log - - NOTARIZATION_STATUS=$(cat notarize_status.log | grep Status: | awk '{print $2}') - if [ $NOTARIZATION_STATUS == "success" ]; then - echo "Notarization Successful" - else - echo "Notarization Failed" - exit 1 - fi - - xcrun stapler staple -v "$(cat installer-archive.filename)" - - - name: Sign NSIS installer (Windows) - if: matrix.os == 'Windows' - shell: cmd - run: | - set /p executable=> $GITHUB_ENV - - - name: Remove previous build. - shell: bash - continue-on-error: true - run: rm -rf binaries - - - uses: actions/download-artifact@v2 - with: - name: swift-${{ matrix.type }}_${{ matrix.os.short_name }} - path: binaries - - - name: Add version to binary names. - shell: bash - working-directory: binaries - run: | - mv swift-${{ matrix.type }}${{ matrix.os.exe_suffix }} swift-${{ matrix.type }}_${{ env.VERSION }}_${{ matrix.os.short_name }}${{ matrix.os.exe_suffix }} - - - name: Sign Binaries. - shell: cmd - run: | - "${{ env.CODE_SIGNER_PATH_WIN }}" sign ^ - /debug /v /td SHA256 ^ - /n "Swift Navigation, Inc." /a ^ - /tr http://rfc3161timestamp.globalsign.com/advanced ^ - binaries/swift-${{ matrix.type }}_${{ env.VERSION }}_${{ matrix.os.short_name }}${{ matrix.os.exe_suffix }} - if: matrix.os.name == 'Windows' - - - name: Sign Binaries. - shell: bash - working-directory: binaries - run: | - codesign -vvvv \ - -s "${{ secrets.APPLE_DEVELOPER_ID }}" \ - --timestamp \ - --options=runtime \ - swift-${{ matrix.type }}_${{ env.VERSION }}_${{ matrix.os.short_name }}${{ matrix.os.exe_suffix }} - if: matrix.os.name == 'macOS' - - - name: Add executable permission. - shell: bash - working-directory: binaries - run: | - chmod +x swift-${{ matrix.type }}_${{ env.VERSION }}_${{ matrix.os.short_name }}${{ matrix.os.exe_suffix }} - if: matrix.os.name != 'Windows' - - - uses: actions/upload-artifact@v2 - with: - name: swift-${{ matrix.type }}_${{ matrix.os.short_name }}-signed - path: binaries/swift-${{ matrix.type }}_${{ env.VERSION }}_${{ matrix.os.short_name }}${{ matrix.os.exe_suffix }} - - zip_binaries: - name: Zip Binaries - timeout-minutes: 10 - needs: - - sign_binaries - strategy: - matrix: - os: - - { name: macOS, short_name: "macos" } - - { name: Windows, short_name: "windows" } - - { name: Linux, short_name: "linux" } + frontend_distribute: + name: Run frontend benchmarks, build, sign and distribute + needs: [ checks, backend_bench ] runs-on: ubuntu-latest steps: - - name: Store git tag vars. - shell: bash - run: | - echo "VERSION=${GITHUB_REF##*/}" >> $GITHUB_ENV - - - name: Pull swift-files - uses: actions/download-artifact@v2 - with: - name: swift-files_${{ matrix.os.short_name }}-signed - path: ${{ matrix.os.short_name }} - - name: Pull swift-settings - uses: actions/download-artifact@v2 - with: - name: swift-settings_${{ matrix.os.short_name }}-signed - path: ${{ matrix.os.short_name }} - - name: Pull swift-updater - uses: actions/download-artifact@v2 - with: - name: swift-updater_${{ matrix.os.short_name }}-signed - path: ${{ matrix.os.short_name }} - - - name: Zip Binaries. - shell: bash - working-directory: ${{ matrix.os.short_name }} - run: 7z a -tzip "../swift-binaries_${{ matrix.os.short_name }}_${{ env.VERSION }}-all.zip" - - - uses: actions/upload-artifact@v2 - with: - name: swift-binaries_${{ matrix.os.short_name }}-all - path: swift-binaries_${{ matrix.os.short_name }}_${{ env.VERSION }}-all.zip - if: matrix.os.name == 'macOS' - - - uses: actions/upload-artifact@v2 - with: - name: swift-binaries_${{ matrix.os.short_name }}-signed - path: swift-binaries_${{ matrix.os.short_name }}_${{ env.VERSION }}-all.zip - if: matrix.os.name != 'macOS' - - sign_zipped_binaries: - name: Sign Zipped Binaries - timeout-minutes: 10 - needs: - - zip_binaries - strategy: - matrix: - os: - - { name: macOS, short_name: "macos" } - runs-on: [self-hosted, '${{ matrix.os.name }}', code-signer] - steps: - - name: Store git tag vars. - shell: bash - run: | - echo "VERSION=${GITHUB_REF##*/}" >> $GITHUB_ENV + - shell: bash + if: github.event_name == 'push' && contains(github.ref, 'refs/tags') + run: echo "SHOULD_RELEASE=true" >> $GITHUB_ENV - - name: Pull zipped binaries - uses: actions/download-artifact@v2 - with: - name: swift-binaries_${{ matrix.os.short_name }}-all - path: binaries-all - - - name: Sign Binaries. - shell: bash - working-directory: binaries-all - run: | - - codesign -vvvv \ - -s "${{ secrets.APPLE_DEVELOPER_ID }}" \ - -f --timestamp "swift-binaries_${{ matrix.os.short_name }}_${{ env.VERSION }}-all.zip" - - xcrun altool \ - --verbose \ - --notarize-app \ - --file swift-binaries_${{ matrix.os.short_name }}_${{ env.VERSION }}-all.zip\ - --primary-bundle-id ${{ env.APP_BUNDLE_ID }} \ - --apiKey ${{ secrets.APPLE_KEY_ID }} \ - --apiIssuer ${{ secrets.APPLE_ISSUER_ID }} + - shell: bash + run: echo "VERSION=${GITHUB_REF##*/}" >> $GITHUB_ENV - - uses: actions/upload-artifact@v2 - with: - name: swift-binaries_${{ matrix.os.short_name }}-signed - path: binaries-all/swift-binaries_${{ matrix.os.short_name }}_${{ env.VERSION }}-all.zip - - release: - name: Create Release - needs: - - sign_zipped_binaries - - sign_application - if: github.event_name == 'push' && contains(github.ref, 'refs/tags') - runs-on: ubuntu-20.04 - steps: - - name: Store git tag and date vars. - run: | - DATE="$(date '+%Y-%m-%d')"; - echo "DATE=${DATE}" >> $GITHUB_ENV - echo "VERSION=${GITHUB_REF##*/}" >> $GITHUB_ENV - - name: Pull Windows Installer - uses: actions/download-artifact@v2 - with: - name: Windows-installer - path: windows - - name: Pull Windows Binaries - uses: actions/download-artifact@v2 - with: - name: swift-binaries_windows-signed - path: windows - - name: Pull Linux Installer - uses: actions/download-artifact@v2 - with: - name: Linux-installer - path: linux - - name: Pull Linux Binaries - uses: actions/download-artifact@v2 - with: - name: swift-binaries_linux-signed - path: linux - - name: Pull macOS Installer - uses: actions/download-artifact@v2 - with: - name: macOS-installer - path: macos - - name: Pull macOS Binaries - uses: actions/download-artifact@v2 - with: - name: swift-binaries_macos-signed - path: macos - - name: Prepare Release - shell: bash - run: | - echo "WINDOWS_ARCHIVE=$(cat windows/installer-archive.filename)" >>$GITHUB_ENV - echo "LINUX_ARCHIVE=$(cat linux/installer-archive.filename)" >>$GITHUB_ENV - echo "MACOS_ARCHIVE=$(cat macos/installer-archive.filename)" >>$GITHUB_ENV - - name: Release - uses: softprops/action-gh-release@v1 - with: - name: "${{ env.VERSION }}-${{ env.DATE }}" - files: | - windows/${{ env.WINDOWS_ARCHIVE }} - windows/swift-binaries_windows_${{ env.VERSION }}-all.zip - linux/${{ env.LINUX_ARCHIVE }} - linux/swift-binaries_linux_${{ env.VERSION }}-all.zip - macos/${{ env.MACOS_ARCHIVE }} - macos/swift-binaries_macos_${{ env.VERSION }}-all.zip - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - uses: convictional/trigger-workflow-and-wait@v1.6.1 + with: + owner: swift-nav + repo: swift-toolbox-ci + ref: main + workflow_file_name: distribute.yml + client_payload: '{ + "branch": "${{ github.ref_name }}", + "run_id": "${{ github.run_id }}", + "should_release": "${{ env.SHOULD_RELEASE || false}}", + "version": "${{ env.VERSION }}", + "pr_number": "${{ github.event.number }}" + }' + github_user: ${{ secrets.GH_NAME }} + github_token: ${{ secrets.GH_TOKEN }} + propagate_failure: true + wait_workflow: true + trigger_workflow: true