Remove files that would be ignored by gitignore from releases

This commit is contained in:
John Bintz 2023-04-05 09:43:33 -04:00
parent adb994efe6
commit 0b08c2e258
1 changed files with 30 additions and 23 deletions

View File

@ -6,14 +6,14 @@ require 'erb'
source = File.read('src/BSDSocket.s') source = File.read('src/BSDSocket.s')
aminet_template = ERB.new(File.read("aminet.readme.erb")) aminet_template = ERB.new(File.read('aminet.readme.erb'))
capture_version = false capture_version = false
version = nil version = nil
source.lines.each do |line| source.lines.each do |line|
if capture_version if capture_version
version = line[/dc\.b "([^"]+)"/,1] version = line[/dc\.b "([^"]+)"/, 1]
break break
end end
@ -31,51 +31,58 @@ project_name = 'BSDSocket-Extension'
build_dir = File.join(build_base, project_name) build_dir = File.join(build_base, project_name)
FileUtils.rm_rf build_dir FileUtils.rm_rf build_dir
FileUtils.rm_rf 'aminet'
FileUtils.mkdir_p build_dir FileUtils.mkdir_p build_dir
FileUtils.mkdir_p 'aminet' FileUtils.mkdir_p 'aminet'
hackerbun_target = File.expand_path("dist/AMOSPro_BSDSocket_#{version}.lha") hackerbun_target = File.expand_path("dist/AMOSPro_BSDSocket_#{version}.lha")
[ [
"AMOSPro_BSDSocket.Lib", 'AMOSPro_BSDSocket.Lib',
"README.md", 'README.md',
"API.md", 'API.md',
"LICENSE", 'LICENSE'
].each do |file| ].each do |file|
target = "#{build_dir}/#{file}" target = "#{build_dir}/#{file}"
FileUtils.mkdir_p File.dirname(target) FileUtils.mkdir_p File.dirname(target)
FileUtils.cp file, target FileUtils.cp file, target
end end
[ gitignores = File.readlines('.gitignore').map(&:strip)
"src",
"examples" %w[
src
examples
].each do |dir| ].each do |dir|
FileUtils.cp_r dir, "#{build_dir}/#{dir}" FileUtils.cp_r dir, "#{build_dir}/#{dir}"
Dir["#{build_dir}/#{dir}/**/*"].each do |file|
FileUtils.rm file if gitignores.any? { |gi| File.fnmatch(gi, file) }
end
end end
Dir["icons/**/*.info"].each do |info| Dir['icons/**/*.info'].each do |info|
target = info.gsub("icons/", build_base + "/") target = info.gsub('icons/', build_base + '/')
FileUtils.mkdir_p File.dirname(target) FileUtils.mkdir_p File.dirname(target)
FileUtils.cp info, target FileUtils.cp info, target
end end
Dir.chdir build_base do Dir.chdir build_base do
Open3.popen2e( Open3.popen2e(
"jlha", "c", hackerbun_target, 'jlha', 'c', hackerbun_target,
*(Dir["*"])) do |stdin, stdout_and_stderr, wait_thr| *(Dir['*'])
) do |stdin, stdout_and_stderr, wait_thr|
Thread.new do Thread.new do
stdout_and_stderr.each { |l| puts l } stdout_and_stderr.each { |l| puts l }
end
stdin.close
wait_thr.value
end end
stdin.close
wait_thr.value
end
end end
FileUtils.cp hackerbun_target, "aminet/BSDSocket-Extension.lha" FileUtils.cp hackerbun_target, 'aminet/BSDSocket-Extension.lha'
File.open("aminet/BSDSocket-Extension.readme", "w") do |fh| File.open('aminet/BSDSocket-Extension.readme', 'w') do |fh|
fh.puts aminet_template.result(binding) fh.puts aminet_template.result(binding)
end end