Drop prepare-release job, each build gets-or-creates the release
This commit is contained in:
@@ -10,41 +10,7 @@ env:
|
||||
REPO: LotusGuild/cinny-desktop
|
||||
|
||||
jobs:
|
||||
prepare-release:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
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:
|
||||
- uses: actions/checkout@v4
|
||||
@@ -84,9 +50,19 @@ jobs:
|
||||
shell: powershell
|
||||
env:
|
||||
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
RELEASE_ID: ${{ needs.prepare-release.outputs.release_id }}
|
||||
VERSION: ${{ needs.prepare-release.outputs.version }}
|
||||
VERSION: ${{ steps.version.outputs.version }}
|
||||
run: |
|
||||
# Get or create the latest release
|
||||
$release = Invoke-RestMethod -Uri "$env:GITEA_URL/api/v1/repos/$env:REPO/releases/tags/latest" `
|
||||
-Headers @{ Authorization = "token $TOKEN" } -ErrorAction SilentlyContinue
|
||||
if (-not $release) {
|
||||
$release = Invoke-RestMethod -Uri "$env:GITEA_URL/api/v1/repos/$env:REPO/releases" `
|
||||
-Method Post `
|
||||
-Headers @{ Authorization = "token $TOKEN"; "Content-Type" = "application/json" } `
|
||||
-Body "{`"tag_name`":`"latest`",`"name`":`"Lotus Chat $VERSION`",`"prerelease`":true,`"body`":`"Built from ${{ github.sha }}`"}"
|
||||
}
|
||||
$releaseId = $release.id
|
||||
|
||||
$nsis = "src-tauri\target\release\bundle\nsis"
|
||||
$files = @(
|
||||
"$nsis\Cinny_${VERSION}_x64-setup.exe",
|
||||
@@ -96,14 +72,13 @@ jobs:
|
||||
$names = @("LotusChat-x86_64-setup.exe", "LotusChat-x86_64-setup.nsis.zip", "LotusChat-x86_64-setup.nsis.zip.sig")
|
||||
for ($i = 0; $i -lt $files.Length; $i++) {
|
||||
$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])" `
|
||||
Invoke-RestMethod -Uri "$env:GITEA_URL/api/v1/repos/$env:REPO/releases/$releaseId/assets?name=$($names[$i])" `
|
||||
-Method Post `
|
||||
-Headers @{ Authorization = "token $TOKEN"; "Content-Type" = "application/octet-stream" } `
|
||||
-Body $bytes
|
||||
}
|
||||
|
||||
build-linux:
|
||||
needs: prepare-release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@@ -154,9 +129,20 @@ jobs:
|
||||
- name: Upload to release
|
||||
env:
|
||||
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
RELEASE_ID: ${{ needs.prepare-release.outputs.release_id }}
|
||||
VERSION: ${{ steps.version.outputs.version }}
|
||||
run: |
|
||||
# Get or create the latest release
|
||||
RELEASE=$(curl -sf "$GITEA_URL/api/v1/repos/$REPO/releases/tags/latest" \
|
||||
-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 $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=(
|
||||
|
||||
Reference in New Issue
Block a user