ruffle-rs / ruffle

A Flash Player emulator written in Rust
https://ruffle.rs
Other
15.59k stars 809 forks source link

Provide permalink to latest nightly Ruffle build assets (for automated deployment) #3053

Open digitalcircuit opened 3 years ago

digitalcircuit commented 3 years ago

Describe the bug Ruffle does not seem to provide a way to download the latest release without navigating the GitHub releases page, or HTML scraping the https://ruffle.rs/ website.

Expected behavior Ruffle could have a statically named tag (e.g. latest_nightly) that is updated by release_nightly.yaml, similar to the existing Arch package support.

This would simplify automated nightly/weekly deployments of the prebuilt version of Ruffle.

Additional information The logical flow might be like this:

  1. Set up a secondary job called create-latest-nightly-release
  2. Run only if create-nightly-release runs
  3. Recreate a new release with tag named latest_nightly, using GongT/actions-recreate-release@v1
      - name: Recreate release permalink
        if: env.GHA_REPO_ALIVE == 'true'
        id: create_release
        uses: GongT/actions-recreate-release@v1
        # Until https://github.com/actions/create-release/issues/29 is addressed
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: latest-nightly
          release_name: Nightly ${{ steps.current_time_dashes.outputs.formattedTime }}
          prerelease: true
  4. After build, upload to the latest release as well

Alternatively, the GitHub CI workflow could be given permission to update a static link on the ruffle.rs hosting infrastructure.

Or, if the GitHub Actions workflow uploads build artifacts (not just release artifacts), nightly.link could be used. See Quassel IRC's usage here to provide a stable latest link.

Is the problem with the Ruffle desktop app, extension, or self-hosted version? It applies to all versions of Ruffle.

What platform are you using?

bls1999 commented 3 years ago

I may be missing the point here, but this query to the GitHub API gives me the latest release: https://api.github.com/repos/ruffle-rs/ruffle/releases?per_page=1

From there, you can isolate the link to the self-hosted version and download it. I set up a PHP script that does exactly this via a daily CRON job on my server and it works great.

digitalcircuit commented 3 years ago

@bls1999 Thank you, I missed that when I was looking this up. GitHub's documentation pointed me to https://docs.github.com/en/github/administering-a-repository/linking-to-releases but that only seems to work with stable releases.

Having a static set of URLs that redirect to the latest of each artifact in the nightly releases would still be nice (no need to parse JSON with e.g. jq), but this is still better than scraping HTML.

bls1999 commented 3 years ago

@bls1999 Thank you, I missed that when I was looking this up. GitHub's documentation pointed me to https://docs.github.com/en/github/administering-a-repository/linking-to-releases but that only seems to work with stable releases.

No prob! I had that problem at the start too. Happy to help. :)

Having a static set of URLs that redirect to the latest of each artifact in the nightly releases would still be nice (no need to parse JSON with e.g. jq), but this is still better than scraping HTML.

Ah, that makes sense. I didn't think about needing to parse the JSON in bash.

digitalcircuit commented 3 years ago

@bls1999 With the API url you've provided, I've come up with a workaround in shell using jq

LATEST_SELFHOSTED_URL=$(curl "https://api.github.com/repos/ruffle-rs/ruffle/releases?per_page=1" | jq --raw-output ".[0].assets[] | select(.browser_download_url | endswith(\"selfhosted.zip\")).browser_download_url")
echo "Latest selfhosted.zip is at: $LATEST_SELFHOSTED_URL"
# And do whatever processing you want to do
#
# For example…
# wget "$LATEST_SELFHOSTED_URL" --output-document="selfhosted.zip"
# unzip -d "ruffle" selfhosted.zip
# echo "Updated Ruffle in 'ruffle' directory"

Sample output:

$ LATEST_SELFHOSTED_URL=$(curl "https://api.github.com/repos/ruffle-rs/ruffle/releases?per_page=1" | jq --raw-output ".[0].assets[] | select(.browser_download_url | endswith(\"selfhosted.zip\")).browser_download_url")
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 13900  100 13900    0     0  22601      0 --:--:-- --:--:-- --:--:-- 22601

$ echo "Latest selfhosted.zip is at: $LATEST_SELFHOSTED_URL"
Latest selfhosted.zip is at: https://github.com/ruffle-rs/ruffle/releases/download/nightly-2021-02-04/ruffle_nightly_2021_02_04_selfhosted.zip

(One can pass --silent to curl to silence the progress.)

Full shell fetch, download, and extract sample output: ``` $ LATEST_SELFHOSTED_URL=$(curl "https://api.github.com/repos/ruffle-rs/ruffle/releases?per_page=1" | jq --raw-output ".[0].assets[] | select(.browser_download_url | endswith(\"selfhosted.zip\")).browser_download_url") % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 13900 100 13900 0 0 22601 0 --:--:-- --:--:-- --:--:-- 22601 $ wget "$LATEST_SELFHOSTED_URL" --output-document="selfhosted.zip" --2021-02-03 22:30:44-- https://github.com/ruffle-rs/ruffle/releases/download/nightly-2021-02-04/ruffle_nightly_2021_02_04_selfhosted.zip Resolving github.com (github.com)... 140.82.114.4 […trimmed…] Connecting to github-releases.githubusercontent.com (github-releases.githubusercontent.com)|185.199.110.154|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 1694569 (1.6M) [application/octet-stream] Saving to: ‘selfhosted.zip’ selfhosted.zip 100%[===================>] 1.62M 8.25MB/s in 0.2s 2021-02-03 22:30:44 (8.25 MB/s) - ‘selfhosted.zip’ saved [1694569/1694569] $ unzip -d "ruffle" selfhosted.zip Archive: selfhosted.zip inflating: ruffle/LICENSE_APACHE inflating: ruffle/LICENSE_MIT inflating: ruffle/ruffle.js inflating: ruffle/ruffle.js.map inflating: ruffle/README.md inflating: ruffle/72622b051eb31ffb7c70ef3f0ca63e55.wasm $ echo "Updated Ruffle in 'ruffle' directory" Updated Ruffle in 'ruffle' directory ```

I'd still prefer a simple URL one could just hand over to wget, curl, etc instead of stream processing JSON, but I'm sharing this here meanwhile in case it helps others.

n0samu commented 1 year ago

As an alternative, I've created a short Python script that allows updating Ruffle automatically: https://github.com/n0samu/gh-update/ Another option is to use the official Ruffle CDN, as explained here: https://ruffle.rs/#usage