programmatic video rendering framework that is actually fast
ci: Release a version by pushing a tag (#146)
Dmitriy Kovalenko3e82908c3a79
diff --git a/.github/workflows/main.yml b/.github/workflows/main.ymlindex 41878510..eb9dc43a 100644--- a/.github/workflows/main.yml+++ b/.github/workflows/main.yml@@ -2,6 +2,8 @@ name: CIon:push:branches: [ main ]+ # A v1.2.3 tag from scripts/release.sh publishes that version, see the publish job+ tags: [ "v*" ]pull_request:branches: [ main ]# GitHub evicts caches that were not used for 7 days, rebuild them before that@@ -192,12 +194,13 @@ jobs:run: just check-examplesrelease:- name: Publish nightly release- if: github.event_name == 'push' && github.ref == 'refs/heads/main'+ # A push to main publishes a nightly, a v* tag publishes that version (scripts/release-version.sh)+ name: Publish release+ if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))runs-on: ubuntu-latest# npm trusted publishing: the job proves its identity to npm with an OIDC token instead of a secretpermissions:- contents: read+ contents: write # the GitHub release of a tagid-token: writesteps:- name: Checkout@@ -225,13 +228,18 @@ jobs:cache: truecache-key: "v3-rust"- - name: Run Release Script+ - name: Publish crates and @fframes/editorenv:- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}run: |- git fetch --tags- bash release.sh "$(git describe --tags $(git rev-list --tags --max-count=1)).rc-$(printf "%02d" $(git rev-list --count $(git describe --tags --abbrev=0)..HEAD))"+ git fetch --tags --force+ scripts/publish.sh "$(scripts/release-version.sh)"++ - name: GitHub release+ if: startsWith(github.ref, 'refs/tags/v')+ env:+ GH_TOKEN: ${{ github.token }}+ run: gh release create "$GITHUB_REF_NAME" --verify-tag --generate-notes --title "$GITHUB_REF_NAME"build-windows:name: Windows build and render testdiff --git a/AGENTS.md b/AGENTS.mdindex 53087163..7e337f25 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -262,8 +262,10 @@ two scenes on a 16:9 grid), `--title`, `--format landscape|portrait|square|uhd`,`--backend cpu|skia-metal|skia-vulkan`, `--dir`, `--fframes-path <checkout>`. Inside thisrepository it uses workspace dependencies and registers the crate in the workspace members;elsewhere it pins the crates.io release matching its own version (`--git` for `main`,-`--fframes-path` for a checkout) and makes the crate its own workspace. `release.sh` publishes-`cargo-fframes` and `fframes_native_player` with the other crates on every push to main.+`--fframes-path` for a checkout) and makes the crate its own workspace. Every push to main+publishes a nightly of all crates and `@fframes/editor` (`scripts/publish.sh`, version from+`scripts/release-version.sh`); `./scripts/release.sh 1.2.3` cuts a release: it sets the+versions, commits, pushes the `v1.2.3` tag, and CI publishes it and creates the GitHub release.The generated crate compiles and renders as is:diff --git a/release.sh b/release.shdeleted file mode 100644index 537168dc..00000000--- a/release.sh+++ /dev/null@@ -1,35 +0,0 @@-set -euo pipefail-VERSION="$1"-echo "Releasing version $VERSION"--if ! git diff --quiet; then- echo "Error: There are unstaged changes in the repository."- exit 1-fi--cargo install cargo-edit-cargo set-version "$VERSION"--# Crates first, in dependency order, so a failing npm publish can not hold back the Rust-# release. `cargo publish` waits until each crate is in the index before the next one.-for crate in \- webvtt-parser \- svgr-macro \- fframes-media \- media-dir-macro \- fframes \- fframes-editor-controller \- fframes-skia-renderer \- fframes-native-player \- cargo-fframes; do- echo "Publishing $crate"- (cd "$crate" && cargo publish --allow-dirty --no-verify)-done--cd fframes-editor-pnpm build:prod-pnpm version "$VERSION" --no-git-tag-version-# npm itself: it authenticates with the job's OIDC token (trusted publishing) and attaches provenance-# Every nightly is a prerelease version; npm publishes those only with an explicit dist-tag,-# and `latest` is what `npm install @fframes/editor` has always resolved to-npm publish --access public --tag latestdiff --git a/scripts/publish.sh b/scripts/publish.shnew file mode 100755index 00000000..cc46d72d--- /dev/null+++ b/scripts/publish.sh@@ -0,0 +1,48 @@+#!/usr/bin/env bash+# Publishes one version of every crate and of @fframes/editor. CI runs it with the version+# from scripts/release-version.sh; the versions in the tree are set unless they already match+# (a release commit made by scripts/release.sh already carries them).+#+# scripts/publish.sh 1.0.0+set -euo pipefail+VERSION="$1"+echo "Publishing version $VERSION"++if ! git diff --quiet; then+ echo "Error: There are unstaged changes in the repository."+ exit 1+fi++if [ "$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[]|select(.name=="fframes")|.version')" != "$VERSION" ]; then+ cargo install cargo-edit+ cargo set-version "$VERSION"+fi++# Crates first, in dependency order, so a failing npm publish can not hold back the Rust+# release. `cargo publish` waits until each crate is in the index before the next one.+for crate in \+ webvtt-parser \+ svgr-macro \+ fframes-media \+ media-dir-macro \+ fframes \+ fframes-editor-controller \+ fframes-skia-renderer \+ fframes-native-player \+ cargo-fframes; do+ echo "Publishing $crate"+ (cd "$crate" && cargo publish --allow-dirty --no-verify)+done++cd fframes-editor+pnpm build:prod+[ "$(node -p 'require("./package.json").version')" = "$VERSION" ] || pnpm version "$VERSION" --no-git-tag-version+# Nightlies must not become what `npm install @fframes/editor` resolves to once a stable+# version exists; npm insists on an explicit dist-tag for prereleases anyway.+case "$VERSION" in+ *rc*) DIST_TAG=nightly ;;+ *-*) DIST_TAG=next ;;+ *) DIST_TAG=latest ;;+esac+# npm itself: it authenticates with the job's OIDC token (trusted publishing) and attaches provenance+npm publish --access public --tag "$DIST_TAG"diff --git a/scripts/release-version.sh b/scripts/release-version.shnew file mode 100755index 00000000..70aef5d1--- /dev/null+++ b/scripts/release-version.sh@@ -0,0 +1,28 @@+#!/usr/bin/env bash+# Prints the version CI publishes for the current checkout.+#+# scripts/release-version.sh+#+# A pushed `v1.2.3` tag is released as `1.2.3`. Every other push to main is a nightly derived+# from the latest tag: after a prerelease tag it continues that prerelease+# (`v1.0.0-beta.7` -> `1.0.0-beta.7.rc-45`), after a stable tag it is a release candidate of+# the next patch version (`v1.0.0` -> `1.0.1-rc.12`), so it sorts after the release and cargo+# and npm keep resolving to the stable one by default. The number is the count of commits+# since the tag.+set -euo pipefail++ref="${GITHUB_REF_NAME:-}"+if [[ "$ref" == v[0-9]* ]] && git rev-parse -q --verify "refs/tags/$ref" >/dev/null; then+ echo "${ref#v}"+ exit 0+fi++tag=$(git describe --tags --abbrev=0)+last=${tag#v}+count=$(printf '%02d' "$(git rev-list --count "$tag..HEAD")")+if [[ "$last" == *-* ]]; then+ echo "$last.rc-$count"+else+ IFS=. read -r major minor patch <<<"$last"+ echo "$major.$minor.$((patch + 1))-rc.$count"+fidiff --git a/scripts/release.sh b/scripts/release.shnew file mode 100755index 00000000..49468027--- /dev/null+++ b/scripts/release.sh@@ -0,0 +1,54 @@+#!/bin/bash+# Cuts a release: sets the version in every crate and in the editor package, commits, tags+# and pushes. CI publishes the tag to crates.io and npm and creates the GitHub release.+#+# ./scripts/release.sh 1.0.0+set -euo pipefail++VERSION="${1:?Usage: ./scripts/release.sh <version> (e.g. 1.0.0)}"++# Strip leading 'v' if provided+VERSION="${VERSION#v}"++TAG="v${VERSION}"++cd "$(dirname "$0")/.."+git pull++# Check for clean working tree+if ! git diff --quiet || ! git diff --cached --quiet; then+ echo "Error: Working tree is not clean. Commit or stash changes first."+ exit 1+fi++# Check if tag already exists+if git rev-parse "$TAG" >/dev/null 2>&1; then+ echo "Error: Tag $TAG already exists"+ exit 1+fi++echo "Releasing $VERSION..."++echo "→ Updating Cargo.toml versions to $VERSION"+cargo set-version "$VERSION" 2>/dev/null || {+ echo "cargo-edit not found, installing..."+ cargo install cargo-edit+ cargo set-version "$VERSION"+}++echo "→ Updating @fframes/editor to $VERSION"+(cd fframes-editor && pnpm version "$VERSION" --no-git-tag-version >/dev/null)++git add -u+git commit -m "chore: release $VERSION"++echo "→ Creating tag $TAG"+git tag -a "$TAG" -m "Release $VERSION"++echo "→ Pushing to origin"+git push origin+git push origin "$TAG"++echo ""+echo "Release $VERSION created and pushed."+echo "CI will publish the crates and @fframes/editor: https://github.com/dmtrKovalenko/fframes/actions"