Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/actions/animathio-cli/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Released AniMathIO CLI
description: Download a released AniMathIO AppImage, verify its SHA-256 and extract animathio-cli.
inputs:
github-token:
description: Token for `gh release download` (the release is public).
required: true
tag:
description: AniMathIO release tag.
default: v2.1.0
asset:
description: AppImage asset name.
default: animathio_2.1.0_x86_64.AppImage
sha256:
description: Pinned SHA-256 of the asset.
default: cce18dd8215aa9c23ba7c5756e6c0785c1931dd027aadf31a7bbbf3b92fac6ec
outputs:
cli:
description: Absolute path of the extracted animathio-cli.
value: ${{ steps.extract.outputs.cli }}
runs:
using: composite
steps:
- id: extract
shell: bash
env:
GH_TOKEN: ${{ inputs.github-token }}
TAG: ${{ inputs.tag }}
ASSET: ${{ inputs.asset }}
SHA256: ${{ inputs.sha256 }}
run: |
set -euo pipefail
dir="$RUNNER_TEMP/animathio-cli"
mkdir -p "$dir"
gh release download "$TAG" --repo AniMathIO/AniMathIO --pattern "$ASSET" --dir "$dir"
echo "$SHA256 $dir/$ASSET" | sha256sum -c -
chmod +x "$dir/$ASSET"
(cd "$dir" && "./$ASSET" --appimage-extract > /dev/null)
echo "cli=$dir/squashfs-root/usr/bin/animathio-cli" >> "$GITHUB_OUTPUT"
76 changes: 76 additions & 0 deletions .github/workflows/index.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Community index
# Regenerates community-index.json (the single static file the editor reads) from
# community-plugins.json and the GitHub releases it points at. See docs/registry.md.
on:
workflow_call:
workflow_dispatch:
schedule:
# Plugins released from their own repositories are picked up within hours.
- cron: "17 */6 * * *"
push:
branches: [main]
paths:
- community-plugins.json
- schemas/community-index.schema.json
- scripts/registry.py
concurrency:
group: community-index
cancel-in-progress: false
permissions:
contents: read
jobs:
generate:
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: main
persist-credentials: false
- run: python3 -m pip install -r scripts/requirements.txt
- name: Regenerate community-index.json
env:
GH_TOKEN: ${{ github.token }}
# Not strict: a plugin whose release cannot be verified keeps its previous entry
# (or is left out) and a warning annotation is raised; the other plugins still update.
run: python3 scripts/registry.py index
- name: Upload the index
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: community-index
path: community-index.json
if-no-files-found: error
commit:
needs: generate
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: write
# Only copy and commit data on this runner; no repository scripts or plugin code.
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: main
persist-credentials: false
- name: Download the index
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: community-index
path: ${{ runner.temp }}/generated-index
- name: Commit the index
env:
GH_TOKEN: ${{ github.token }}
run: |
cp "$RUNNER_TEMP/generated-index/community-index.json" community-index.json
if git diff --quiet -- community-index.json; then
echo "community-index.json is up to date"
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add community-index.json
git -c core.hooksPath=/dev/null commit -m "chore(registry): update community-index.json"
auth=$(printf 'x-access-token:%s' "$GH_TOKEN" | base64 -w0)
git -c "http.https://github.com/.extraheader=AUTHORIZATION: basic $auth" push origin HEAD:main
74 changes: 74 additions & 0 deletions .github/workflows/registry.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Registry
# Submission checks for community-plugins.json (see docs/registry.md and CONTRIBUTING.md).
on:
pull_request:
paths:
- community-plugins.json
- community/**
- schemas/**
- scripts/registry*.py
- scripts/check_submission.py
- scripts/test_registry.py
- scripts/requirements.txt
- README.md
- .github/workflows/registry.yml
- .github/actions/**
push:
branches: [main]
paths:
- community-plugins.json
- schemas/**
- scripts/**
- .github/workflows/registry.yml
workflow_dispatch:
permissions:
contents: read
jobs:
registry:
runs-on: ubuntu-latest
timeout-minutes: 45
env:
CARGO_BUILD_JOBS: 3
CARGO_PROFILE_DEV_DEBUG: 0
CARGO_INCREMENTAL: 0
ANIMATHIO_AUDIO: none
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
persist-credentials: false
- name: Install tools
run: |
python3 -m pip install -r scripts/requirements.txt
rustup toolchain install stable --profile minimal --target wasm32-wasip2
rustup default stable
- name: Registry script tests
run: python3 -m unittest discover -s scripts -v
- name: Validate community-plugins.json
# Schema, unique and unreserved ids, public repositories, OSI/OFL licenses, README table.
env:
GH_TOKEN: ${{ github.token }}
run: python3 scripts/registry.py validate
- name: Resolve releases into an index
# External plugins need a published release (asset + .sha256); plugins hosted here are
# released after merge, so they are built below instead.
env:
GH_TOKEN: ${{ github.token }}
run: python3 scripts/registry.py index --strict --allow-unreleased-hosted --previous /dev/null --output "$RUNNER_TEMP/index.json"
- name: Released AniMathIO CLI
id: cli
uses: ./.github/actions/animathio-cli
with:
github-token: ${{ github.token }}
- name: Build and smoke-test changed entries
env:
BASE_REF: ${{ github.base_ref }}
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
git show "origin/$BASE_REF:community-plugins.json" > "$RUNNER_TEMP/base.json" 2>/dev/null || echo '{"plugins":[]}' > "$RUNNER_TEMP/base.json"
scope=(--base "$RUNNER_TEMP/base.json" --build-external)
else
scope=(--all)
fi
# Third-party build scripts may run above: no token is passed to this step.
python3 scripts/check_submission.py "${{ steps.cli.outputs.cli }}" "$RUNNER_TEMP/index.json" "$RUNNER_TEMP/work" "${scope[@]}"
130 changes: 130 additions & 0 deletions .github/workflows/release-plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
name: Release plugin
# Tag <plugin-id>@<version> (or run manually with the plugin directory) to build a plugin
# hosted in this repository and publish `<id>-<version>.amplugin` plus its `.sha256`.
# The tag must be on main, the plugin must be listed in community-plugins.json and its
# plugin.toml must carry exactly that id and version. Versions are immutable: a release
# that exists is never replaced.
on:
push:
tags:
- "*@*"
workflow_dispatch:
inputs:
path:
description: "Plugin directory to release, e.g. community/code-snippets (version from its plugin.toml)"
required: true
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 45
permissions:
contents: read
outputs:
id: ${{ steps.plugin.outputs.id }}
version: ${{ steps.plugin.outputs.version }}
tag: ${{ steps.plugin.outputs.tag }}
env:
CARGO_BUILD_JOBS: 3
CARGO_PROFILE_DEV_DEBUG: 0
CARGO_INCREMENTAL: 0
ANIMATHIO_AUDIO: none
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
persist-credentials: false
- name: Only release what is on main
run: |
git fetch origin main
git merge-base --is-ancestor "$GITHUB_SHA" origin/main || { echo "::error::$GITHUB_SHA is not on main"; exit 1; }
- name: Install tools
run: |
python3 -m pip install -r scripts/requirements.txt
rustup toolchain install stable --profile minimal --target wasm32-wasip2
rustup default stable
- name: Resolve the plugin from the registry
id: plugin
env:
INPUT_PATH: ${{ inputs.path }}
run: |
if [ "$GITHUB_EVENT_NAME" = "push" ]; then
python3 scripts/registry.py resolve --tag "$GITHUB_REF_NAME" | tee -a "$GITHUB_OUTPUT"
else
python3 scripts/registry.py resolve --path "$INPUT_PATH" | tee -a "$GITHUB_OUTPUT"
fi
- name: Build and package
env:
PLUGIN_PATH: ${{ steps.plugin.outputs.path }}
run: python3 scripts/registry.py package "$PLUGIN_PATH" --out dist
- name: Released AniMathIO CLI
id: cli
uses: ./.github/actions/animathio-cli
with:
github-token: ${{ github.token }}
- name: Load and render with the released CLI
env:
PLUGIN_ID: ${{ steps.plugin.outputs.id }}
run: python3 scripts/registry_smoke.py "${{ steps.cli.outputs.cli }}" dist --only "$PLUGIN_ID"
- name: Upload release assets
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: plugin-release
path: |
dist/${{ steps.plugin.outputs.id }}-${{ steps.plugin.outputs.version }}.amplugin
dist/${{ steps.plugin.outputs.id }}-${{ steps.plugin.outputs.version }}.amplugin.sha256
if-no-files-found: error
publish:
needs: build
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: write
# A fresh runner: never check out the repository or execute downloaded code here.
steps:
- name: Download release assets
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: plugin-release
path: dist
- name: Verify release assets
env:
PLUGIN_ID: ${{ needs.build.outputs.id }}
VERSION: ${{ needs.build.outputs.version }}
TAG: ${{ needs.build.outputs.tag }}
run: |
python3 - <<'PYTHON'
import hashlib, os, pathlib, re
pid, version, tag = (os.environ[k] for k in ('PLUGIN_ID', 'VERSION', 'TAG'))
assert re.fullmatch(r'[a-z0-9]+(?:[-_][a-z0-9]+)*(?:\.[a-z0-9]+(?:[-_][a-z0-9]+)*){2,}', pid), 'invalid plugin id'
assert re.fullmatch(r'[0-9]+\.[0-9]+\.[0-9]+', version), 'invalid version'
assert tag == f'{pid}@{version}', 'tag mismatch'
name = f'{pid}-{version}.amplugin'
directory = pathlib.Path('dist')
assert {p.name for p in directory.iterdir()} == {name, name + '.sha256'}, 'unexpected assets'
digest = hashlib.sha256((directory / name).read_bytes()).hexdigest()
assert (directory / (name + '.sha256')).read_text() == f'{digest} {name}\n', 'SHA-256 mismatch'
PYTHON
- name: Publish the release
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
TAG: ${{ needs.build.outputs.tag }}
PLUGIN_ID: ${{ needs.build.outputs.id }}
VERSION: ${{ needs.build.outputs.version }}
run: |
if gh release view "$TAG" > /dev/null 2>&1; then
echo "::error::release $TAG already exists; bump the version in plugin.toml"
exit 1
fi
sha=$(cut -d' ' -f1 "dist/$PLUGIN_ID-$VERSION.amplugin.sha256")
printf '%s %s\n\nSHA-256: `%s`\n\nInstall from the Plugins tab in AniMathIO 2.2+ (Browse), or download the .amplugin into your user plugin folder. See the README for details.\n' \
"$PLUGIN_ID" "$VERSION" "$sha" > notes.md
gh release create "$TAG" "dist/$PLUGIN_ID-$VERSION.amplugin" "dist/$PLUGIN_ID-$VERSION.amplugin.sha256" \
--target "$GITHUB_SHA" --title "$PLUGIN_ID $VERSION" --notes-file notes.md --latest=false
index:
needs: publish
permissions:
contents: write
uses: ./.github/workflows/index.yml
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.host/
.generated/
*.deb
__pycache__/
Loading
Loading