Skip to content

Commit

Permalink
Use tag timestamp instead of current timestamp when SOURCE_DATE_EPOCH…
Browse files Browse the repository at this point in the history
… is not set
  • Loading branch information
sebastianbergmann committed Apr 19, 2024
1 parent 15741a8 commit 85f0d38
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions build/scripts/phar-set-timestamps/run.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@

use Seld\PharUtils\Timestamps;

$util = new Timestamps($argv[1]);

if (is_string(getenv('SOURCE_DATE_EPOCH'))) {
$timestamp = new DateTime;
$timestamp->setTimestamp((int) getenv('SOURCE_DATE_EPOCH'));
$epoch = (int) getenv('SOURCE_DATE_EPOCH');
} else {
$timestamp = new DateTimeImmutable('now');
$epoch = (int) trim(shell_exec('git log -1 --format=%at ' . trim(shell_exec('git describe --abbrev=0'))));
}

$util->updateTimestamps($timestamp);
$timestamp = new DateTime;
$timestamp->setTimestamp($epoch);

$util = new Timestamps($argv[1]);
$util->updateTimestamps($timestamp);
$util->save($argv[1], Phar::SHA512);

0 comments on commit 85f0d38

Please sign in to comment.