diff --git a/.github/workflows/windows-build-tools.yml b/.github/workflows/windows-build-tools.yml index 54367cf..009295e 100644 --- a/.github/workflows/windows-build-tools.yml +++ b/.github/workflows/windows-build-tools.yml @@ -11,35 +11,67 @@ on: jobs: msys2: name: >- - msys2 tools + ${{ matrix.os }} msys2 tools #env: # FORCE_UPDATE: true - runs-on: windows-2022 + permissions: + contents: write + runs-on: ${{ matrix.os }} strategy: fail-fast: false + matrix: + include: + - { os: windows-2022, ruby: ucrt, type: ucrt64, windows-toolchain: default } + - { os: windows-11-arm, ruby: 3.4, type: clangarm64, windows-toolchain: none } steps: - name: Checkout uses: actions/checkout@v4 + - name: Set platform + id: platform + run: | + platform=${{ matrix.os }} + platform=${platform/windows-2022/windows-latest} + platform=${platform/%-arm/-arm64} + echo "platform=$platform" >> $GITHUB_OUTPUT + shell: bash + - name: Copy msys2 files to temp dir + if: matrix.windows-toolchain == 'default' run: | $temp = $env:RUNNER_TEMP md $temp\msys64 # copy current msys2 to temp folder, needed to determine what files to include # in zip file (only newer files) xcopy C:\msys64 $temp\msys64 /s /q + + - name: Install msys2 + if: matrix.windows-toolchain == 'none' + run: | + (New-Object System.Net.WebClient).DownloadFile("https://repo.msys2.org/distrib/msys2-x86_64-latest.sfx.exe", "msys2-x86_64-latest.sfx.exe") + (New-Object System.Net.WebClient).DownloadFile("https://repo.msys2.org/distrib/msys2-x86_64-latest.sfx.exe.sig", "msys2-x86_64-latest.sfx.exe.sig") + gpg --keyserver keyserver.ubuntu.com --recv "0EBF 782C 5D53 F7E5 FB02 A667 46BD 761F 7A49 B0EC" + gpg --verify msys2-x86_64-latest.sfx.exe.sig + + .\msys2-x86_64-latest.sfx.exe -y -oC:\ + + C:\msys64\msys2_shell.cmd -defterm -here -no-start -${{ matrix.type }} + + echo "C:\msys64\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + echo "C:\msys64\${{ matrix.type }}\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append timeout-minutes: 15 - name: Set up Ruby - uses: ruby/setup-ruby@v1 + uses: ntkme/setup-ruby@windows-11-arm-dev with: - ruby-version: ucrt + ruby-version: ${{ matrix.ruby }} + windows-toolchain: ${{ matrix.windows-toolchain }} timeout-minutes: 7 - name: Update msys2 tools 7z and Upload - run: ruby create_msys2_pkg.rb + run: ruby create_msys2_pkg.rb msys2-${{ steps.platform.outputs.platform }} env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ github.token }} timeout-minutes: 10 gcc-mingw: @@ -49,6 +81,8 @@ jobs: ${{ matrix.gcc }} gcc #env: # FORCE_UPDATE: true + permissions: + contents: write runs-on: windows-2022 strategy: fail-fast: false @@ -69,16 +103,18 @@ jobs: - name: Update ${{ matrix.gcc }} gcc 7z and Upload run: ruby create_gcc_pkg.rb ${{ matrix.gcc }} env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ github.token }} timeout-minutes: 13 gcc-ucrt: if: ${{ always() }} - needs: gcc-mingw + needs: msys2 name: >- ${{ matrix.gcc }} gcc #env: # FORCE_UPDATE: true + permissions: + contents: write runs-on: windows-2022 strategy: fail-fast: false @@ -99,6 +135,37 @@ jobs: - name: Update ${{ matrix.gcc }} gcc 7z and Upload run: ruby create_gcc_pkg.rb ${{ matrix.gcc }} env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ github.token }} + timeout-minutes: 13 + + gcc-clangarm64: + if: ${{ always() }} + needs: msys2 + name: >- + ${{ matrix.gcc }} gcc + #env: + # FORCE_UPDATE: true + permissions: + contents: write + runs-on: windows-11-arm + strategy: + fail-fast: false + matrix: + include: + - { gcc: clangarm64-3.0 , ruby: 3.4 } + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Ruby + uses: ntkme/setup-ruby@windows-11-arm-dev + with: + ruby-version: ${{ matrix.ruby }} + timeout-minutes: 7 + + - name: Update ${{ matrix.gcc }} gcc 7z and Upload + run: ruby create_gcc_pkg.rb ${{ matrix.gcc }} + env: + GITHUB_TOKEN: ${{ github.token }} timeout-minutes: 13 diff --git a/common.rb b/common.rb index a4a0c50..3729f3c 100644 --- a/common.rb +++ b/common.rb @@ -34,16 +34,9 @@ module Common PACMAN = 'C:/msys64/usr/bin/pacman.exe' BASH = 'C:/msys64/usr/bin/bash.exe' - SSL_3_SAVE_FILES = %w[ - bin/libcrypto-3-x64.dll - bin/libssl-3-x64.dll - etc/ssl/openssl.cnf - ] - def gh_api_graphql(http, query) body = {} body["query"] = query - response = nil req = Net::HTTP::Post.new '/gh_api_graphql' req['Authorization'] = "Bearer #{TOKEN}" @@ -315,12 +308,12 @@ def refresh_keys system 'taskkill /f /fi "MODULES eq msys-2.0.dll"' STDOUT.syswrite "#{str}\n#{END_GROUP}" - + str.match?(/new signatures:|signatures cleaned:/) ? true : nil end def pacman_syuu(ignore = nil) - + usr_bin = "#{MSYS2_ROOT}/usr/bin" exit 1 unless system "#{usr_bin}/sed -i 's/^CheckSpace/#CheckSpace/g' C:/msys64/etc/pacman.conf" diff --git a/create_gcc_pkg.rb b/create_gcc_pkg.rb index 5c82c11..fde5956 100644 --- a/create_gcc_pkg.rb +++ b/create_gcc_pkg.rb @@ -38,14 +38,26 @@ class << self ['mingw64', 'mingw-w64-x86_64-'] when 'mingw32' ['mingw32', 'mingw-w64-i686-'] + when 'clangarm64' + ['clangarm64', 'mingw-w64-clang-aarch64-'] else - STDOUT.syswrite "Invalid package type, must be ucrt64, mingw64, or mingw32\n" + STDOUT.syswrite "Invalid package type, must be ucrt64, mingw64, mingw32, or clangarm64\n" exit 1 end MSYS2_PKG = "#{MSYS2_ROOT}/#{PKG_DIR}" - - SSL_1_DLLS = %w[bin/libcrypto-1_1-x64.dll bin/libssl-1_1-x64.dll] + + SSL_1_DLLS = if PKG_DIR == 'clangarm64' + %w[bin/libcrypto-1_1.dll bin/libssl-1_1.dll] + else + %w[bin/libcrypto-1_1-x64.dll bin/libssl-1_1-x64.dll] + end + + SSL_3_SAVE_FILES = if PKG_DIR == 'clangarm64' + %w[bin/libcrypto-3.dll bin/libssl-3.dll etc/ssl/openssl.cnf] + else + %w[bin/libcrypto-3-x64.dll bin/libssl-3-x64.dll etc/ssl/openssl.cnf] + end def add_ri2_key # appveyor ri2 package signing key @@ -85,11 +97,9 @@ def openssl_upgrade pkg_name = "openssl-3.0.7-1-any.pkg.tar.zst" pkg = "https://github.com/oneclick/rubyinstaller2-packages/releases/download/ci.ri2/#{PKG_PRE}#{pkg_name}" pkg_sig = "#{pkg}.sig" - old_dlls = %w[libcrypto-1_1-x64.dll libssl-1_1-x64.dll] - dll_root = "#{MSYS2_ROOT}/#{PKG_DIR}/bin" # save previous dll files so we can copy back into folder - old_dlls.each { |fn| FileUtils.cp "#{dll_root}/#{fn}", "." } + SSL_1_DLLS.each { |fn| FileUtils.cp "#{MSYS2_PKG}/#{fn}", "." } download pkg , "./#{PKG_PRE}#{pkg_name}" download pkg_sig, "./#{PKG_PRE}#{pkg_name}.sig" @@ -98,11 +108,7 @@ def openssl_upgrade exec_check "Install OpenSSL Upgrade", "pacman.exe -Udd --noconfirm --noprogressbar #{PKG_PRE}#{pkg_name}" # copy previous dlls back into MSYS2 folder - old_dlls.each do |fn| - unless File.exist? "#{dll_root}/#{fn}" - FileUtils.cp fn , "#{dll_root}/#{fn}" - end - end + SSL_1_DLLS.each { |fn| FileUtils.cp_r File.basename(fn) , "#{MSYS2_PKG}/#{fn}" } end # Below files are part of the 'ca-certificates' package, they are not @@ -142,7 +148,7 @@ def install_gcc # Note that OpenSSL may need to be ignored if PKG_NAME.end_with?('-3.0') pacman_syuu - else + else pacman_syuu end diff --git a/create_mswin_pkg.rb b/create_mswin_pkg.rb index 8c08e0d..eed7e4d 100644 --- a/create_mswin_pkg.rb +++ b/create_mswin_pkg.rb @@ -60,7 +60,7 @@ def generate_package_files Dir.chdir VCPKG do |d| install_info = %x(./vcpkg install #{PACKAGES} --triplet=x64-windows --dry-run) - + installed_packages = install_info.include?('The following packages will be built and installed') exec_check "Installing #{PACKAGES}", @@ -101,7 +101,7 @@ def generate_package_files def run generate_package_files - + copy_ssl_files # create 7z archive file diff --git a/create_msys2_pkg.rb b/create_msys2_pkg.rb index 2afcb5e..aea1a66 100644 --- a/create_msys2_pkg.rb +++ b/create_msys2_pkg.rb @@ -21,8 +21,22 @@ class << self LOCAL = 'var/lib/pacman/local' CACHE = 'var/cache/pacman/pkg' - MSYS2_PKG = RUBY_PLATFORM.include?('ucrt') ? - "#{MSYS2_ROOT}/ucrt64" : "#{MSYS2_ROOT}/mingw64" + MSYS2_PKG = case RUBY_PLATFORM + when 'aarch64-mingw-ucrt' + "#{MSYS2_ROOT}/clangarm64" + when /ucrt$/ + "#{MSYS2_ROOT}/ucrt64" + else + "#{MSYS2_ROOT}/mingw64" + end + + PKG_NAME = ARGV[0].downcase + + SSL_3_SAVE_FILES = %w[ + bin/libcrypto-3-x64.dll + bin/libssl-3-x64.dll + etc/ssl/openssl.cnf + ] def update_msys2 @@ -101,8 +115,6 @@ def run log_array_2_column updated_pkgs, 48, "Installed MSYS2 Packages" - gpg_files = Dir["#{MSYS2_ROOT}/etc/pacman.d/gnupg/*"].count { |fn| File.file? fn } - if current_pkgs == updated_pkgs && !updated_keys && !ENV.key?('FORCE_UPDATE') STDOUT.syswrite "\n** No update to MSYS2 tools needed **\n\n" exit 0 @@ -110,20 +122,27 @@ def run STDOUT.syswrite "\n#{GRN}** Creating and Uploading MSYS update 7z **#{RST}\n\n" end - remove_non_msys2 - remove_duplicate_files - clean_database 'msys' - clean_packages + exec_check "Remove all uninstalled packages" , "#{BASH} -c \"paccache -r -f -u -k0\"" + exec_check "Keep the newest for all other packages" , "#{BASH} -c \"paccache -r -f -k1\"" + exec_check "Remove all cached packages" , "#{PACMAN} -Scc --noconfirm" + + # create a delta package for existing mysys installation on the runner + if File.exist?(ORIG_MSYS2) + remove_non_msys2 + remove_duplicate_files + clean_database 'msys' + clean_packages + end # create 7z file STDOUT.syswrite "##[group]#{YEL}Create msys2 7z file#{RST}\n" - tar_path = "#{Dir.pwd}\\msys2.7z".gsub '/', '\\' + tar_path = "#{Dir.pwd}\\#{PKG_NAME}.7z".gsub '/', '\\' Dir.chdir MSYS2_ROOT do exit 1 unless system "\"#{SEVEN}\" a #{tar_path}" end STDOUT.syswrite "##[endgroup]\n" - upload_7z_update 'msys2', time + upload_7z_update PKG_NAME, time end end end