Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ project(
# set this to "${PROJECT_VERSION}" on release
#set(INSTALL_VERSION "${PROJECT_VERSION}")
set(INSTALL_VERSION "unreleased")
if(INSTALL_VERSION STREQUAL "unreleased")
set(INSTALL_OUTPUT_VERSION "${PROJECT_VERSION}dev")
else()
set(INSTALL_OUTPUT_VERSION "${INSTALL_VERSION}")
endif()
set(H3_CORE_VERSION 4.5.0)
set(H3_CORE_SHA256 0da8a392a6ff77e76b60e6a331a49497d0935b6b7b6899da7a3e2786139b0441)

Expand Down
72 changes: 66 additions & 6 deletions cmake/AddPostgreSQLExtension.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,21 @@ function(PostgreSQL_add_extension_bitcode LIBRARY_NAME EXTENSION_NAME EXTENSION_
)
endfunction()

macro(PostgreSQL_append_update_transition SOURCE_VERSION)
set(UPDATE_TRANSITION_NAME "${EXTENSION_NAME}--${SOURCE_VERSION}--${EXTENSION_VERSION}.sql")
set(UPDATE_TRANSITION_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${UPDATE_TRANSITION_NAME}")
set(UPDATE_TRANSITION_CONTENT [=[
-- Generated transition from @SOURCE_VERSION@ development installs.
\echo Use "ALTER EXTENSION @EXTENSION_NAME@ UPDATE TO '@EXTENSION_VERSION@'" to load this file. \quit
]=])
string(REPLACE "@SOURCE_VERSION@" "${SOURCE_VERSION}" UPDATE_TRANSITION_CONTENT "${UPDATE_TRANSITION_CONTENT}")
string(REPLACE "@EXTENSION_NAME@" "${EXTENSION_NAME}" UPDATE_TRANSITION_CONTENT "${UPDATE_TRANSITION_CONTENT}")
string(REPLACE "@EXTENSION_VERSION@" "${EXTENSION_VERSION}" UPDATE_TRANSITION_CONTENT "${UPDATE_TRANSITION_CONTENT}")
file(WRITE "${UPDATE_TRANSITION_OUTPUT}" "${UPDATE_TRANSITION_CONTENT}")
list(APPEND UPDATE_TRANSITION_NAMES "${UPDATE_TRANSITION_NAME}")
list(APPEND UPDATE_TRANSITION_OUTPUTS "${UPDATE_TRANSITION_OUTPUT}")
endmacro()

# Helper command to add extensions
function(PostgreSQL_add_extension LIBRARY_NAME)
set(options RELOCATABLE)
Expand Down Expand Up @@ -271,25 +286,70 @@ function(PostgreSQL_add_extension LIBRARY_NAME)

# Apply the same compatibility preprocessing to update scripts.
set(EXTENSION_UPDATES_PROCESSED "")
set(EXTENSION_UNRELEASED_TRANSITION_EMITTED FALSE)
set(EXTENSION_PROJECT_DEV_RELEASE_TRANSITION_EMITTED FALSE)
set(EXTENSION_SOURCE_DEV_RELEASE_TRANSITION_EMITTED FALSE)
foreach(file ${EXTENSION_UPDATES})
get_filename_component(UPDATE_NAME "${file}" NAME)
set(UPDATE_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${UPDATE_NAME}")
set(UPDATE_OUTPUT_NAME "${UPDATE_NAME}")
set(UPDATE_TRANSITION_NAMES "")
set(UPDATE_TRANSITION_OUTPUTS "")
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${file}")
file(READ "${file}" UPDATE_CONTENTS)
Comment thread
Komzpa marked this conversation as resolved.
if(UPDATE_OUTPUT_NAME MATCHES "--unreleased\\.sql$" AND NOT EXTENSION_VERSION STREQUAL "unreleased")
string(REGEX REPLACE "--unreleased\\.sql$" "--${EXTENSION_VERSION}.sql" UPDATE_OUTPUT_NAME "${UPDATE_OUTPUT_NAME}")
string(REPLACE "UPDATE TO 'unreleased'" "UPDATE TO '${EXTENSION_VERSION}'" UPDATE_CONTENTS "${UPDATE_CONTENTS}")
string(REPLACE "availability: unreleased" "availability: ${EXTENSION_VERSION}" UPDATE_CONTENTS "${UPDATE_CONTENTS}")
endif()

if(NOT EXTENSION_VERSION STREQUAL "unreleased" AND NOT EXTENSION_UNRELEASED_TRANSITION_EMITTED)
if(UPDATE_OUTPUT_NAME MATCHES "--${EXTENSION_VERSION}\\.sql$")
# Let old local development installs marked as "unreleased" move to
# the generated development version, and later to the real release.
set(EXTENSION_UNRELEASED_TRANSITION_EMITTED TRUE)
PostgreSQL_append_update_transition("unreleased")
endif()
endif()

if(DEFINED PROJECT_VERSION AND EXTENSION_VERSION STREQUAL PROJECT_VERSION
AND (NOT EXTENSION_PROJECT_DEV_RELEASE_TRANSITION_EMITTED OR NOT EXTENSION_SOURCE_DEV_RELEASE_TRANSITION_EMITTED))
Comment on lines +314 to +315

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Generate dev-to-dev upgrade aliases

When the next development cycle starts (for example, after releasing 4.5.1 and returning INSTALL_VERSION to unreleased), EXTENSION_VERSION becomes 4.5.1dev, so this branch is skipped and the build only emits the normal 4.5.0--4.5.1 plus 4.5.1--4.5.1dev paths. A developer who installed the current 4.5.0dev version from source then has no 4.5.0dev--4.5.1 or 4.5.0dev--4.5.1dev update file in a fresh next-cycle build, so ALTER EXTENSION ... UPDATE cannot move their dev install forward unless they first install the release artifact. Please emit the source-dev compatibility transition when generating the dev default version as well as release builds.

Useful? React with 👍 / 👎.

if(UPDATE_OUTPUT_NAME MATCHES "^${EXTENSION_NAME}--(.+)--${EXTENSION_VERSION}\\.sql$")
set(UPDATE_SOURCE_VERSION "${CMAKE_MATCH_1}")
if(NOT EXTENSION_PROJECT_DEV_RELEASE_TRANSITION_EMITTED)
set(EXTENSION_PROJECT_DEV_RELEASE_TRANSITION_EMITTED TRUE)
PostgreSQL_append_update_transition("${PROJECT_VERSION}dev")
endif()
if(NOT UPDATE_SOURCE_VERSION STREQUAL "unreleased")
set(UPDATE_SOURCE_DEV_VERSION "${UPDATE_SOURCE_VERSION}dev")
if(NOT UPDATE_SOURCE_DEV_VERSION STREQUAL "${PROJECT_VERSION}dev" AND NOT EXTENSION_SOURCE_DEV_RELEASE_TRANSITION_EMITTED)
set(EXTENSION_SOURCE_DEV_RELEASE_TRANSITION_EMITTED TRUE)
PostgreSQL_append_update_transition("${UPDATE_SOURCE_DEV_VERSION}")
endif()
endif()
endif()
endif()
set(UPDATE_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${UPDATE_OUTPUT_NAME}")
if(PostgreSQL_VERSION_MAJOR VERSION_LESS "16")
file(READ "${file}" UPDATE_CONTENTS)
string(REPLACE "@extschema:${EXTENSION_NAME}@." "" UPDATE_CONTENTS "${UPDATE_CONTENTS}")
string(REPLACE "@extschema:h3@." "" UPDATE_CONTENTS "${UPDATE_CONTENTS}")
string(REPLACE "@extschema:postgis@." "" UPDATE_CONTENTS "${UPDATE_CONTENTS}")
string(REPLACE "@extschema:postgis_raster@." "" UPDATE_CONTENTS "${UPDATE_CONTENTS}")
file(WRITE "${UPDATE_OUTPUT}" "${UPDATE_CONTENTS}")
else()
configure_file("${file}" "${UPDATE_OUTPUT}" COPYONLY)
endif()
file(WRITE "${UPDATE_OUTPUT}" "${UPDATE_CONTENTS}")
configure_file(
"${UPDATE_OUTPUT}"
"${EXTENSION_BUILD_EXTENSION_DIR}/${UPDATE_NAME}"
"${EXTENSION_BUILD_EXTENSION_DIR}/${UPDATE_OUTPUT_NAME}"
COPYONLY
)
list(APPEND EXTENSION_UPDATES_PROCESSED "${UPDATE_OUTPUT}")
foreach(UPDATE_TRANSITION_NAME UPDATE_TRANSITION_OUTPUT IN ZIP_LISTS UPDATE_TRANSITION_NAMES UPDATE_TRANSITION_OUTPUTS)
configure_file(
"${UPDATE_TRANSITION_OUTPUT}"
"${EXTENSION_BUILD_EXTENSION_DIR}/${UPDATE_TRANSITION_NAME}"
COPYONLY
)
list(APPEND EXTENSION_UPDATES_PROCESSED "${UPDATE_TRANSITION_OUTPUT}")
endforeach()
endforeach()

# Install everything else into share-dir
Expand Down
16 changes: 12 additions & 4 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

In order to build and test your changes, simply run `./scripts/develop`.

During development, repository source files keep `INSTALL_VERSION` and the
latest update SQL filenames at `unreleased`. CMake derives the installed
PostgreSQL extension version from that placeholder as `${PROJECT_VERSION}dev`,
so a development build of project version `4.5.0` installs control, SQL, and
module metadata for `4.5.0dev`. Release scripts still replace the source
placeholder with the exact release version.

For local upgrade-validation coverage, install `pg_validate_extupgrade` so
`ctest` can run the same extension-upgrade checks as CI. Without it, CTest
registers explicit `*_validate_extupgrade_unavailable` placeholder tests and
Expand Down Expand Up @@ -30,8 +37,9 @@ This command also validates that all extension GUCs are documented in `h3/src/gu
- The script creates `release-X.Y.Z` and leaves the release changes
uncommitted for review.
2. Review the release diff
- Root `CMakeLists.txt` has `VERSION X.Y.Z` and installs
`${PROJECT_VERSION}` instead of `unreleased`.
- Root `CMakeLists.txt` has `VERSION X.Y.Z`, sets `INSTALL_VERSION` to
`${PROJECT_VERSION}`, and therefore installs exactly `X.Y.Z` instead of
the generated development version.
- The `h3` and `h3_postgis` update files that ended in `--unreleased.sql`
have been renamed to end in `--X.Y.Z.sql`, and their CMake references were
renamed with them.
Expand Down Expand Up @@ -60,6 +68,6 @@ This command also validates that all extension GUCs are documented in `h3/src/gu
- Run `scripts/postrelease`. The script restores `INSTALL_VERSION` to
`unreleased`, creates the next empty `h3--X.Y.Z--unreleased.sql` and
`h3_postgis--X.Y.Z--unreleased.sql` files, adds them to the extension CMake
files, restores the upgrade regression target to `unreleased`, and runs the
release metadata checks.
files, keeps the upgrade regression target pointed at the default
extension version, and runs the release metadata checks.
- Review, commit, push, and merge the post-release development branch.
2 changes: 1 addition & 1 deletion h3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PostgreSQL_add_extension(postgresql_h3
RELOCATABLE
NAME h3
COMMENT "H3 bindings for PostgreSQL"
VERSION ${INSTALL_VERSION}
VERSION ${INSTALL_OUTPUT_VERSION}
COMPONENT ${PROJECT_NAME}
SOURCES
src/binding/edge.c
Expand Down
2 changes: 1 addition & 1 deletion h3/src/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
#ifndef H3_CONFIG_H
#define H3_CONFIG_H

#define POSTGRESQL_H3_VERSION "@INSTALL_VERSION@"
#define POSTGRESQL_H3_VERSION "@INSTALL_OUTPUT_VERSION@"

#endif /* H3_CONFIG_H */
2 changes: 1 addition & 1 deletion h3/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ PostgreSQL_add_extupgrade_test(
NAME h3_validate_extupgrade
EXTNAME h3
FROM_VERSION 0.1.0
TO_VERSION ${INSTALL_VERSION}
TO_VERSION ${INSTALL_OUTPUT_VERSION}
TEMP_ROOT ${CMAKE_CURRENT_BINARY_DIR}/extupgrade-h3
TEMP_PORT 65441
DYNAMIC_LIBRARY_PATH ${H3_REGRESS_TEMP_CONFIG_DYNAMIC_LIBRARY_PATH}
Expand Down
4 changes: 2 additions & 2 deletions h3/test/expected/extension.out
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
--
-- TEST h3_get_extension_version
--
SELECT h3_get_extension_version() ~ '^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$'
SELECT h3_get_extension_version() ~ '^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:dev|-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$'
OR h3_get_extension_version() = 'unreleased';
t

Expand Down Expand Up @@ -97,7 +97,7 @@ SELECT
hex,
h3_distance_user_wrapper(hex) AS dist
FROM h3_distance_expr_fail_userfn;
ALTER EXTENSION h3 UPDATE TO 'unreleased';
ALTER EXTENSION h3 UPDATE;
SELECT (current_setting('server_version_num')::int >= 140000) = EXISTS (
SELECT 1
FROM pg_amproc ap
Expand Down
4 changes: 2 additions & 2 deletions h3/test/sql/extension.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
-- TEST h3_get_extension_version
--

SELECT h3_get_extension_version() ~ '^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$'
SELECT h3_get_extension_version() ~ '^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:dev|-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$'
OR h3_get_extension_version() = 'unreleased';

--
Expand Down Expand Up @@ -114,7 +114,7 @@ SELECT
h3_distance_user_wrapper(hex) AS dist
FROM h3_distance_expr_fail_userfn;

ALTER EXTENSION h3 UPDATE TO 'unreleased';
ALTER EXTENSION h3 UPDATE;

SELECT (current_setting('server_version_num')::int >= 140000) = EXISTS (
SELECT 1
Expand Down
2 changes: 1 addition & 1 deletion h3_postgis/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PostgreSQL_add_extension(postgresql_h3_postgis
RELOCATABLE
NAME h3_postgis
COMMENT "H3 PostGIS integration"
VERSION ${INSTALL_VERSION}
VERSION ${INSTALL_OUTPUT_VERSION}
COMPONENT ${PROJECT_NAME}
REQUIRES
h3
Expand Down
2 changes: 1 addition & 1 deletion h3_postgis/src/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
#ifndef PGH3_CONFIG_H
#define PGH3_CONFIG_H

#define POSTGRESQL_PGH3_VERSION "@INSTALL_VERSION@"
#define POSTGRESQL_PGH3_VERSION "@INSTALL_OUTPUT_VERSION@"

#endif /* PGH3_CONFIG_H */
2 changes: 1 addition & 1 deletion h3_postgis/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ PostgreSQL_add_extupgrade_test(
NAME h3_postgis_validate_extupgrade
EXTNAME h3_postgis
FROM_VERSION 4.0.0
TO_VERSION ${INSTALL_VERSION}
TO_VERSION ${INSTALL_OUTPUT_VERSION}
TEMP_ROOT ${CMAKE_CURRENT_BINARY_DIR}/extupgrade-h3_postgis
TEMP_PORT 65442
DYNAMIC_LIBRARY_PATH ${H3_POSTGIS_REGRESS_TEMP_CONFIG_DYNAMIC_LIBRARY_PATH}
Expand Down
6 changes: 2 additions & 4 deletions scripts/postrelease
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,9 @@ main() {

make_next_update h3 h3/sql/updates h3/CMakeLists.txt "$version"
make_next_update h3_postgis h3_postgis/sql/updates h3_postgis/CMakeLists.txt "$version"
sed -i "s/ALTER EXTENSION h3 UPDATE TO '${version}'/ALTER EXTENSION h3 UPDATE TO 'unreleased'/g" \
h3/test/sql/extension.sql h3/test/expected/extension.out
for test_file in h3/test/sql/extension.sql h3/test/expected/extension.out; do
grep -q "ALTER EXTENSION h3 UPDATE TO 'unreleased'" "$test_file" ||
die "${test_file} extension regression target was not restored to unreleased"
grep -q "ALTER EXTENSION h3 UPDATE;" "$test_file" ||
die "${test_file} extension regression target does not update to the default version"
done

verify_update_references
Expand Down
6 changes: 2 additions & 4 deletions scripts/release
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ release_update_file() {
[[ ! -e "$new_file" ]] || die "${new_file} already exists"

git mv "$old_file" "$new_file"
sed -i "s/unreleased/${version}/g" "$new_file"
sed -i "s/UPDATE TO 'unreleased'/UPDATE TO '${version}'/g" "$new_file"
sed -i "s/availability: unreleased/availability: ${version}/g" "$new_file"
sed -i -E 's/[[:space:]]+$//' "$new_file"
grep -qF "$old_name" "$cmake_file" || die "${cmake_file} does not reference ${old_name}"
OLD_NAME="$old_name" NEW_NAME="$new_name" \
Expand Down Expand Up @@ -211,9 +212,6 @@ main() {
release_update_file h3 h3/sql/updates h3/CMakeLists.txt "$version"
release_update_file h3_postgis h3_postgis/sql/updates h3_postgis/CMakeLists.txt "$version"

sed -i "s/ALTER EXTENSION h3 UPDATE TO 'unreleased'/ALTER EXTENSION h3 UPDATE TO '${version}'/g" \
h3/test/sql/extension.sql h3/test/expected/extension.out

sed -i -E "s/^version: v[0-9]+\.[0-9]+\.[0-9]+/version: v${version}/" CITATION.cff
sed -i -E "s/^date-released: [0-9]{4}-[0-9]{2}-[0-9]{2}/date-released: ${release_date}/" CITATION.cff

Expand Down
Loading