Skip to content

Commit

Permalink
simplify upgrade scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
wangfenjin committed Oct 1, 2023
1 parent d130b95 commit 9dff39c
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions upgrade.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
#!/bin/bash

## How to run
## `./upgrade.sh from to`
##
## such as:
## `./upgrade.sh 0.3.1 0.3.2`
## `./upgrade.sh`

if [ "$#" -ne 2 ]
then
echo "Arguments are not equals to 2\n"
echo "./upgrade.sh from to"
exit 1
# https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c
# Usage
# $ get_latest_release "duckdb/duckdb"
get_latest_release() {
curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api
grep '"tag_name":' | # Get tag line
sed -E 's/.*"v([^"]+)".*/\1/' # Pluck JSON value
}

duckdb_version=$(get_latest_release "duckdb/duckdb")
duckdb_rs_version=$(get_latest_release "duckdb/duckdb-rs")

if [ $duckdb_version = $duckdb_rs_version ]; then
echo "Already update to date, latest version is $duckdb_version"
exit 0
fi

sed -i '' "s/$1/$2/g" Cargo.toml libduckdb-sys/upgrade.sh libduckdb-sys/Cargo.toml .github/workflows/rust.yaml
echo "Start to upgrade from $duckdb_version to $duckdb_rs_version"

sed -i '' "s/$duckdb_rs_version/$duckdb_version/g" Cargo.toml libduckdb-sys/upgrade.sh libduckdb-sys/Cargo.toml .github/workflows/rust.yaml
./libduckdb-sys/upgrade.sh

0 comments on commit 9dff39c

Please sign in to comment.