Restructure: publish direct to release, no artifact storage
This commit is contained in:
@@ -5,11 +5,47 @@ on:
|
|||||||
branches: [main]
|
branches: [main]
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
|
env:
|
||||||
|
GITEA_URL: https://code.lotusguild.org
|
||||||
|
REPO: LotusGuild/cinny-desktop
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-windows:
|
prepare-release:
|
||||||
runs-on: windows
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
version: ${{ steps.version.outputs.version }}
|
release_id: ${{ steps.create.outputs.release_id }}
|
||||||
|
version: ${{ steps.create.outputs.version }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Create rolling latest release
|
||||||
|
id: create
|
||||||
|
env:
|
||||||
|
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: |
|
||||||
|
VERSION=$(python3 -c "import json; print(json.load(open('src-tauri/tauri.conf.json'))['version'])")
|
||||||
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
# Delete existing latest release+tag if present
|
||||||
|
OLD=$(curl -sf "$GITEA_URL/api/v1/repos/$REPO/releases/tags/latest" \
|
||||||
|
-H "Authorization: token $TOKEN" 2>/dev/null || true)
|
||||||
|
OLD_ID=$(echo "$OLD" | python3 -c "import sys,json; print(json.load(sys.stdin).get('id',''))" 2>/dev/null || true)
|
||||||
|
if [ -n "$OLD_ID" ] && [ "$OLD_ID" != "None" ] && [ "$OLD_ID" != "" ]; then
|
||||||
|
curl -sf -X DELETE "$GITEA_URL/api/v1/repos/$REPO/releases/$OLD_ID" -H "Authorization: token $TOKEN" || true
|
||||||
|
curl -f -X DELETE "$GITEA_URL/api/v1/repos/$REPO/tags/latest" -H "Authorization: token $TOKEN" || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create fresh release
|
||||||
|
RELEASE_ID=$(curl -sf -X POST "$GITEA_URL/api/v1/repos/$REPO/releases" \
|
||||||
|
-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'])")
|
||||||
|
echo "release_id=$RELEASE_ID" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
build-windows:
|
||||||
|
needs: prepare-release
|
||||||
|
runs-on: windows
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
@@ -42,25 +78,31 @@ jobs:
|
|||||||
NODE_OPTIONS: '--max_old_space_size=4096'
|
NODE_OPTIONS: '--max_old_space_size=4096'
|
||||||
run: npm run tauri -- build
|
run: npm run tauri -- build
|
||||||
|
|
||||||
- name: Stage artifacts
|
- name: Upload to release
|
||||||
shell: powershell
|
shell: powershell
|
||||||
|
env:
|
||||||
|
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
RELEASE_ID: ${{ needs.prepare-release.outputs.release_id }}
|
||||||
|
VERSION: ${{ needs.prepare-release.outputs.version }}
|
||||||
run: |
|
run: |
|
||||||
$v = "${{ steps.version.outputs.version }}"
|
|
||||||
New-Item -ItemType Directory -Force dist | Out-Null
|
|
||||||
$msi = "src-tauri\target\release\bundle\msi"
|
$msi = "src-tauri\target\release\bundle\msi"
|
||||||
Copy-Item "$msi\Cinny_${v}_x64_en-US.msi" dist\LotusChat-x86_64.msi
|
$files = @(
|
||||||
Copy-Item "$msi\Cinny_${v}_x64_en-US.msi.zip" dist\LotusChat-x86_64.msi.zip
|
"$msi\Cinny_${VERSION}_x64_en-US.msi",
|
||||||
Copy-Item "$msi\Cinny_${v}_x64_en-US.msi.zip.sig" dist\LotusChat-x86_64.msi.zip.sig
|
"$msi\Cinny_${VERSION}_x64_en-US.msi.zip",
|
||||||
|
"$msi\Cinny_${VERSION}_x64_en-US.msi.zip.sig"
|
||||||
- uses: actions/upload-artifact@v4
|
)
|
||||||
with:
|
$names = @("LotusChat-x86_64.msi", "LotusChat-x86_64.msi.zip", "LotusChat-x86_64.msi.zip.sig")
|
||||||
name: windows
|
for ($i = 0; $i -lt $files.Length; $i++) {
|
||||||
path: dist/
|
$bytes = [System.IO.File]::ReadAllBytes($files[$i])
|
||||||
|
Invoke-RestMethod -Uri "$env:GITEA_URL/api/v1/repos/$env:REPO/releases/$RELEASE_ID/assets?name=$($names[$i])" `
|
||||||
|
-Method Post `
|
||||||
|
-Headers @{ Authorization = "token $TOKEN"; "Content-Type" = "application/octet-stream" } `
|
||||||
|
-Body $bytes
|
||||||
|
}
|
||||||
|
|
||||||
build-linux:
|
build-linux:
|
||||||
|
needs: prepare-release
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
|
||||||
version: ${{ steps.version.outputs.version }}
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
@@ -107,71 +149,25 @@ jobs:
|
|||||||
NODE_OPTIONS: '--max_old_space_size=4096'
|
NODE_OPTIONS: '--max_old_space_size=4096'
|
||||||
run: npm run tauri -- build
|
run: npm run tauri -- build
|
||||||
|
|
||||||
- name: Stage artifacts
|
- name: Upload to release
|
||||||
run: |
|
|
||||||
v="${{ steps.version.outputs.version }}"
|
|
||||||
mkdir dist
|
|
||||||
cp "src-tauri/target/release/bundle/deb/Cinny_${v}_amd64.deb" dist/LotusChat-x86_64.deb
|
|
||||||
cp "src-tauri/target/release/bundle/appimage/Cinny_${v}_amd64.AppImage" dist/LotusChat-x86_64.AppImage
|
|
||||||
cp "src-tauri/target/release/bundle/appimage/Cinny_${v}_amd64.AppImage.tar.gz" dist/LotusChat-x86_64.AppImage.tar.gz
|
|
||||||
cp "src-tauri/target/release/bundle/appimage/Cinny_${v}_amd64.AppImage.tar.gz.sig" dist/LotusChat-x86_64.AppImage.tar.gz.sig
|
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: linux
|
|
||||||
path: dist/
|
|
||||||
|
|
||||||
publish:
|
|
||||||
needs: [build-windows, build-linux]
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
env:
|
|
||||||
GITEA_URL: https://code.lotusguild.org
|
|
||||||
REPO: LotusGuild/cinny-desktop
|
|
||||||
steps:
|
|
||||||
- name: Install deps
|
|
||||||
run: apt-get update && apt-get install -y curl python3
|
|
||||||
|
|
||||||
- uses: actions/download-artifact@v4
|
|
||||||
with:
|
|
||||||
name: windows
|
|
||||||
path: dist/
|
|
||||||
|
|
||||||
- uses: actions/download-artifact@v4
|
|
||||||
with:
|
|
||||||
name: linux
|
|
||||||
path: dist/
|
|
||||||
|
|
||||||
- name: Publish rolling latest release
|
|
||||||
env:
|
env:
|
||||||
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
VERSION: ${{ needs.build-windows.outputs.version }}
|
RELEASE_ID: ${{ needs.prepare-release.outputs.release_id }}
|
||||||
|
VERSION: ${{ steps.version.outputs.version }}
|
||||||
run: |
|
run: |
|
||||||
# Delete existing 'latest' release+tag if present
|
deb="src-tauri/target/release/bundle/deb/Cinny_${VERSION}_amd64.deb"
|
||||||
OLD_ID=$(curl -sf "$GITEA_URL/api/v1/repos/$REPO/releases/tags/latest" \
|
appimage="src-tauri/target/release/bundle/appimage/Cinny_${VERSION}_amd64.AppImage"
|
||||||
-H "Authorization: token $TOKEN" \
|
declare -A uploads=(
|
||||||
| python3 -c "import sys,json; print(json.load(sys.stdin).get('id',''))" 2>/dev/null || true)
|
["LotusChat-x86_64.deb"]="$deb"
|
||||||
if [ -n "$OLD_ID" ] && [ "$OLD_ID" != "None" ] && [ "$OLD_ID" != "" ]; then
|
["LotusChat-x86_64.AppImage"]="$appimage"
|
||||||
curl -sf -X DELETE "$GITEA_URL/api/v1/repos/$REPO/releases/$OLD_ID" \
|
["LotusChat-x86_64.AppImage.tar.gz"]="${appimage}.tar.gz"
|
||||||
-H "Authorization: token $TOKEN"
|
["LotusChat-x86_64.AppImage.tar.gz.sig"]="${appimage}.tar.gz.sig"
|
||||||
curl -f -X DELETE "$GITEA_URL/api/v1/repos/$REPO/tags/latest" \
|
)
|
||||||
-H "Authorization: token $TOKEN" || true
|
for name in "${!uploads[@]}"; do
|
||||||
fi
|
echo "Uploading $name"
|
||||||
|
|
||||||
# Create fresh release
|
|
||||||
RELEASE_ID=$(curl -sf -X POST "$GITEA_URL/api/v1/repos/$REPO/releases" \
|
|
||||||
-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'])")
|
|
||||||
|
|
||||||
# Upload all artifacts
|
|
||||||
for f in dist/*; do
|
|
||||||
[ -f "$f" ] || continue
|
|
||||||
fname=$(basename "$f")
|
|
||||||
echo "Uploading $fname"
|
|
||||||
curl -sf -X POST \
|
curl -sf -X POST \
|
||||||
"$GITEA_URL/api/v1/repos/$REPO/releases/$RELEASE_ID/assets?name=$fname" \
|
"$GITEA_URL/api/v1/repos/$REPO/releases/$RELEASE_ID/assets?name=$name" \
|
||||||
-H "Authorization: token $TOKEN" \
|
-H "Authorization: token $TOKEN" \
|
||||||
-H "Content-Type: application/octet-stream" \
|
-H "Content-Type: application/octet-stream" \
|
||||||
--data-binary @"$f"
|
--data-binary @"${uploads[$name]}"
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user