Fix release asset updates
This commit is contained in:
@@ -78,7 +78,26 @@ jobs:
|
|||||||
REPOSITORY: ${{ gitea.repository }}
|
REPOSITORY: ${{ gitea.repository }}
|
||||||
run: |
|
run: |
|
||||||
set -eu
|
set -eu
|
||||||
upload_url="${SERVER_URL%/}/api/v1/repos/$REPOSITORY/releases/$RELEASE_ID/assets"
|
release_url="${SERVER_URL%/}/api/v1/repos/$REPOSITORY/releases/$RELEASE_ID"
|
||||||
|
upload_url="$release_url/assets"
|
||||||
|
release_json="$(curl -fsS -H "Authorization: token $GITEA_TOKEN" "$release_url")"
|
||||||
|
|
||||||
|
delete_asset_if_exists() {
|
||||||
|
asset_name="$1"
|
||||||
|
asset_id="$(printf '%s' "$release_json" \
|
||||||
|
| tr '{' '\n' \
|
||||||
|
| grep "\"name\":\"$asset_name\"" \
|
||||||
|
| sed -n 's/.*"id":[[:space:]]*\([0-9][0-9]*\).*/\1/p' \
|
||||||
|
| head -n 1)"
|
||||||
|
if [ -n "$asset_id" ]; then
|
||||||
|
curl -fsS -X DELETE "$upload_url/$asset_id" \
|
||||||
|
-H "Authorization: token $GITEA_TOKEN"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
delete_asset_if_exists "$RELEASE_ARCHIVE"
|
||||||
|
delete_asset_if_exists "$RELEASE_SHA256"
|
||||||
|
|
||||||
curl -fsS -X POST "$upload_url?name=$RELEASE_ARCHIVE" \
|
curl -fsS -X POST "$upload_url?name=$RELEASE_ARCHIVE" \
|
||||||
-H "Authorization: token $GITEA_TOKEN" \
|
-H "Authorization: token $GITEA_TOKEN" \
|
||||||
-F "attachment=@$RELEASE_ARCHIVE"
|
-F "attachment=@$RELEASE_ARCHIVE"
|
||||||
|
|||||||
@@ -116,17 +116,16 @@ fn update(force: bool) -> Result<UpdateResult, String> {
|
|||||||
curl -fsSL {} -o \"$tmp/openstock.tar.gz\"\n\
|
curl -fsSL {} -o \"$tmp/openstock.tar.gz\"\n\
|
||||||
tar -xzf \"$tmp/openstock.tar.gz\" -C \"$tmp\"\n\
|
tar -xzf \"$tmp/openstock.tar.gz\" -C \"$tmp\"\n\
|
||||||
test -x \"$tmp/openstock\"\n\
|
test -x \"$tmp/openstock\"\n\
|
||||||
mkdir -p {}\n\
|
install_dir={}\n\
|
||||||
target={}\n\
|
mkdir -p \"$install_dir\"\n\
|
||||||
tmp_target=\"{}/.openstock.tmp.$$\"\n\
|
target=\"$install_dir/openstock\"\n\
|
||||||
|
tmp_target=\"$install_dir/.openstock.tmp.$$\"\n\
|
||||||
cp \"$tmp/openstock\" \"$tmp_target\"\n\
|
cp \"$tmp/openstock\" \"$tmp_target\"\n\
|
||||||
chmod 755 \"$tmp_target\"\n\
|
chmod 755 \"$tmp_target\"\n\
|
||||||
mv -f \"$tmp_target\" \"$target\"\n\
|
mv -f \"$tmp_target\" \"$target\"\n\
|
||||||
printf 'installed: %s\\n' \"$target\"\n",
|
printf 'installed: %s\\n' \"$target\"\n",
|
||||||
shell_quote(&asset.browser_download_url),
|
shell_quote(&asset.browser_download_url),
|
||||||
shell_quote(&install_dir.display().to_string()),
|
shell_quote(&install_dir.display().to_string()),
|
||||||
shell_quote(&install_dir.join("openstock").display().to_string()),
|
|
||||||
shell_quote(&install_dir.display().to_string()),
|
|
||||||
);
|
);
|
||||||
let output = Command::new("sh")
|
let output = Command::new("sh")
|
||||||
.arg("-c")
|
.arg("-c")
|
||||||
|
|||||||
Reference in New Issue
Block a user