Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2290ac5ecf | |||
| 45294b6299 | |||
| 6101e8d462 | |||
| 6ddd9928fc |
@ -92,20 +92,71 @@ jobs:
|
|||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
response=$(curl -sS -X POST "$api_url" \
|
echo "Creating release with tag: $RELEASE_TAG"
|
||||||
|
echo "API URL: $api_url"
|
||||||
|
echo "Target commit: $RELEASE_TARGET"
|
||||||
|
|
||||||
|
http_code=$(curl -sS -w "%{http_code}" -o /tmp/release_response.json -X POST "$api_url" \
|
||||||
-H "Authorization: token $GITEA_TOKEN" \
|
-H "Authorization: token $GITEA_TOKEN" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "$payload")
|
-d "$payload")
|
||||||
release_id=$(echo "$response" | grep -o '"id":[0-9]*' | head -n 1 | grep -o '[0-9]*')
|
|
||||||
if [ -z "$release_id" ] || echo "$response" | grep -q '"message"'; then
|
response=$(cat /tmp/release_response.json)
|
||||||
echo "Create release failed: $response"
|
echo "HTTP Status: $http_code"
|
||||||
|
echo "Response: $response"
|
||||||
|
|
||||||
|
if [ "$http_code" -ne 201 ]; then
|
||||||
|
echo "Failed to create release (HTTP $http_code)"
|
||||||
|
if echo "$response" | grep -q "already exists"; then
|
||||||
|
echo "Release with tag $RELEASE_TAG already exists"
|
||||||
|
fi
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
release_id=$(echo "$response" | grep -oP '"id":\K[0-9]+' | head -n 1 || true)
|
||||||
|
if [ -z "$release_id" ]; then
|
||||||
|
echo "Failed to extract release ID from response"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "Release created: id=$release_id"
|
echo "Release created: id=$release_id"
|
||||||
|
|
||||||
|
echo "Listing jar files in target directory:"
|
||||||
|
ls -lh target/*.jar || echo "No jar files found"
|
||||||
|
|
||||||
|
upload_count=0
|
||||||
for asset_path in target/*.jar; do
|
for asset_path in target/*.jar; do
|
||||||
|
if [ ! -f "$asset_path" ]; then
|
||||||
|
echo "Skipping non-existent file: $asset_path"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
asset_name=$(basename "$asset_path")
|
asset_name=$(basename "$asset_path")
|
||||||
curl -sS -X POST "$api_url/$release_id/assets?name=$asset_name" \
|
file_size=$(stat -c%s "$asset_path" 2>/dev/null || echo "unknown")
|
||||||
|
echo "Uploading asset: $asset_name (size: $file_size bytes)"
|
||||||
|
|
||||||
|
upload_url="$api_url/$release_id/assets?name=$asset_name"
|
||||||
|
echo "Upload URL: $upload_url"
|
||||||
|
|
||||||
|
set +e
|
||||||
|
http_code=$(curl -sS -w "%{http_code}" -o /tmp/asset_response.json -X POST "$upload_url" \
|
||||||
-H "Authorization: token $GITEA_TOKEN" \
|
-H "Authorization: token $GITEA_TOKEN" \
|
||||||
-H "Content-Type: application/octet-stream" \
|
-H "Content-Type: application/octet-stream" \
|
||||||
--data-binary @"$asset_path"
|
--data-binary @"$asset_path" 2>/dev/null)
|
||||||
|
curl_exit=$?
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ $curl_exit -ne 0 ]; then
|
||||||
|
echo "✗ Curl failed with exit code $curl_exit for $asset_name"
|
||||||
|
cat /tmp/asset_response.json 2>/dev/null || echo "No response file"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$http_code" = "201" ]; then
|
||||||
|
echo "✓ Successfully uploaded: $asset_name"
|
||||||
|
upload_count=$((upload_count + 1))
|
||||||
|
else
|
||||||
|
echo "✗ Failed to upload $asset_name (HTTP $http_code)"
|
||||||
|
cat /tmp/asset_response.json 2>/dev/null || echo "No response body"
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
echo "Upload complete: $upload_count file(s) uploaded"
|
||||||
|
|||||||
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>com.imyeyu.network</groupId>
|
<groupId>com.imyeyu.network</groupId>
|
||||||
<artifactId>timi-network</artifactId>
|
<artifactId>timi-network</artifactId>
|
||||||
<version>0.0.2</version>
|
<version>0.0.3</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|||||||
@ -35,6 +35,36 @@ public class ArgMap<K, V> extends HashMap<K, V> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String toURL(String url) {
|
public String toURL(String url) {
|
||||||
return url + "?" + toURL();
|
StringBuilder sb = new StringBuilder(url);
|
||||||
|
if (url.contains("?")) {
|
||||||
|
if (!url.endsWith("?") && !url.endsWith("&")) {
|
||||||
|
sb.append('&');
|
||||||
|
}
|
||||||
|
sb.append(toURL());
|
||||||
|
return sb.toString();
|
||||||
|
} else {
|
||||||
|
return url + "?" + toURL();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <K, V> ArgMap<K, V> of(K key, V value) {
|
||||||
|
ArgMap<K, V> map = new ArgMap<>();
|
||||||
|
map.put(key, value);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <K, V> ArgMap<K, V> of(K key1, V value1, K key2, V value2) {
|
||||||
|
ArgMap<K, V> map = new ArgMap<>();
|
||||||
|
map.put(key1, value1);
|
||||||
|
map.put(key2, value2);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <K, V> ArgMap<K, V> of(K key1, V value1, K key2, V value2, K key3, V value3) {
|
||||||
|
ArgMap<K, V> map = new ArgMap<>();
|
||||||
|
map.put(key1, value1);
|
||||||
|
map.put(key2, value2);
|
||||||
|
map.put(key3, value3);
|
||||||
|
return map;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
27
src/test/java/com/imyeyu/network/test/ArgMapTest.java
Normal file
27
src/test/java/com/imyeyu/network/test/ArgMapTest.java
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package com.imyeyu.network.test;
|
||||||
|
|
||||||
|
import com.imyeyu.network.ArgMap;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author 夜雨
|
||||||
|
* @since 2026-02-10 12:45
|
||||||
|
*/
|
||||||
|
public class ArgMapTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void toURLTest() {
|
||||||
|
assert ArgMap.of("key", "value").toURL("/detail").equals("/detail?key=value");
|
||||||
|
assert ArgMap.of("key", "value").toURL("/detail?").equals("/detail?key=value");
|
||||||
|
assert ArgMap.of("key", "value").toURL("/detail?id=123").equals("/detail?id=123&key=value");
|
||||||
|
assert ArgMap.of("key", "value").toURL("/detail?id=123&").equals("/detail?id=123&key=value");
|
||||||
|
assert ArgMap.of("key", "value").toURL("http://localhost/detail").equals("http://localhost/detail?key=value");
|
||||||
|
assert ArgMap.of("key", "value").toURL("http://localhost/detail?").equals("http://localhost/detail?key=value");
|
||||||
|
|
||||||
|
String uri = ArgMap.of("key", "value").toURL("/detail?id=123");
|
||||||
|
String url = ArgMap.of("newKey", "newValue").toURL("http://localhost/test" + uri);
|
||||||
|
assert url.equals("http://localhost/test/detail?id=123&key=value&newKey=newValue");
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user