middleman-s3_sync 4.7.0 released

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:

1
2
3
4
5
6
7
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):

1
2
3
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:

1
2
3
4
5
6
7
8
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:

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

Then run:

1
bundle update middleman-s3_sync

Thanks

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