middleman-s3_sync 4.7.0 released

Reliability work on CloudFront invalidations, plus conveniences in the caching policy DSL that make it easier to reason about what gets re-uploaded.


I’ve just released version 4.7.0 of middleman-s3_sync, a gem that synchronizes Middleman-built websites to Amazon S3, with optional CloudFront invalidation. This is a feature release with several new capabilities.

New Features

after_s3_sync Callback

You can now run custom code after sync completes—perfect for notifications, webhooks, or post-deployment tasks:

ruby
activate :s3_sync do |s3_sync|
  s3_sync.after_s3_sync = ->(results) {
    puts "Created: #{results[:created]} files"
    puts "Updated: #{results[:updated]} files"
    puts "Deleted: #{results[:deleted]} files"
  }
end

The callback receives a hash with sync statistics and the list of CloudFront invalidation paths.

scan_build_dir Option

Sync files that exist in your build directory but aren’t tracked by Middleman’s sitemap (e.g., files generated by external tools):

ruby
activate :s3_sync do |s3_sync|
  s3_sync.scan_build_dir = true
end

S3 Website routing_rules

Configure S3 website redirect rules directly from your Middleman config:

ruby
activate :s3_sync do |s3_sync|
  s3_sync.routing_rules = [
    {
      condition: { key_prefix_equals: 'old/' },
      redirect: { replace_key_prefix_with: 'new/', http_redirect_code: '301' }
    }
  ]
end

Improved Content Type Detection

Better MIME type detection using the mime-types gem as a fallback, with support for custom content types via the content_types option.

Other Improvements

  • Reliability: Proper sitemap population before sync ensures all resources are captured
  • CI/CD: GitHub Actions workflows for continuous integration and automated releases
  • Dependencies: Tightened gemspec with bounded dependency versions
  • Ruby: Now requires Ruby >= 3.0

Upgrading

Update your Gemfile:

ruby
gem 'middleman-s3_sync', '~> 4.7'

Then run:

shell
bundle update middleman-s3_sync

Thanks

As always, the source is on GitHub and the gem is on RubyGems. Feedback and PRs welcome!


Filed under middleman ruby s3

Comments

Powered by Disqus.



© 2007–2026 Frederic Jean · CC BY-SA 3.0 · RSS