forked from JSKitty/Vector
-
-
Notifications
You must be signed in to change notification settings - Fork 18
54 lines (47 loc) · 2.13 KB
/
Copy pathpreview-pointer.yaml
File metadata and controls
54 lines (47 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
name: 'preview-pointer'
# Preview builds check a single fixed URL for updates:
# releases/download/preview/latest.json
#
# GitHub has no "latest including pre-releases" redirect, so that URL is a
# permanent pointer release whose only asset is the manifest, re-pointed here
# on every publish.
#
# It tracks the newest build of EITHER channel on purpose. Refreshing it when a
# stable release publishes is what carries preview users onto the official
# build instead of stranding them on the last preview; once they install it,
# their client is a stable build reading the stable endpoint, and the two
# channels have converged.
on:
release:
types: [published]
jobs:
repoint:
# Uploading to the pointer publishes nothing, but guard anyway so a manual
# edit of the pointer release can never re-trigger this.
if: github.event.release.tag_name != 'preview'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Point the preview channel at ${{ github.event.release.tag_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ github.event.release.tag_name }}
run: |
set -euo pipefail
if ! gh release download "$TAG" --repo "$GITHUB_REPOSITORY" \
--pattern latest.json --dir . --clobber 2>/dev/null; then
echo "::warning::$TAG has no latest.json asset; preview channel left unchanged."
exit 0
fi
echo "Manifest version: $(jq -r .version latest.json)"
# `--prerelease` is load-bearing: without it the pointer would become
# the repo's /releases/latest and serve previews to the stable channel.
if ! gh release view preview --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
gh release create preview \
--repo "$GITHUB_REPOSITORY" \
--prerelease \
--title 'Preview channel' \
--notes 'Update manifest for Vector preview builds. Nothing to download here; the manifest points at the real release.'
fi
gh release upload preview latest.json --clobber --repo "$GITHUB_REPOSITORY"