Repository navigation
70 lines (66 loc) · 3.68 KB
/
Copy pathdeck.yml
File metadata and controls
70 lines (66 loc) · 3.68 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
name: Deck model
# The extra `deck` pins the deck model, the package ournotes-sim that ournotes-deck publishes with each release, so
# that one nnnotes version always carries one deck model. The pin follows ournotes-deck's releases: when the latest
# release has published its replay and recommendation WASM packages (the engines of music-data --replay-engine and
# --recommend-engine) and its ournotes-sim wheels, and it is past the pinned release, this opens a pull request that
# moves the pin and dispatches CI and the commit message check on its branch (a pull request opened with the workflow
# token starts no workflow by itself); their checks land on the pull request.
on:
schedule:
- cron: "17 3 * * *"
workflow_dispatch:
permissions:
actions: write
contents: write
pull-requests: write
jobs:
update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Compare the pinned release with ournotes-deck's latest release
id: deck
env:
GH_TOKEN: ${{ github.token }}
run: |
pinned=$(sed -nE 's/^deck = \["ournotes-sim==([0-9]+\.[0-9]+\.[0-9]+)"\]$/\1/p' pyproject.toml)
[ -n "$pinned" ] || { echo "pyproject.toml pins no ournotes-sim release" >&2; exit 1; }
release=$(gh api repos/empty-sekai/ournotes-deck/releases/latest)
tag=$(jq -r .tag_name <<< "$release")
version=${tag#v}
published=true
for module in replay recommend; do
jq -e --arg name "ournotes-$module-wasm-$tag.tar.gz" 'any(.assets[]; .name == $name)' <<< "$release" \
> /dev/null || published=false
done
curl -fsS -o /dev/null "https://pypi.org/pypi/ournotes-sim/$version/json" || published=false
# ahead: the release contains the pinned release and more; behind or diverged: leave the pin to a person
status=$(gh api "repos/empty-sekai/ournotes-deck/compare/v$pinned...$tag" --jq .status)
echo "pinned $pinned, latest $version: $status, WASM packages and wheels published: $published"
echo "pinned=$pinned" >> "$GITHUB_OUTPUT"
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "tag=$tag" >> "$GITHUB_OUTPUT"
echo "move=$([ "$status" = ahead ] && [ "$published" = true ] && echo true || echo false)" >> "$GITHUB_OUTPUT"
- name: Move the pin
if: steps.deck.outputs.move == 'true'
run: sed -i -E 's/^(deck = \["ournotes-sim==)${{ steps.deck.outputs.pinned }}("\])$/\1${{ steps.deck.outputs.version }}\2/' pyproject.toml
- uses: peter-evans/create-pull-request@v8
id: pr
if: steps.deck.outputs.move == 'true'
with:
branch: deck/update
commit-message: "build(deck): ournotes-deck ${{ steps.deck.outputs.tag }}"
title: "build(deck): ournotes-deck ${{ steps.deck.outputs.tag }}"
body: |
Moves the deck model to ournotes-deck ${{ steps.deck.outputs.tag }},
https://github.com/empty-sekai/ournotes-deck/releases/tag/${{ steps.deck.outputs.tag }}
Changes: https://github.com/empty-sekai/ournotes-deck/compare/v${{ steps.deck.outputs.pinned }}...${{ steps.deck.outputs.tag }}
Music data files made after this change name the new commit in `provenance.deck.commit`; their deck
statistics may differ.
- name: Check the pull request
if: steps.pr.outputs.pull-request-operation == 'created' || steps.pr.outputs.pull-request-operation == 'updated'
env:
GH_TOKEN: ${{ github.token }}
run: |
gh workflow run ci.yml --repo "$GITHUB_REPOSITORY" --ref deck/update
gh workflow run commitlint.yml --repo "$GITHUB_REPOSITORY" --ref deck/update