diff --git a/.github/workflows/ami-release-nix.yml b/.github/workflows/ami-release-nix.yml index cb004ce82..08de3dca9 100644 --- a/.github/workflows/ami-release-nix.yml +++ b/.github/workflows/ami-release-nix.yml @@ -55,7 +55,7 @@ jobs: run: | packer init stage2-nix-psql.pkr.hcl GIT_SHA=${{github.sha}} - packer build -var "git-head-version=${GIT_SHA}" -var "packer-execution-id=${GITHUB_RUN_ID}" -var-file="development-arm.vars.pkr.hcl" -var-file="common-nix.vars.pkr.hcl" stage2-nix-psql.pkr.hcl + packer build -var "git_sha=${GIT_SHA}" -var "git-head-version=${GIT_SHA}" -var "packer-execution-id=${GITHUB_RUN_ID}" -var-file="development-arm.vars.pkr.hcl" -var-file="common-nix.vars.pkr.hcl" stage2-nix-psql.pkr.hcl - name: Grab release version id: process_release_version diff --git a/common-nix.vars.pkr.hcl b/common-nix.vars.pkr.hcl index 77421cc3e..a4f97def6 100644 --- a/common-nix.vars.pkr.hcl +++ b/common-nix.vars.pkr.hcl @@ -1 +1 @@ -postgres-version = "15.6.1.110" +postgres-version = "15.6.1.111" diff --git a/nix/ext/wrappers/default.nix b/nix/ext/wrappers/default.nix index aca14dc9a..af0c15b5d 100644 --- a/nix/ext/wrappers/default.nix +++ b/nix/ext/wrappers/default.nix @@ -7,43 +7,41 @@ , buildPgrxExtension_0_11_3 , cargo , darwin +, jq }: +let + gitTags = builtins.fromJSON (builtins.readFile (builtins.fetchurl { + url = "https://api.github.com/repos/supabase/wrappers/tags"; + sha256 = "0am40yspir70wp8pik1c7qmfvbby3nyxza115pi9klp6fyv2s93j"; # Replace with actual hash + })); +in buildPgrxExtension_0_11_3 rec { pname = "supabase-wrappers"; version = "0.4.1"; inherit postgresql; - src = fetchFromGitHub { owner = "supabase"; repo = "wrappers"; rev = "v${version}"; hash = "sha256-AU9Y43qEMcIBVBThu+Aor1HCtfFIg+CdkzK9IxVdkzM="; }; - - nativeBuildInputs = [ pkg-config cargo ]; - - buildInputs = [ openssl ] ++ lib.optionals (stdenv.isDarwin) [ + nativeBuildInputs = [ pkg-config cargo jq ]; + buildInputs = [ openssl ] ++ lib.optionals (stdenv.isDarwin) [ darwin.apple_sdk.frameworks.CoreFoundation darwin.apple_sdk.frameworks.Security darwin.apple_sdk.frameworks.SystemConfiguration ]; - - # Needed to get openssl-sys to use pkg-config. OPENSSL_NO_VENDOR = 1; CARGO="${cargo}/bin/cargo"; - cargoLock = { - #TODO when we move to newer versions this lockfile will need to be sourced - # from ${src}/Cargo.lock lockFile = "${src}/Cargo.lock"; outputHashes = { "clickhouse-rs-1.0.0-alpha.1" = "sha256-0zmoUo/GLyCKDLkpBsnLAyGs1xz6cubJhn+eVqMEMaw="; }; }; postPatch = "cp ${cargoLock.lockFile} Cargo.lock"; - buildAndTestSubdir = "wrappers"; buildFeatures = [ "helloworld_fdw" @@ -60,12 +58,33 @@ buildPgrxExtension_0_11_3 rec { "cognito_fdw" "wasm_fdw" ]; - - # FIXME (aseipp): disable the tests since they try to install .control - # files into the wrong spot, aside from that the one main test seems - # to work, though doCheck = false; + preBuild = '' + echo "Processing git tags..." + echo '${builtins.toJSON gitTags}' | ${jq}/bin/jq -r '.[].name' | sort -rV > git_tags.txt + ''; + + postInstall = '' + echo "Creating SQL files for previous versions..." + current_version="${version}" + sql_file="$out/share/postgresql/extension/wrappers--$current_version.sql" + + if [ -f "$sql_file" ]; then + while read -r tag; do + tag_version=$(echo "$tag" | sed 's/^v//') + if [ "$(printf '%s\n' "$tag_version" "$current_version" | sort -V | head -n1)" = "$tag_version" ] && [ "$tag_version" != "$current_version" ]; then + new_file="$out/share/postgresql/extension/wrappers--$tag_version--$current_version.sql" + echo "Creating $new_file" + cp "$sql_file" "$new_file" + fi + done < git_tags.txt + else + echo "Warning: $sql_file not found" + fi + rm git_tags.txt + ''; + meta = with lib; { description = "Various Foreign Data Wrappers (FDWs) for PostreSQL"; homepage = "https://github.com/supabase/wrappers"; @@ -73,4 +92,4 @@ buildPgrxExtension_0_11_3 rec { platforms = postgresql.meta.platforms; license = licenses.postgresql; }; -} \ No newline at end of file +}