The main repo's Releases page was empty: the installers live only on yetone/magpie-releases, which is bad for finding magpie and confusing to people who look here first. A new mirror-release job, after the dispatch, waits (up to an hour, every 30s) until the magpie-releases release for the tag has 16 assets, downloads them, and creates the same release here with GITHUB_TOKEN (contents: write): title "magpie vX", the same notes plus a link to the magpie-releases page. A rerun edits the notes and replaces the assets. It fails when fewer than 16 land here. Nothing reads this repo's releases: self-update (internal/update), install.sh and the site's /api/latest still read magpie-releases, unchanged. A release made with GITHUB_TOKEN triggers no workflow, and none here listens for release events. Run: YAML parses; the wait and download half by hand against v0.1.1191 (16 assets, 554M, title "magpie v0.1.1191"). The create half runs for the first time on the next tag.
97 lines
3.8 KiB
YAML
97 lines
3.8 KiB
YAML
name: Release
|
|
|
|
# Pushing a v* tag hands off to yetone/magpie-releases, which builds, signs,
|
|
# notarises and publishes magpie there; that repo is where people download
|
|
# from, and the signing secrets live only there. Once its release has every
|
|
# asset, the same release is copied here, so this repo's Releases page has
|
|
# the installers too (PapainTea on X). Self-update, install.sh and the site
|
|
# still read magpie-releases only.
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
workflow_dispatch:
|
|
inputs:
|
|
version:
|
|
description: 'Version to release (e.g., 0.1.0 — no v prefix; the v tag must exist)'
|
|
required: true
|
|
type: string
|
|
|
|
jobs:
|
|
trigger-release:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
version: ${{ steps.version.outputs.version }}
|
|
ref: ${{ steps.version.outputs.ref }}
|
|
|
|
steps:
|
|
- name: Get version
|
|
id: version
|
|
env:
|
|
INPUT_VERSION: ${{ github.event.inputs.version }}
|
|
run: |
|
|
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
|
|
REF="$GITHUB_REF_NAME"
|
|
VERSION="${REF#v}"
|
|
else
|
|
VERSION="$INPUT_VERSION"
|
|
REF="v$INPUT_VERSION"
|
|
fi
|
|
# a newline or quote would add outputs or break the JSON below
|
|
[[ "$VERSION" =~ ^[0-9][0-9A-Za-z.+-]*$ ]] || { echo "bad version: $VERSION" >&2; exit 1; }
|
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
echo "ref=$REF" >> $GITHUB_OUTPUT
|
|
echo "Triggering release for version: $VERSION (ref: $REF)"
|
|
|
|
- name: Trigger release workflow in magpie-releases
|
|
uses: peter-evans/repository-dispatch@v3
|
|
with:
|
|
# PAT with contents write on yetone/magpie-releases.
|
|
token: ${{ secrets.RELEASES_REPO_TOKEN }}
|
|
repository: yetone/magpie-releases
|
|
event-type: release
|
|
client-payload: '{"ref": "${{ steps.version.outputs.ref }}", "version": "${{ steps.version.outputs.version }}"}'
|
|
|
|
- name: Output status
|
|
run: echo "Watch the build at https://github.com/yetone/magpie-releases/actions"
|
|
|
|
mirror-release:
|
|
needs: trigger-release
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 75
|
|
permissions:
|
|
contents: write
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
REF: ${{ needs.trigger-release.outputs.ref }}
|
|
ASSETS: 16 # what every release carries; a smaller count is still uploading
|
|
steps:
|
|
- name: Wait for magpie-releases to publish every asset
|
|
run: |
|
|
for i in $(seq 1 120); do
|
|
n=$(gh release view "$REF" -R yetone/magpie-releases --json assets -q '.assets | length' 2>/dev/null || echo 0)
|
|
echo "attempt $i: $n of $ASSETS assets"
|
|
[ "$n" -ge "$ASSETS" ] && exit 0
|
|
sleep 30
|
|
done
|
|
echo "magpie-releases never published $REF with $ASSETS assets" >&2
|
|
exit 1
|
|
|
|
- name: Copy the release here
|
|
run: |
|
|
set -euo pipefail
|
|
mkdir -p dist
|
|
gh release download "$REF" -R yetone/magpie-releases -D dist
|
|
gh release view "$REF" -R yetone/magpie-releases --json body -q .body > notes.md
|
|
printf '\n\n---\nThe same release, and the feed magpie updates from: https://github.com/yetone/magpie-releases/releases/tag/%s\n' "$REF" >> notes.md
|
|
if gh release view "$REF" -R "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
|
|
gh release edit "$REF" -R "$GITHUB_REPOSITORY" --notes-file notes.md
|
|
gh release upload "$REF" dist/* -R "$GITHUB_REPOSITORY" --clobber
|
|
else
|
|
gh release create "$REF" dist/* -R "$GITHUB_REPOSITORY" --verify-tag --title "magpie $REF" --notes-file notes.md
|
|
fi
|
|
n=$(gh release view "$REF" -R "$GITHUB_REPOSITORY" --json assets -q '.assets | length')
|
|
echo "$REF has $n assets here"
|
|
[ "$n" -ge "$ASSETS" ]
|