nextcloud-notes-desktop/.forgejo/workflows/release.yml
Daniel 6104851b8e
Some checks failed
Release / Build Linux Release (push) Has been cancelled
Add Forgejo release workflow
2026-05-15 16:37:13 +02:00

61 lines
2 KiB
YAML

name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
jobs:
linux-release:
name: Build Linux Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- name: Install dependencies
run: npm ci
- name: Build Linux packages
run: npm run dist:linux -- --publish never
- name: Create Forgejo release
if: startsWith(github.ref, 'refs/tags/v')
env:
FORGEJO_TOKEN: ${{ github.token }}
FORGEJO_API: https://git.danvics.com/api/v1
REPO: ${{ github.repository }}
TAG: ${{ github.ref_name }}
run: |
set -eu
response=$(curl -sS -X POST "$FORGEJO_API/repos/$REPO/releases" \
-H "Authorization: token $FORGEJO_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"tag_name\":\"$TAG\",\"target_commitish\":\"main\",\"name\":\"$TAG\",\"body\":\"Automated Linux desktop build.\",\"draft\":false,\"prerelease\":false}")
release_id=$(node -e "const data = JSON.parse(process.argv[1]); if (!data.id) throw new Error(JSON.stringify(data)); console.log(data.id)" "$response")
echo "release_id=$release_id" >> "$GITHUB_ENV"
- name: Upload release assets
if: startsWith(github.ref, 'refs/tags/v')
env:
FORGEJO_TOKEN: ${{ github.token }}
FORGEJO_API: https://git.danvics.com/api/v1
REPO: ${{ github.repository }}
run: |
set -eu
for artifact in release/*.AppImage release/*.deb; do
[ -f "$artifact" ] || continue
name=$(basename "$artifact")
curl -sS -X POST "$FORGEJO_API/repos/$REPO/releases/$release_id/assets?name=$name" \
-H "Authorization: token $FORGEJO_TOKEN" \
-H "Content-Type: application/octet-stream" \
--data-binary "@$artifact"
done