The open source AI video agent: turns any coding agent into a video agent, with an editor to change anything it makes.
release: mirror a published release's desktop files for fast downloads (#17)
riverisbuildingcff0c278fe00
diff --git a/.github/workflows/desktop.yml b/.github/workflows/desktop.ymlindex e863cfa..5295b68 100644--- a/.github/workflows/desktop.yml+++ b/.github/workflows/desktop.yml@@ -2,7 +2,8 @@ name: desktop# The official desktop app (CONTRIBUTING.md, Releases): push the tag v<version> (the version every package has), or run# it by hand for an existing tag. Each target is built (the Macs signed and notarized), and a draft GitHub release gets# the installers and the update feeds. Publishing that release makes it the latest: the website's download links and-# the apps' update checks go to the latest release's files (openfilm.dev/download/… redirects there).+# the apps' update checks go to the latest release's files (openfilm.dev/download/… serves them from the mirror+# mirror.yml fills when it is published, else redirects to GitHub).## The secrets are in the `desktop-release` environment (Settings → Environments; deployments limited to v* tags):# OPENFILM_SIGN_IDENTITY the Developer ID Application identity, "Name (TEAMID)"diff --git a/.github/workflows/mirror.yml b/.github/workflows/mirror.ymlnew file mode 100644index 0000000..673fcf3--- /dev/null+++ b/.github/workflows/mirror.yml@@ -0,0 +1,76 @@+name: mirror+# The desktop app's files, mirrored where they download fast (openfilm.dev/download/… serves them from there, else+# from GitHub). When a release is published: every file of it goes to download/desktop/<tag>/ in the bucket, then, if it+# is the latest release, download/desktop/latest.json ({ "tag": "<tag>" }) names it, and the website's download links+# and the apps' update checks move to it. Only a published release is mirrored, never a draft being checked.+#+# Again for a release already published: run it by hand on its tag (gh workflow run mirror.yml --ref v<version>).+#+# The secrets are in the `desktop-release` environment, beside desktop.yml's (an S3 token of the bucket only):+# MIRROR_S3_ENDPOINT the bucket's S3 endpoint (https://<account>.r2.cloudflarestorage.com)+# MIRROR_S3_BUCKET the bucket+# MIRROR_S3_ACCESS_KEY_ID, MIRROR_S3_SECRET_ACCESS_KEY the token's keys+on:+ release:+ types: [published]+ workflow_dispatch:+permissions:+ contents: read+concurrency:+ group: mirror+ cancel-in-progress: false+jobs:+ mirror:+ if: github.repository == 'openfilm/openfilm'+ runs-on: ubuntu-latest+ environment: desktop-release+ env:+ GH_TOKEN: ${{ github.token }}+ TAG: ${{ github.event.release.tag_name || github.ref_name }}+ ENDPOINT: ${{ secrets.MIRROR_S3_ENDPOINT }}+ BUCKET: ${{ secrets.MIRROR_S3_BUCKET }}+ AWS_ACCESS_KEY_ID: ${{ secrets.MIRROR_S3_ACCESS_KEY_ID }}+ AWS_SECRET_ACCESS_KEY: ${{ secrets.MIRROR_S3_SECRET_ACCESS_KEY }}+ AWS_DEFAULT_REGION: auto+ # R2 takes the checksums the AWS CLI sends only when an operation needs them+ AWS_REQUEST_CHECKSUM_CALCULATION: when_required+ AWS_RESPONSE_CHECKSUM_VALIDATION: when_required+ # where the website reads them (its worker.js)+ PREFIX: download/desktop+ steps:+ - name: The release's files+ run: |+ if [ -z "$ENDPOINT" ] || [ -z "$BUCKET" ]; then+ echo "::notice::The MIRROR_S3_* secrets are not set: $TAG is downloaded from GitHub only"+ echo "SKIP=1" >> "$GITHUB_ENV"+ exit 0+ fi+ if [ "$(gh release view "$TAG" -R "$GITHUB_REPOSITORY" --json isDraft -q .isDraft)" != "false" ]; then+ echo "::error::$TAG is not a published release"+ exit 1+ fi+ gh release download "$TAG" -R "$GITHUB_REPOSITORY" --dir files+ ls -l files+ - name: Into the bucket, and checked there+ if: env.SKIP != '1'+ run: |+ aws s3 cp files "s3://$BUCKET/$PREFIX/$TAG/" --recursive --endpoint-url "$ENDPOINT" --no-progress+ for f in files/*; do+ name="$(basename "$f")"+ size="$(aws s3api head-object --bucket "$BUCKET" --key "$PREFIX/$TAG/$name" --endpoint-url "$ENDPOINT" --query ContentLength --output text)"+ if [ "$size" != "$(stat -c %s "$f")" ]; then+ echo "::error::$name is $size bytes in the bucket, $(stat -c %s "$f") here"+ exit 1+ fi+ done+ - name: The latest release, if it is this one+ if: env.SKIP != '1'+ run: |+ LATEST="$(gh api "repos/$GITHUB_REPOSITORY/releases/latest" -q .tag_name)"+ if [ "$LATEST" != "$TAG" ]; then+ echo "::notice::$TAG is mirrored; the latest release is $LATEST, which stays the one downloaded"+ exit 0+ fi+ printf '{"tag":"%s"}\n' "$TAG" > latest.json+ aws s3 cp latest.json "s3://$BUCKET/$PREFIX/latest.json" --endpoint-url "$ENDPOINT" --content-type application/json --cache-control no-store+ echo "::notice::openfilm.dev/download now serves $TAG from the mirror"