Fix upload: extract version from artifact, fix bash token syntax
This commit is contained in:
@@ -44,7 +44,11 @@ jobs:
|
||||
env:
|
||||
TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||
run: |
|
||||
$VERSION = (Get-Content src-tauri\tauri.conf.json | ConvertFrom-Json).version
|
||||
# Extract version from built artifact filename
|
||||
$nsis = "src-tauri\target\release\bundle\nsis"
|
||||
$setupExe = Get-ChildItem "$nsis\Cinny_*_x64-setup.exe" | Select-Object -First 1
|
||||
$VERSION = $setupExe.Name -replace 'Cinny_(.+)_x64-setup\.exe','$1'
|
||||
Write-Host "Version: $VERSION"
|
||||
|
||||
# Get or create the latest release
|
||||
$release = Invoke-RestMethod -Uri "$env:GITEA_URL/api/v1/repos/$env:REPO/releases/tags/latest" `
|
||||
@@ -119,32 +123,35 @@ jobs:
|
||||
env:
|
||||
TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||
run: |
|
||||
VERSION=$(python3 -c "import json; print(json.load(open('src-tauri/tauri.conf.json'))['version'])")
|
||||
# Extract version from built artifact filename — no file reads needed
|
||||
DEB=$(ls src-tauri/target/release/bundle/deb/Cinny_*_amd64.deb | head -1)
|
||||
VERSION=$(basename "$DEB" | sed 's/Cinny_\(.*\)_amd64\.deb/\1/')
|
||||
echo "Version: $VERSION"
|
||||
|
||||
# Get or create the latest release
|
||||
RELEASE=$(curl -sf "$GITEA_URL/api/v1/repos/$REPO/releases/tags/latest" \
|
||||
-H "Authorization: token $env:TOKEN" 2>/dev/null || true)
|
||||
-H "Authorization: token $TOKEN" 2>/dev/null || true)
|
||||
RELEASE_ID=$(echo "$RELEASE" | python3 -c "import sys,json; print(json.load(sys.stdin).get('id',''))" 2>/dev/null || true)
|
||||
if [ -z "$RELEASE_ID" ] || [ "$RELEASE_ID" = "None" ]; then
|
||||
RELEASE_ID=$(curl -sf -X POST "$GITEA_URL/api/v1/repos/$REPO/releases" \
|
||||
-H "Authorization: token $env:TOKEN" \
|
||||
-H "Authorization: token $TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"tag_name\":\"latest\",\"name\":\"Lotus Chat $VERSION\",\"prerelease\":true,\"body\":\"Built from ${{ github.sha }}\"}" \
|
||||
| python3 -c "import sys,json; print(json.load(sys.stdin)['id'])")
|
||||
fi
|
||||
|
||||
deb="src-tauri/target/release/bundle/deb/Cinny_${VERSION}_amd64.deb"
|
||||
appimage="src-tauri/target/release/bundle/appimage/Cinny_${VERSION}_amd64.AppImage"
|
||||
declare -A uploads=(
|
||||
["LotusChat-x86_64.deb"]="$deb"
|
||||
["LotusChat-x86_64.AppImage"]="$appimage"
|
||||
["LotusChat-x86_64.AppImage.tar.gz"]="${appimage}.tar.gz"
|
||||
["LotusChat-x86_64.AppImage.tar.gz.sig"]="${appimage}.tar.gz.sig"
|
||||
)
|
||||
for name in "${!uploads[@]}"; do
|
||||
APPIMAGE="src-tauri/target/release/bundle/appimage/Cinny_${VERSION}_amd64.AppImage"
|
||||
for file in \
|
||||
"LotusChat-x86_64.deb|$DEB" \
|
||||
"LotusChat-x86_64.AppImage|${APPIMAGE}" \
|
||||
"LotusChat-x86_64.AppImage.tar.gz|${APPIMAGE}.tar.gz" \
|
||||
"LotusChat-x86_64.AppImage.tar.gz.sig|${APPIMAGE}.tar.gz.sig"; do
|
||||
name="${file%%|*}"
|
||||
path="${file##*|}"
|
||||
echo "Uploading $name"
|
||||
curl -sf -X POST \
|
||||
"$GITEA_URL/api/v1/repos/$REPO/releases/$RELEASE_ID/assets?name=$name" \
|
||||
-H "Authorization: token $env:TOKEN" \
|
||||
-H "Authorization: token $TOKEN" \
|
||||
-H "Content-Type: application/octet-stream" \
|
||||
--data-binary @"${uploads[$name]}"
|
||||
--data-binary @"$path"
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user