Skip to content

Commit

Permalink
Add src/SOURCE_DATE_EPOCH to release tree (#14574)
Browse files Browse the repository at this point in the history
  • Loading branch information
straight-shoota authored May 13, 2024
1 parent 12f4e03 commit 8d14782
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Makefile.win
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ 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 ?=
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)
Expand Down
3 changes: 3 additions & 0 deletions scripts/release-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions scripts/update-changelog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down

0 comments on commit 8d14782

Please sign in to comment.