Skip to content

Commit

Permalink
Support SOURCE_DATE_EPOCH environment variable for "reproducible" bui…
Browse files Browse the repository at this point in the history
…lds.

Fixes mkdocs#938.
  • Loading branch information
waylan committed May 16, 2016
1 parent 5547f2a commit b9e3aee
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/about/release-notes.md
Expand Up @@ -73,6 +73,8 @@ created and third-party templates:
pages config. (#728)
* Update searching to Lunr 0.7, which comes with some performance enhancements
for larger documents (#859)
* Bugfix: Support SOURCE_DATE_EPOCH environment variable for "reproducible"
builds (#938)

## Version 0.15.3 (2016-02-18)

Expand Down
7 changes: 6 additions & 1 deletion mkdocs/commands/build.py
Expand Up @@ -2,6 +2,7 @@

from __future__ import unicode_literals
from datetime import datetime
from calendar import timegm
import io
import logging
import os
Expand Down Expand Up @@ -55,6 +56,10 @@ def get_global_context(nav, config):
extra_javascript = utils.create_media_urls(nav, config['extra_javascript'])

extra_css = utils.create_media_urls(nav, config['extra_css'])

# Support SOURCE_DATE_EPOCH environment variable for "reproducible" builds.
# See https://reproducible-builds.org/specs/source-date-epoch/
timestamp = int(os.environ.get('SOURCE_DATE_EPOCH', timegm(datetime.utcnow().utctimetuple())))

return {
'site_name': site_name,
Expand Down Expand Up @@ -84,7 +89,7 @@ def get_global_context(nav, config):
'google_analytics': config['google_analytics'],

'mkdocs_version': mkdocs.__version__,
'build_date_utc': datetime.utcnow(),
'build_date_utc': datetime.utcfromtimestamp(timestamp),

'config': config
}
Expand Down

0 comments on commit b9e3aee

Please sign in to comment.