Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 56 additions & 13 deletions .github/workflows/windows-build-tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,43 @@ on:
jobs:
msys2:
name: >-
msys2 tools
${{ matrix.name }} tools
#env:
# FORCE_UPDATE: true
runs-on: windows-2022
permissions:
contents: write
Comment on lines +17 to +18
Copy link
Contributor Author

@ntkme ntkme Apr 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHub now blocks user from adding new secret starting with GITHUB in name, which is a pain for me to test in my fork. Switch to custom permission + github.token allows me to run this on my fork more easily without adding a secret GITHUB_TOKEN. Also note that even if the write permission is requested, it will not be granted to PRs (similar to how secret works), so there isn't a security concern.

runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- { os: windows-2022, ruby: ucrt, name: msys2 }
- { os: windows-11-arm, ruby: 3.4, name: msys2-arm64 }
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Copy msys2 files to temp dir
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
if (Test-Path -LiteralPath C:\msys64 -PathType Container) {
$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
}
timeout-minutes: 15

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ucrt
ruby-version: ${{ matrix.ruby }}
timeout-minutes: 7

- name: Update msys2 tools 7z and Upload
run: ruby create_msys2_pkg.rb
run: ruby create_msys2_pkg.rb ${{ matrix.name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ github.token }}
timeout-minutes: 10

gcc-mingw:
Expand All @@ -49,6 +57,8 @@ jobs:
${{ matrix.gcc }} gcc
#env:
# FORCE_UPDATE: true
permissions:
contents: write
runs-on: windows-2022
strategy:
fail-fast: false
Expand All @@ -69,16 +79,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
Expand All @@ -99,6 +111,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: ruby/setup-ruby@v1
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

17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,42 @@ Below summarizes the default MSYS2 installations on Actions Windows images:

| Actions<br/>Image | MSYS<br/>Base | MSYS<br/>Build Tools | mingw64<br/>gcc & tools | mingw64<br/>packages | ucrt64<br/>gcc & tools | ucrt64<br/>packages |
|--------------------|:--------------:|:--------------------:|:-----------------------:|:--------------------:|:----------------------:|:-------------------:|
| **11-arm** | No | No | No | No | No | No |
| **2022 and later** | Yes | No | No | No | No | No |
| **2016, 2019** | Yes | Yes | Yes | Some | No | No |

### Notes

Six package files are stored in a GitHub release, and are used by
Eight package files are stored in a GitHub release, and are used by
[ruby/setup-ruby](https://github.com/ruby/setup-ruby). They are:

* **`msys2.7z`** The base msys2 installation on Actions Windows images contains a minimal
set of bash tools, and no shared build tools. Code updates the MSYS2 files, and saves only
updated files to the 7z. All Ruby Windows releases from version 2.4 and later use these
updated files to the 7z. All Ruby Windows x64 releases from version 2.4 and later use these
tools.

* **`msys2-arm64.7z`** The base msys2 installation on Actions Windows images contains a minimal
set of bash tools, and no shared build tools. Code saves complate base MSYS2 files to the 7z.
All Ruby Windows arm64 releases from version 3.4 and later use these tools.

* **`mingw64.7z`** This contains the mingw64 gcc chain and any packages needed to build
Ruby. This has OpenSSL 1.1.1 installed, as of 26-Apr-2024, 1.1.1.w. Normal Ruby Windows
releases from version 2.4 thru 3.0 use these tools.

* **`mingw64-3.0.7z`** This contains the mingw64 gcc chain and any packages needed to build
Ruby. The MSYS2 OpenSSL 3.3.z package is installed. The mingw Ruby master build is the
Ruby. The MSYS2 OpenSSL 3.y.z package is installed. The mingw Ruby master build is the
only build that uses this.

* **`ucrt64.7z`** This contains the ucrt64 gcc chain and any packages needed to build
Ruby. This has OpenSSL 1.1.1 installed, as of 26-Apr-2024, 1.1.1.w. Ruby version 3.1 is
the only release that uses this.

* **`ucrt64-3.0.7z`** This contains the ucrt64 gcc chain and any packages needed to build
Ruby. The MSYS2 OpenSSL 3.3.z package is installed. Ruby 3.2, head, & ucrt builds use this.
Ruby. The MSYS2 OpenSSL 3.y.z package is installed. Ruby 3.2, head, & ucrt builds use this.

* **`clangarm64-3.0.7z`** This contains the clangarm64 gcc chain and any packages needed to build
Ruby. The MSYS2 OpenSSL 3.y.z package is installed. Ruby 3.4 and head builds on windows arm64
use this.

* **`mswin.7z`** This contains files needed to compile Windows Ruby mswin builds. It contains
libffi, libyaml, openssl, readline, and zlib, built with the Microsoft vcpkg system. This
Expand Down
11 changes: 2 additions & 9 deletions common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down Expand Up @@ -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"
Expand Down
34 changes: 22 additions & 12 deletions create_gcc_pkg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -241,6 +247,10 @@ def run
STDOUT.syswrite "\n#{GRN}** Creating and Uploading #{PKG_DIR} gcc tools 7z **#{RST}\n\n"
end

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"

copy_to_temp

clean_package
Expand Down
4 changes: 2 additions & 2 deletions create_mswin_pkg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}",
Expand Down Expand Up @@ -101,7 +101,7 @@ def generate_package_files

def run
generate_package_files

copy_ssl_files

# create 7z archive file
Expand Down
30 changes: 23 additions & 7 deletions create_msys2_pkg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -101,29 +115,31 @@ 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
else
STDOUT.syswrite "\n#{GRN}** Creating and Uploading MSYS update 7z **#{RST}\n\n"
end

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"

remove_non_msys2
remove_duplicate_files
remove_duplicate_files if File.exist?(ORIG_MSYS2)
clean_database 'msys'
clean_packages

# 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
Expand Down