Skip to content

Commit

Permalink
[FEAT] util.sh update extensions.json with jq (lnbits#140)
Browse files Browse the repository at this point in the history
usage: `sh util.sh update_extension example v0.4.2`
  • Loading branch information
dni authored Aug 27, 2023
1 parent 4d27ca6 commit d73b24a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ get lnbits env variables for all extensions
sh util.sh env
```

update a extension in extensions.json with id and version

```sh
sh util.sh update_extension example v0.4.2
```

### Example video on how to release a extension into this repo

this uses a github workflow like this: https://github.com/lnbits/example/blob/main/.github/workflows/release.yml
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"bugs": {
"url": "https://github.com/lnbits/lnbits-extensions/issues"
},
"homepage": "https://extensions.lnbits.org/",
"homepage": "https://extensions.lnbits.com/",
"devDependencies": {
"prettier": "^2.8.8",
"sass": "^1.64.2",
Expand Down
18 changes: 18 additions & 0 deletions util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,29 @@ env() {
echo "LNBITS_EXTENSIONS_DEFAULT_INSTALL=\"$env\""
}

# param: extension id (example)
# param: key (version)
# param: value (v0.0.0)
update_extension_attribute(){
tmp=$(mktemp)
jq --indent 4 --arg id $1 --arg key $2 --arg value $3 \
'( .extensions[] | select(.id == $id) ) |= with_entries(if .key == $key then .value = $value else . end)' \
extensions.json > "$tmp" && mv "$tmp" extensions.json
}

# param: extension id (example)
# param: version (v0.0.0)
update_extension() {
archive="https://github.com/lnbits/$1/archive/ref/tags/$2.zip"
update_extension_attribute $1 version $2
update_extension_attribute $1 archive $archive
update_extension_attribute $1 hash $(wget -O - $archive 2> /dev/null | sha256sum | cut -d" " -f 1)
}

# execute functions
$@

# example
# sh util.sh clone
# sh util.sh pull
# sh util.sh update_extension example "v0.0.0"

0 comments on commit d73b24a

Please sign in to comment.