Skip to content

fix(flatpak): replace gh CLI with curl in upload step — gh not in con… #12

fix(flatpak): replace gh CLI with curl in upload step — gh not in con…

fix(flatpak): replace gh CLI with curl in upload step — gh not in con… #12

Workflow file for this run

name: Flatpak
on:
push:
tags:
- "v*"
workflow_dispatch:
permissions:
contents: write
jobs:
build-flatpak:
name: Build Flatpak (Ubuntu 24.04)
runs-on: ubuntu-24.04
container:
image: bilelmoussaoui/flatpak-github-actions:freedesktop-24.08
options: --privileged
steps:
- uses: actions/checkout@v6
- name: Validate Flatpak manifest
run: bash tests/packaging/flatpak_validate.sh
- name: Install Rust SDK extension
run: |
flatpak remote-add --if-not-exists flathub \
https://flathub.org/repo/flathub.flatpakrepo
flatpak install --noninteractive flathub \
org.freedesktop.Sdk.Extension.rust-stable//24.08 \
org.freedesktop.Sdk.Extension.llvm18//24.08
- name: Build with flatpak-builder
run: |
flatpak-builder \
--repo=repo \
--install-deps-from=flathub \
--force-clean \
builddir \
packaging/flatpak/io.github.thewrz.HonkHonk.yml
- name: Bundle
run: |
flatpak build-bundle repo honkhonk.flatpak io.github.thewrz.HonkHonk
- name: Upload Flatpak artifact
uses: actions/upload-artifact@v4
with:
name: honkhonk-flatpak-${{ github.ref_name }}
path: honkhonk.flatpak
- name: Attach Flatpak to GitHub Release
if: startsWith(github.ref, 'refs/tags/')
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG_NAME: ${{ github.ref_name }}
REPO: ${{ github.repository }}
run: |
for i in $(seq 1 30); do
HTTP=$(curl -sf -o /dev/null -w "%{http_code}" \
-H "Authorization: token $GH_TOKEN" \
"https://api.github.com/repos/$REPO/releases/tags/$TAG_NAME")
[ "$HTTP" = "200" ] && break
echo "Waiting for release... ($i/30)"
sleep 10
done
[ "$HTTP" = "200" ] || { echo "Release not found after 5 minutes"; exit 1; }
RELEASE=$(curl -sf \
-H "Authorization: token $GH_TOKEN" \
"https://api.github.com/repos/$REPO/releases/tags/$TAG_NAME")
ASSET_ID=$(echo "$RELEASE" | python3 -c "
import sys, json

Check failure on line 75 in .github/workflows/flatpak.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/flatpak.yml

Invalid workflow file

You have an error in your yaml syntax on line 75
data = json.load(sys.stdin)
for a in data.get('assets', []):
if a['name'] == 'honkhonk.flatpak':
print(a['id'])
break
" 2>/dev/null)
[ -n "$ASSET_ID" ] && curl -sf -X DELETE \
-H "Authorization: token $GH_TOKEN" \
"https://api.github.com/repos/$REPO/releases/assets/$ASSET_ID"
UPLOAD_URL=$(echo "$RELEASE" | python3 -c "
import sys, json; print(json.load(sys.stdin)['upload_url'].split('{')[0])
")
curl -sf \
-H "Authorization: token $GH_TOKEN" \
-H "Content-Type: application/octet-stream" \
"$UPLOAD_URL?name=honkhonk.flatpak" \
--data-binary @honkhonk.flatpak