sanctum/.github/workflows/build.yml
MiTHRAL 95bb71b60f
Some checks failed
/ Build App (push) Failing after 1m37s
ci: fix release asset upload to use multipart form, handle existing releases
2026-04-22 18:09:04 -04:00

69 lines
2.3 KiB
YAML

on:
push:
branches:
- main
tags:
- 'v*'
pull_request:
permissions:
contents: write
jobs:
build:
name: Build App
runs-on: docker
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Checkout assets
run: git -c submodule."assets".update=checkout submodule update --init assets
- name: Install pnpm
run: npm install -g pnpm@10.18.1
- name: Install dependencies
run: pnpm install
- name: Install zip
run: apt-get update && apt-get install -y zip
- name: Build Linux
run: pnpm exec electron-forge make --platform linux --arch x64 --targets @electron-forge/maker-zip
- name: Build Windows
run: pnpm exec electron-forge make --platform win32 --arch x64 --targets @electron-forge/maker-zip
- name: Create release and upload artifacts
if: startsWith(github.ref, 'refs/tags/v')
env:
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ github.ref_name }}
run: |
# Reuse existing release if already created (handles re-runs)
RESPONSE=$(curl -s \
"https://git.mithraic.cloud/api/v1/repos/ad3laid3/sanctum/releases/tags/$TAG" \
-H "Authorization: token $GITEA_TOKEN")
RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | head -1 | grep -o '[0-9]*')
if [ -z "$RELEASE_ID" ]; then
RESPONSE=$(curl -sf -X POST \
"https://git.mithraic.cloud/api/v1/repos/ad3laid3/sanctum/releases" \
-H "Authorization: token $GITEA_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"tag_name\":\"$TAG\",\"name\":\"Sanctum $TAG\",\"draft\":false,\"prerelease\":false}")
RELEASE_ID=$(echo "$RESPONSE" | grep -o '"id":[0-9]*' | head -1 | grep -o '[0-9]*')
fi
echo "Release ID: $RELEASE_ID"
find out/make -type f -name "*.zip" | while read FILE; do
NAME=$(basename "$FILE")
echo "Uploading $NAME..."
curl -sf -X POST \
"https://git.mithraic.cloud/api/v1/repos/ad3laid3/sanctum/releases/$RELEASE_ID/assets?name=$NAME" \
-H "Authorization: token $GITEA_TOKEN" \
-F "attachment=@$FILE"
done