nextcloud-notes-desktop/.forgejo/workflows/release.yml
Daniel 0076b37a23
Some checks failed
Release / Build Linux (push) Has been cancelled
Release / Build macOS (push) Has been cancelled
Use Forgejo runners for release builds
2026-05-15 16:39:18 +02:00

79 lines
2.7 KiB
YAML

name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
jobs:
build:
name: Build ${{ matrix.name }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- name: Linux
runner: ubuntu-latest
command: npm run dist:linux -- --publish never
artifacts: "release/*.AppImage release/*.deb"
- name: macOS
runner: macos-latest
command: npm run dist:mac -- --publish never
artifacts: "release/*.dmg release/*.zip"
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 packages
run: ${{ matrix.command }}
- name: Create or find 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 "$FORGEJO_API/repos/$REPO/releases/tags/$TAG" \
-H "Authorization: token $FORGEJO_TOKEN")
release_id=$(node -e "const data = JSON.parse(process.argv[1]); console.log(data.id || '')" "$response")
if [ -z "$release_id" ]; then
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 desktop builds from Forgejo runners.\",\"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")
fi
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 }}
ARTIFACTS: ${{ matrix.artifacts }}
run: |
set -eu
for artifact in $ARTIFACTS; 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