Skip to content

Commit 23215a2

Browse files
committed
chore: upload 0.4.2 schema scripts (#266)
try-job: psql_macos --------- Signed-off-by: usamoi <usamoi@outlook.com>
1 parent 8530ccf commit 23215a2

7 files changed

Lines changed: 617 additions & 155 deletions

File tree

.github/workflows/check.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ jobs:
201201

202202
- name: Install
203203
run: |
204-
cargo make package -o ./build/raw
205-
cargo make install --sudo -i ./build/raw
204+
cargo make build -o ./build/raw
205+
sudo make PG_CONFIG=${PGRX_PG_CONFIG_PATH} install
206206
207207
- name: Service
208208
run: |
@@ -304,8 +304,8 @@ jobs:
304304
305305
- name: Install
306306
run: |
307-
cargo make package -o ./build/raw
308-
cargo make install --sudo -i ./build/raw
307+
cargo make build -o ./build/raw
308+
sudo make PG_CONFIG=${PGRX_PG_CONFIG_PATH} install
309309
310310
- name: Service
311311
run: |
@@ -327,7 +327,6 @@ jobs:
327327
VERSION: ${{ matrix.version }}
328328
ARCH: ${{ matrix.arch }}
329329
run: |
330-
cargo make package -o ./build/raw
331330
(cd ./build/raw && zip -r ../postgresql-${VERSION}-vchord_${SEMVER}_${ARCH}-apple-darwin.zip .)
332331
333332
- name: Upload Artifacts

.github/workflows/pgxn.yml

Lines changed: 0 additions & 75 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ jobs:
8585
ARCH: ${{ matrix.arch }}
8686
PLATFORM: ${{ matrix.arch == 'x86_64' && 'amd64' || 'arm64' }}
8787
run: |
88-
cargo make package -o ./build/raw
88+
cargo make build -o ./build/raw
89+
8990
(cd ./build/raw && zip -r ../postgresql-${VERSION}-vchord_${SEMVER}_${ARCH}-linux-gnu.zip .)
9091
9192
mkdir -p ./build/deb
@@ -219,4 +220,28 @@ jobs:
219220
--amend ghcr.io/tensorchord/vchord-postgres:pg${{ matrix.version }}-v${{ env.SEMVER }}-amd64 \
220221
--amend ghcr.io/tensorchord/vchord-postgres:pg${{ matrix.version }}-v${{ env.SEMVER }}-arm64
221222
docker manifest push ghcr.io/tensorchord/vchord-postgres:pg${{ matrix.version }}-v${{ env.SEMVER }}
222-
223+
224+
pgxn:
225+
runs-on: "ubuntu-latest"
226+
needs: ["semver", "build"]
227+
228+
steps:
229+
- name: Checkout
230+
uses: actions/checkout@v4
231+
232+
- name: Upload
233+
env:
234+
SEMVER: ${{ needs.semver.outputs.SEMVER }}
235+
PGXN_PASSWORD: ${{ secrets.PGXN_PASSWORD }}
236+
run: |
237+
mkdir -p ./build
238+
239+
sed -e "s/@DISTVERSION@/${SEMVER}/g" META.json.in > META.json
240+
git archive --format zip --prefix "vchord-${SEMVER}/" --add-file META.json -o "./build/vchord--${SEMVER}.zip" HEAD
241+
242+
curl --fail -sS \
243+
--user "tensorchord:${PGXN_PASSWORD}" \
244+
-F "submit=Release It!" \
245+
-F "archive=@./build/vchord--${SEMVER}.zip" \
246+
-H "X-Requested-With: XMLHttpRequest" \
247+
https://manager.pgxn.org/upload

Makefile

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
PG_CONFIG ?= $(shell which pg_config)
1+
PG_CONFIG ?= pg_config
22

3-
.PHONY: make package install
4-
.DEFAULT_GOAL: package
3+
.PHONY: all build install uninstall
54

6-
all: build-make package
5+
all: build
76

8-
build-make:
9-
mkdir -p ./build
10-
cargo build -p make
11-
cp ./target/debug/make ./build/make
12-
13-
package:
14-
PGRX_PG_CONFIG_PATH="$(PG_CONFIG)" ./build/make package -o ./build/raw
7+
build:
8+
PGRX_PG_CONFIG_PATH="$(PG_CONFIG)" cargo make build -o ./build/raw
159

1610
install:
17-
PGRX_PG_CONFIG_PATH="$(PG_CONFIG)" ./build/make install -i ./build/raw
11+
cp -r ./build/raw/pkglibdir/. $(shell $(PG_CONFIG) --pkglibdir)
12+
cp -r ./build/raw/sharedir/. $(shell $(PG_CONFIG) --sharedir)
13+
14+
uninstall:
15+
rm -f $(shell find $(shell $(PG_CONFIG) --pkglibdir) -type f -name 'vchord.*')
16+
rm -f $(shell find $(shell $(PG_CONFIG) --sharedir)/extension -type f -name 'vchord.*')
17+
rm -f $(shell find $(shell $(PG_CONFIG) --sharedir)/extension -type f -name 'vchord--*.sql')

crates/make/src/main.rs

Lines changed: 7 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,15 @@ struct Cli {
3131

3232
#[derive(Subcommand)]
3333
enum Commands {
34-
Package(PackageArgs),
35-
Install(InstallArgs),
34+
Build(BuildArgs),
3635
}
3736

3837
#[derive(Args)]
39-
struct PackageArgs {
38+
struct BuildArgs {
4039
#[arg(short, long)]
4140
output: String,
4241
}
4342

44-
#[derive(Args)]
45-
struct InstallArgs {
46-
#[arg(short, long)]
47-
input: Option<String>,
48-
#[arg(long, default_value = "false")]
49-
sudo: bool,
50-
}
51-
5243
fn main() -> Result<()> {
5344
let cli = Cli::parse();
5445
if !std::fs::exists("vchord.control")? {
@@ -203,14 +194,8 @@ fn main() -> Result<()> {
203194
let command_stdout = String::from_utf8(command_output.stdout)?.replace("\t", " ");
204195
Ok(command_stdout)
205196
};
206-
let uilts_install = |sudo: bool, permission: &str, src: &str, dst: &str| {
207-
let mut command;
208-
if sudo {
209-
command = Command::new("sudo");
210-
command.arg("install");
211-
} else {
212-
command = Command::new("install");
213-
};
197+
let uilts_install = |permission: &str, src: &str, dst: &str| {
198+
let mut command = Command::new("install");
214199
command.args(["-m", permission, src, dst]);
215200
let debug = format!("{command:?}");
216201
let status = command.spawn()?.wait()?;
@@ -219,36 +204,18 @@ fn main() -> Result<()> {
219204
}
220205
Ok(())
221206
};
222-
let uilts_cp = |sudo: bool, args: &[&str]| {
223-
let mut command;
224-
if sudo {
225-
command = Command::new("sudo");
226-
command.arg("cp");
227-
} else {
228-
command = Command::new("cp");
229-
};
230-
command.args(args);
231-
let debug = format!("{command:?}");
232-
let status = command.spawn()?.wait()?;
233-
if !status.success() {
234-
bail!("Command execution failed: {debug}");
235-
}
236-
Ok(())
237-
};
238207
let dll_suffix = if OS == "macos" && matches!(fork.as_str(), "pg13" | "pg14" | "pg15") {
239208
".so"
240209
} else {
241210
DLL_SUFFIX
242211
};
243-
let install = |sudo, pkglibdir, sharedir_extension| -> Result<()> {
212+
let install = |pkglibdir, sharedir_extension| -> Result<()> {
244213
uilts_install(
245-
sudo,
246214
"755",
247215
&format!("./target/release/{DLL_PREFIX}vchord{DLL_SUFFIX}"),
248216
&format!("{pkglibdir}/vchord{dll_suffix}"),
249217
)?;
250218
uilts_install(
251-
sudo,
252219
"644",
253220
"./vchord.control",
254221
&format!("{sharedir_extension}/vchord.control"),
@@ -258,14 +225,12 @@ fn main() -> Result<()> {
258225
let path = maybe_entry?.path();
259226
let name = path.file_name().context("broken assets")?;
260227
uilts_install(
261-
sudo,
262228
"644",
263229
&format!("{}", path.display()),
264230
&format!("{sharedir_extension}/{}", name.display()),
265231
)?;
266232
}
267233
uilts_install(
268-
sudo,
269234
"644",
270235
&format!("./sql/install/vchord--{version}.sql"),
271236
&format!("{sharedir_extension}/vchord--{version}.sql"),
@@ -276,7 +241,6 @@ fn main() -> Result<()> {
276241
file.write_all(contents.as_bytes())?;
277242
let path = file.into_temp_path();
278243
uilts_install(
279-
sudo,
280244
"644",
281245
&format!("{}", path.display()),
282246
&format!("{sharedir_extension}/vchord--0.0.0.sql"),
@@ -285,7 +249,7 @@ fn main() -> Result<()> {
285249
Ok(())
286250
};
287251
match cli.command {
288-
Commands::Package(PackageArgs { output }) => {
252+
Commands::Build(BuildArgs { output }) => {
289253
build()?;
290254
let pkglibdir = format!("{output}/pkglibdir");
291255
let sharedir = format!("{output}/sharedir");
@@ -297,25 +261,7 @@ fn main() -> Result<()> {
297261
std::fs::create_dir_all(&pkglibdir)?;
298262
std::fs::create_dir_all(&sharedir)?;
299263
std::fs::create_dir_all(&sharedir_extension)?;
300-
install(false, pkglibdir, sharedir_extension)?;
301-
}
302-
Commands::Install(InstallArgs { sudo, input }) => {
303-
if let Some(input) = input {
304-
uilts_cp(
305-
sudo,
306-
&["-r", &format!("{input}/pkglibdir/."), &map["PKGLIBDIR"]],
307-
)?;
308-
uilts_cp(
309-
sudo,
310-
&["-r", &format!("{input}/sharedir/."), &map["SHAREDIR"]],
311-
)?;
312-
} else {
313-
build()?;
314-
let pkglibdir = map["PKGLIBDIR"].clone();
315-
let sharedir = map["SHAREDIR"].clone();
316-
let sharedir_extension = format!("{sharedir}/extension");
317-
install(sudo, pkglibdir, sharedir_extension)?;
318-
}
264+
install(pkglibdir, sharedir_extension)?;
319265
}
320266
}
321267
Ok(())

0 commit comments

Comments
 (0)