giblish 3.0.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7ec2fb091e00a933c081217c3a82f6b7002f3bffee15f5263ec9dc1f4f6ab128
4
- data.tar.gz: 138dee38cd08e1efe6627635ef6fa110af3e5fa3f9ac96137afcbdf4296aa7e0
3
+ metadata.gz: fc2d44b3987ea014fad53e2accf48aa3734e1ba68c20328506179bf19e41621e
4
+ data.tar.gz: 65b013e0e91895ed2b9d882ff0249111856bbee31db29d72b08242d2cef9b3e6
5
5
  SHA512:
6
- metadata.gz: 7a29d740604e700c77222b570df47119dcafa1c8f074f818d81ea9ce16c13736b9332ade2a04f1a151258b5043fe56e0883537a303438426599e039b526a2eb5
7
- data.tar.gz: 414ac99ae8eed148a2b72453ae092fa5a0721917b5ca5d9cd8de8c0fc2b8c1edb65e92abe3f975f35562bf07e86492eb7781b9e856f0b0b88e2d77afe0d0947f
6
+ metadata.gz: e3cbae7cfd88de2a747dfe27e82bedf52fcb270963c8388a2f1b3e41c4401bd412a536e5d87097ce715c9c5aaf380385d85ee78b0d190669e6be1ffea24f8733
7
+ data.tar.gz: ca512fe02b3b3a172637bfaa955682fedbde866ba943276cc81b8389ff3b40b59e0714702d56752d11d0cf4a0b8413bbf06d371f3550a04b153c286378b0cd00
data/Changelog.adoc CHANGED
@@ -7,6 +7,17 @@
7
7
  ** write instructions for github webhook triggered generation
8
8
  * Update the default css for giblish html generation.
9
9
 
10
+ == v3.0.1
11
+
12
+ * add release scripts
13
+ * fix some linting issues
14
+
15
+ == v3.0.0
16
+
17
+ * break out the pathtree operations into a separate gem (gran)
18
+ * bump ruby version to >= 3.3
19
+ * bump all asciidoctor dependencies to the latest available
20
+
10
21
  == v2.2.2
11
22
 
12
23
  * [BUGFIX] - fix a possible null ref when generating pdfs
data/giblish.gemspec CHANGED
@@ -49,7 +49,7 @@ Gem::Specification.new do |spec|
49
49
  # 'matrix' needed because of incompatibilities between prawn v2.4
50
50
  # and ruby 3.1
51
51
  # sorbet-runtime
52
- spec.add_runtime_dependency "gran", "~> 0.1"
52
+ spec.add_runtime_dependency "gran", "~> 0.1", ">= 0.1.1"
53
53
  # spec.add_runtime_dependency "matrix", "~>0.4"
54
54
  spec.add_runtime_dependency "warning", "~>1.0"
55
55
  spec.add_runtime_dependency "asciidoctor", "~>2.0", ">= 2.0.25"
@@ -27,7 +27,7 @@ module Giblish
27
27
  raise ArgumentError, "The path: #{cmd_opts.srcdir} is not within a git repo!" if @repo_root.nil?
28
28
 
29
29
  @local_only = cmd_opts.local_only
30
- @abort_on_error = cmd_opts.abort_on_error.nil? ? true : cmd_opts.abort_on_error
30
+ @abort_on_error = cmd_opts.abort_on_error.nil? || cmd_opts.abort_on_error
31
31
 
32
32
  @git_repo = init_git_repo(@repo_root, @local_only)
33
33
  @branches = select_user_branches(cmd_opts.branch_regex, @local_only)
@@ -76,7 +76,8 @@ module Giblish
76
76
 
77
77
  # merge branches with their upstream at origin unless
78
78
  # 'only local'
79
- unless (treeish.respond_to?(:tag?) && treeish.tag?) || @local_only
79
+ is_tag = treeish.respond_to?(:tag?) && treeish.tag?
80
+ if !is_tag && !@local_only
80
81
  # this is a branch, make sure it is up-to-date
81
82
  Giblog.logger.info { "Merging with origin/#{treeish.name}" }
82
83
  @git_repo.merge "origin/#{treeish.name}"
@@ -76,11 +76,9 @@ module Giblish
76
76
 
77
77
  #{"Purpose::\n#{node_data.purpose_str}" unless node_data.purpose_str.to_s.empty?}
78
78
 
79
- #{if node_data.stderr.empty?
80
- ""
81
- else
79
+ #{unless node_data.stderr.empty?
82
80
  "Conversion issues::\n"\
83
- "#{node_data.stderr.gsub(/^/, " * ")}"
81
+ "#{node_data.stderr.gsub(/^/, " * ")}"
84
82
  end
85
83
  }
86
84
 
@@ -1,3 +1,3 @@
1
1
  module Giblish
2
- VERSION = "3.0.0".freeze
2
+ VERSION = "3.0.1".freeze
3
3
  end
@@ -0,0 +1,365 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "pathname"
5
+ require "optparse"
6
+ require "fileutils"
7
+
8
+ # Release automation script for giblish gem
9
+ class GiblishReleaseManager
10
+ GIBLISH_DIR = Pathname.new(__dir__).parent
11
+
12
+ VALID_COMMANDS = %w[prepare publish all].freeze
13
+ VALID_VERSION_TYPES = %w[major minor patch].freeze
14
+
15
+ attr_reader :command, :version_type, :dry_run, :yes, :specific_version
16
+
17
+ def initialize(args)
18
+ @dry_run = false
19
+ @yes = false
20
+ @specific_version = nil
21
+ parse_options(args)
22
+ validate_args
23
+ end
24
+
25
+ def run
26
+ puts "\n=== Giblish Release Manager ==="
27
+ puts "Command: #{command}"
28
+ puts "Version: #{version_type || specific_version}"
29
+ puts "Dry-run: #{dry_run}"
30
+ puts "================================\n\n"
31
+
32
+ case command
33
+ when "prepare"
34
+ prepare_release
35
+ when "publish"
36
+ publish_release
37
+ when "all"
38
+ prepare_release
39
+ publish_release
40
+ end
41
+ end
42
+
43
+ private
44
+
45
+ def parse_options(args)
46
+ OptionParser.new do |opts|
47
+ opts.banner = "Usage: release.rb [options] COMMAND [VERSION]"
48
+ opts.separator ""
49
+ opts.separator "COMMAND: #{VALID_COMMANDS.join(", ")}"
50
+ opts.separator "VERSION: #{VALID_VERSION_TYPES.join(", ")} or specific version (e.g., 0.2.0)"
51
+ opts.separator ""
52
+ opts.separator "Options:"
53
+
54
+ opts.on("-n", "--dry-run", "Show what would happen without doing it") do
55
+ @dry_run = true
56
+ end
57
+
58
+ opts.on("-y", "--yes", "Skip confirmation prompts") do
59
+ @yes = true
60
+ end
61
+
62
+ opts.on("-h", "--help", "Show this help message") do
63
+ puts opts
64
+ exit 0
65
+ end
66
+ end.parse!(args)
67
+
68
+ @command = args[0]
69
+
70
+ # Parse version argument
71
+ if args[1]
72
+ if VALID_VERSION_TYPES.include?(args[1])
73
+ @version_type = args[1]
74
+ elsif args[1].match?(/^\d+\.\d+\.\d+$/)
75
+ @specific_version = args[1]
76
+ else
77
+ puts "ERROR: Invalid version '#{args[1]}'. Must be #{VALID_VERSION_TYPES.join(", ")} or a version number (e.g., 0.2.0)"
78
+ exit 1
79
+ end
80
+ end
81
+ end
82
+
83
+ def validate_args
84
+ unless VALID_COMMANDS.include?(command)
85
+ puts "ERROR: Invalid command '#{command}'. Must be one of: #{VALID_COMMANDS.join(", ")}"
86
+ exit 1
87
+ end
88
+
89
+ if command != "publish" && version_type.nil? && specific_version.nil?
90
+ puts "ERROR: VERSION argument required for '#{command}' command"
91
+ exit 1
92
+ end
93
+ end
94
+
95
+ def prepare_release
96
+ puts "\n📦 Preparing giblish for release...\n"
97
+ with_dir(GIBLISH_DIR) do
98
+ run_safety_checks
99
+ check_gran_dependency
100
+ new_version = bump_version(GIBLISH_DIR / "lib/giblish/version.rb")
101
+ update_changelog(new_version)
102
+ build_gem
103
+ create_git_commit_and_tag(new_version)
104
+ success("Giblish prepared for release: v#{new_version}")
105
+ end
106
+ end
107
+
108
+ def publish_release
109
+ puts "\n🚀 Publishing giblish to RubyGems...\n"
110
+ with_dir(GIBLISH_DIR) do
111
+ push_to_github
112
+ publish_gem
113
+ success("Giblish published!")
114
+ end
115
+ end
116
+
117
+ # Safety Checks
118
+ def run_safety_checks
119
+ step("Running safety checks")
120
+ check_git_status
121
+ check_on_main_branch
122
+ run_tests
123
+ run_linter
124
+ end
125
+
126
+ def check_git_status
127
+ output = `git status --porcelain`.strip
128
+ unless output.empty?
129
+ error("Working directory is not clean. Commit or stash changes first.")
130
+ end
131
+ end
132
+
133
+ def check_on_main_branch
134
+ branch = `git rev-parse --abbrev-ref HEAD`.strip
135
+ unless branch == "main"
136
+ unless confirm("You are on branch '#{branch}', not 'main'. Continue anyway?")
137
+ error("Aborted. Switch to main branch or use --yes to override.")
138
+ end
139
+ end
140
+ end
141
+
142
+ def run_tests
143
+ step("Running tests")
144
+ unless system("bundle exec rake test > /dev/null 2>&1")
145
+ error("Tests failed! Fix tests before releasing.")
146
+ end
147
+ end
148
+
149
+ def run_linter
150
+ step("Running linter")
151
+ unless system("bundle exec rake standard > /dev/null 2>&1")
152
+ error("Linter failed! Fix linting issues before releasing.")
153
+ end
154
+ end
155
+
156
+ def check_gran_dependency
157
+ gemspec_path = GIBLISH_DIR / "giblish.gemspec"
158
+ content = File.read(gemspec_path)
159
+
160
+ if content =~ /add_runtime_dependency\s+"gran",\s+"~>\s*([\d.]+)"/
161
+ current_dep = $1
162
+ latest_gran = get_latest_rubygems_version("gran")
163
+
164
+ if latest_gran && Gem::Version.new(latest_gran) > Gem::Version.new(current_dep)
165
+ puts "⚠️ Gran dependency in giblish.gemspec is ~> #{current_dep}"
166
+ puts " Latest gran on RubyGems is #{latest_gran}"
167
+ puts " Consider updating the dependency before releasing."
168
+ unless confirm("Continue with current gran dependency?")
169
+ error("Aborted. Update gran dependency first.")
170
+ end
171
+ end
172
+ end
173
+ end
174
+
175
+ # Version Management
176
+ def bump_version(version_file)
177
+ current_version = extract_version(version_file)
178
+ new_version = calculate_new_version(current_version)
179
+
180
+ puts "Current version: #{current_version}"
181
+ puts "New version: #{new_version}"
182
+
183
+ unless confirm("Bump version to #{new_version}?")
184
+ error("Aborted by user")
185
+ end
186
+
187
+ update_version_file(version_file, current_version, new_version)
188
+ new_version
189
+ end
190
+
191
+ def extract_version(version_file)
192
+ content = File.read(version_file)
193
+ if content =~ /VERSION\s*=\s*"([\d.]+)"/
194
+ $1
195
+ else
196
+ error("Could not find VERSION in #{version_file}")
197
+ end
198
+ end
199
+
200
+ def calculate_new_version(current)
201
+ return specific_version if specific_version
202
+
203
+ parts = current.split(".").map(&:to_i)
204
+ case version_type
205
+ when "major"
206
+ "#{parts[0] + 1}.0.0"
207
+ when "minor"
208
+ "#{parts[0]}.#{parts[1] + 1}.0"
209
+ when "patch"
210
+ "#{parts[0]}.#{parts[1]}.#{parts[2] + 1}"
211
+ end
212
+ end
213
+
214
+ def update_version_file(version_file, old_version, new_version)
215
+ content = File.read(version_file)
216
+ content.gsub!(/VERSION\s*=\s*"#{Regexp.escape(old_version)}"/,
217
+ "VERSION = \"#{new_version}\"")
218
+
219
+ if dry_run
220
+ puts "[DRY-RUN] Would update #{version_file.basename} to #{new_version}"
221
+ else
222
+ File.write(version_file, content)
223
+ puts "✓ Updated #{version_file.basename}"
224
+ end
225
+ end
226
+
227
+ # Changelog
228
+ def update_changelog(version)
229
+ step("Updating CHANGELOG")
230
+ puts "⚠️ Please update the CHANGELOG manually with changes for v#{version}"
231
+ puts "Press Enter when done..."
232
+ $stdin.gets unless yes
233
+ end
234
+
235
+ # Gem Operations
236
+ def build_gem
237
+ step("Building giblish gem")
238
+
239
+ if dry_run
240
+ puts "[DRY-RUN] Would run: gem build giblish.gemspec"
241
+ else
242
+ unless system("gem build giblish.gemspec")
243
+ error("Failed to build gem")
244
+ end
245
+ puts "✓ Gem built successfully"
246
+ end
247
+ end
248
+
249
+ def publish_gem
250
+ gem_file = Dir.glob("giblish-*.gem").max_by { |f| File.mtime(f) }
251
+
252
+ unless gem_file
253
+ error("No gem file found to publish")
254
+ end
255
+
256
+ step("Publishing #{gem_file}")
257
+
258
+ unless confirm("Push #{gem_file} to RubyGems.org?")
259
+ error("Aborted by user")
260
+ end
261
+
262
+ if dry_run
263
+ puts "[DRY-RUN] Would run: gem push #{gem_file}"
264
+ else
265
+ unless system("gem push #{gem_file}")
266
+ error("Failed to publish gem")
267
+ end
268
+ puts "✓ Gem published successfully"
269
+ end
270
+ end
271
+
272
+ # Git Operations
273
+ def create_git_commit_and_tag(version)
274
+ tag_name = "giblish-v#{version}"
275
+ commit_message = "Release giblish v#{version}"
276
+
277
+ step("Creating git commit and tag")
278
+
279
+ if dry_run
280
+ puts "[DRY-RUN] Would run:"
281
+ puts " git add ."
282
+ puts " git commit -m '#{commit_message}'"
283
+ puts " git tag -a #{tag_name} -m '#{commit_message}'"
284
+ else
285
+ system("git add .")
286
+ unless system("git commit -m '#{commit_message}'")
287
+ error("Failed to create commit")
288
+ end
289
+ unless system("git tag -a #{tag_name} -m '#{commit_message}'")
290
+ error("Failed to create tag")
291
+ end
292
+ puts "✓ Created commit and tag: #{tag_name}"
293
+ end
294
+ end
295
+
296
+ def push_to_github
297
+ step("Pushing to GitHub")
298
+
299
+ unless confirm("Push commits and tags to GitHub?")
300
+ error("Aborted by user")
301
+ end
302
+
303
+ if dry_run
304
+ puts "[DRY-RUN] Would run:"
305
+ puts " git push origin main"
306
+ puts " git push origin --tags"
307
+ else
308
+ unless system("git push origin main")
309
+ error("Failed to push commits")
310
+ end
311
+ unless system("git push origin --tags")
312
+ error("Failed to push tags")
313
+ end
314
+ puts "✓ Pushed to GitHub"
315
+ end
316
+ end
317
+
318
+ # Helpers
319
+ def get_latest_rubygems_version(gem_name)
320
+ output = `gem search ^#{gem_name}$ --remote 2>/dev/null`
321
+ if output =~ /#{gem_name}\s+\(([\d.]+)\)/
322
+ $1
323
+ end
324
+ end
325
+
326
+ def with_dir(dir)
327
+ original_dir = Dir.pwd
328
+ Dir.chdir(dir)
329
+ yield
330
+ ensure
331
+ Dir.chdir(original_dir)
332
+ end
333
+
334
+ def confirm(message)
335
+ return true if yes
336
+ print "#{message} (y/N): "
337
+ response = $stdin.gets.strip.downcase
338
+ response == "y" || response == "yes"
339
+ end
340
+
341
+ def step(message)
342
+ puts "\n→ #{message}..."
343
+ end
344
+
345
+ def success(message)
346
+ puts "\n✓ #{message}\n"
347
+ end
348
+
349
+ def error(message)
350
+ puts "\n✗ ERROR: #{message}\n"
351
+ exit 1
352
+ end
353
+ end
354
+
355
+ # Run the script
356
+ if __FILE__ == $0
357
+ if ARGV.empty?
358
+ puts "Usage: release.rb [options] COMMAND [VERSION]"
359
+ puts "Run with --help for more information"
360
+ exit 1
361
+ end
362
+
363
+ manager = GiblishReleaseManager.new(ARGV)
364
+ manager.run
365
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: giblish
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anders Rillbert
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-10-17 00:00:00.000000000 Z
11
+ date: 2025-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gran
@@ -17,6 +17,9 @@ dependencies:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0.1'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.1.1
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -24,6 +27,9 @@ dependencies:
24
27
  - - "~>"
25
28
  - !ruby/object:Gem::Version
26
29
  version: '0.1'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.1.1
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: warning
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -208,6 +214,7 @@ files:
208
214
  - lib/giblish/version.rb
209
215
  - scripts/hooks/post-receive.example
210
216
  - scripts/hooks/post-update.example
217
+ - scripts/release.rb
211
218
  - scripts/resources/css/adoc-colony.css
212
219
  - scripts/resources/css/giblish-serif.css
213
220
  - scripts/resources/css/giblish.css