From b05efae02df215c0dcb40c72d3ad1a2e3d9666a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20M=C3=BCller?= Date: Sun, 28 Apr 2024 21:38:55 +0200 Subject: [PATCH] Add `src/SOURCE_DATE_EPOCH` to release tree --- Makefile | 4 ++-- Makefile.win | 4 ++-- scripts/release-update.sh | 3 +++ scripts/update-changelog.sh | 5 +++++ 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 492b0aa762df..e56a14a27c1c 100644 --- a/Makefile +++ b/Makefile @@ -46,7 +46,8 @@ SPEC_FLAGS := $(if $(verbose),-v )$(if $(junit_output),--junit_output $(junit_ou CRYSTAL_CONFIG_LIBRARY_PATH := '$$ORIGIN/../lib/crystal' CRYSTAL_CONFIG_BUILD_COMMIT ?= $(shell git rev-parse --short HEAD 2> /dev/null) CRYSTAL_CONFIG_PATH := '$$ORIGIN/../share/crystal/src' -SOURCE_DATE_EPOCH ?= $(shell (git show -s --format=%ct HEAD || stat -c "%Y" Makefile || stat -f "%m" Makefile) 2> /dev/null) +CRYSTAL_VERSION ?= $(shell cat src/VERSION) +SOURCE_DATE_EPOCH ?= $(shell (cat src/SOURCE_DATE_EPOCH || (git show -s --format=%ct HEAD || stat -c "%Y" Makefile || stat -f "%m" Makefile)) 2> /dev/null) ifeq ($(shell command -v ld.lld >/dev/null && uname -s),Linux) EXPORT_CC ?= CC="$(CC) -fuse-ld=lld" endif @@ -63,7 +64,6 @@ LLVM_VERSION := $(if $(LLVM_CONFIG),$(shell $(LLVM_CONFIG) --version 2> /dev/nul LLVM_EXT_DIR = src/llvm/ext LLVM_EXT_OBJ = $(LLVM_EXT_DIR)/llvm_ext.o CXXFLAGS += $(if $(debug),-g -O0) -CRYSTAL_VERSION ?= $(shell cat src/VERSION) DESTDIR ?= PREFIX ?= /usr/local diff --git a/Makefile.win b/Makefile.win index 034dce59e4dc..89c0f9972a14 100644 --- a/Makefile.win +++ b/Makefile.win @@ -63,7 +63,8 @@ SPEC_FLAGS := $(if $(verbose),-v )$(if $(junit_output),--junit_output $(junit_ou CRYSTAL_CONFIG_LIBRARY_PATH := $$ORIGIN\lib CRYSTAL_CONFIG_BUILD_COMMIT := $(shell git rev-parse --short HEAD) CRYSTAL_CONFIG_PATH := $$ORIGIN\src -SOURCE_DATE_EPOCH := $(shell git show -s --format=%ct HEAD) +CRYSTAL_VERSION ?= $(shell type src\VERSION) +SOURCE_DATE_EPOCH ?= $(shell type src/SOURCE_DATE_EPOCH || git show -s --format=%ct HEAD) export_vars = $(eval export CRYSTAL_CONFIG_BUILD_COMMIT CRYSTAL_CONFIG_PATH SOURCE_DATE_EPOCH) export_build_vars = $(eval export CRYSTAL_CONFIG_LIBRARY_PATH) LLVM_CONFIG ?= @@ -71,7 +72,6 @@ LLVM_VERSION := $(if $(LLVM_CONFIG),$(shell $(LLVM_CONFIG) --version)) LLVM_EXT_DIR = src\llvm\ext LLVM_EXT_OBJ = $(LLVM_EXT_DIR)\llvm_ext.obj CXXFLAGS += $(if $(static),$(if $(debug),/MTd /Od ,/MT ),$(if $(debug),/MDd /Od ,/MD )) -CRYSTAL_VERSION ?= $(shell type src\VERSION) prefix ?= $(or $(ProgramW6432),$(ProgramFiles))\crystal BINDIR ?= $(prefix) diff --git a/scripts/release-update.sh b/scripts/release-update.sh index d705ce357f3e..c9fa180f6578 100755 --- a/scripts/release-update.sh +++ b/scripts/release-update.sh @@ -16,6 +16,9 @@ minor_branch="${CRYSTAL_VERSION%.*}" next_minor="$((${minor_branch#*.} + 1))" echo "${CRYSTAL_VERSION%%.*}.${next_minor}.0-dev" > src/VERSION +# Remove SOURCE_DATE_EPOCH (only used in source tree of a release) +rm -f src/SOURCE_DATE_EPOCH + # Edit PREVIOUS_CRYSTAL_BASE_URL in .circleci/config.yml sed -i -E "s|[0-9.]+/crystal-[0-9.]+-[0-9]|$CRYSTAL_VERSION/crystal-$CRYSTAL_VERSION-1|g" .circleci/config.yml diff --git a/scripts/update-changelog.sh b/scripts/update-changelog.sh index 3d044eb79062..6fe0fa2839f3 100755 --- a/scripts/update-changelog.sh +++ b/scripts/update-changelog.sh @@ -44,6 +44,11 @@ git switch $branch 2>/dev/null || git switch -c $branch; echo "${VERSION}" > src/VERSION git add src/VERSION +# Write release date into src/SOURCE_DATE_EPOCH +release_date=$(head -n1 $current_changelog | grep -o -P '(?<=\()[^)]+') +echo "$(date --utc --date="${release_date}" +%s)" > src/SOURCE_DATE_EPOCH +git add src/SOURCE_DATE_EPOCH + if grep --silent -E "^## \[$VERSION\]" CHANGELOG.md; then echo "Replacing section in CHANGELOG"