From 810d322dccd59d85d24e5f4ad0ac974ccec8b4d1 Mon Sep 17 00:00:00 2001 From: Jonas Krimmer <30567171+jonas-kr@users.noreply.github.com> Date: Fri, 18 Jun 2021 17:32:35 +0200 Subject: [PATCH] Generate artifacts using gh-actions (#372) * Generate single artifact * Create artifacts.yml * Remove erroneous - * Correct path * Use archive_artifact correctly * Add tag_name * Correctly generate artifact * Update Artifacts.toml after generating artifacts * Rename * Update Artifacts.toml * Remove old tag before release * Update Artifacts.toml * Use ncipollo/release-action Allows to replace tags * Update Artifacts.toml * Fix deprecation in ncipollo/release-action * Update Artifacts.toml * Fix typo * Update Artifacts.toml * Hopefully enable update of release artifacts * Update Artifacts.toml * Obtain schema correctly * Obtain schema correctly * Rename to plotly.min.js * Update Artifacts.toml * Rename for JuliaPlots repo * Rename for JuliaPlots repo * Update Artifacts.toml * Do not update Artifact.toml automatically Compute SHA256 instead * Revert "Do not update Artifact.toml automatically" This reverts commit 21116a08f61b6a6507b3fbfa38410f4fe5b5f0a1. * Update Artifacts.toml * Update Artifacts.toml * Download artifacts directly without checksum Probably won't work... * Revert "Download artifacts directly without checksum" This reverts commit 038c23cf7898745e1c712f1646021837b894fdd3. * Update Artifacts.toml * Blink.AtomShell.install() not needed anymore * Prepare artifact versioning * Bump julia version * Update Artifacts.toml for artifact version latest * Introduce artifact versioning * Fix bash string interpolation * Update Artifacts.toml for artifact version 1.58.4 * String interpolation in artifact release * Hopefully fix env usage * Update Artifacts.toml for artifact version 1.58.4 * Allow manual triggering * Fix artifact download link * Update Artifacts.toml for artifact version 1.58.4 * Get rid of try ... catch * Bump version number * Repo specifier in generate_artifacts * Repo specifier * Update Artifacts.toml for artifact version 1.58.4 * Update Artifacts.toml for artifact version 1.58.4 Co-authored-by: github-actions[bot] --- .github/workflows/artifacts.yml | 57 +++++++++++++++++++++++++++++++ .github/workflows/deploy_docs.yml | 1 + Artifacts.toml | 6 ++-- Project.toml | 2 +- README.md | 11 +----- deps/find_attr_groups.jl | 2 +- deps/generate_artifacts.jl | 32 +++++++++-------- deps/make_schema_docs.jl | 2 +- 8 files changed, 82 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/artifacts.yml diff --git a/.github/workflows/artifacts.yml b/.github/workflows/artifacts.yml new file mode 100644 index 00000000..8a64bed6 --- /dev/null +++ b/.github/workflows/artifacts.yml @@ -0,0 +1,57 @@ +# This is a basic workflow to help you get started with Actions + +name: Artifacts + +# Controls when the action will run. +on: + # Allows you to run this workflow manually from the Actions tab, do not run automatically + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "gen-artifacts" + gen-artifacts: + # The type of runner that the job will run on + runs-on: ubuntu-latest + # The plotly version. Bumping this environment variable should do the trick + env: + PLOTLY_VER: 1.58.4 + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - name: "Checkout" + uses: actions/checkout@v2 + with: + fetch-depth: 0 # otherwise, you will failed to push refs to dest repo + + - name: "Set up Julia" + uses: julia-actions/setup-julia@v1 + with: + version: 1.6.0 + + - name: "Get artifact" + run: | + cd $GITHUB_WORKSPACE + julia -e 'include(joinpath(pwd(),"deps","generate_artifacts.jl")); generate_artifacts("'"$PLOTLY_VER"'","'"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY"'")' + + - name: "Commit updated Artifacts.toml" + run: | + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git commit -m "Update Artifacts.toml for artifact version $PLOTLY_VER" "Artifacts.toml" + + - name: "Push changes" + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: ${{ github.ref }} + + - name: "Release" + uses: ncipollo/release-action@v1 + with: + allowUpdates: true + artifacts: "plotly-artifacts-${{ env.PLOTLY_VER }}.tar.gz" + replacesArtifacts: true + token: ${{ secrets.GITHUB_TOKEN }} + tag: "plotly-artifacts-${{ env.PLOTLY_VER }}" diff --git a/.github/workflows/deploy_docs.yml b/.github/workflows/deploy_docs.yml index b749a687..f1a83b84 100644 --- a/.github/workflows/deploy_docs.yml +++ b/.github/workflows/deploy_docs.yml @@ -4,6 +4,7 @@ on: branches: [master] tags: [v*] pull_request: + workflow_dispatch: jobs: docdeploy: diff --git a/Artifacts.toml b/Artifacts.toml index 38cb09aa..43ffbff8 100644 --- a/Artifacts.toml +++ b/Artifacts.toml @@ -1,6 +1,6 @@ [plotly-artifacts] -git-tree-sha1 = "0fcbca3e2dac59d4a0f4f3b3fc2de36efe0ca4a1" +git-tree-sha1 = "4fa45e1c116c49318fa3d60adb843b5db5c13069" [[plotly-artifacts.download]] - sha256 = "499fa5e6a60b280c17513b13fbe5b99f37b96870446319bc27a37a137445ea6b" - url = "https://github.com/thomasjm/PlotlyJS.jl/releases/download/v0.14/plotly.js-artifacts-1.57.1.tar.gz" + sha256 = "c945e3724a3969e58dee5a9f00e80a256a5c098e0b4ac8c5838c5a538e186c9d" + url = "https://github.com/jonas-kr/PlotlyJS.jl/releases/download/plotly-artifacts-1.58.4/plotly-artifacts-1.58.4.tar.gz" diff --git a/Project.toml b/Project.toml index f71b2cf6..34363c4a 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "PlotlyJS" uuid = "f0f68f2c-4968-5e81-91da-67840de0976a" authors = ["Spencer Lyon "] -version = "0.14.1" +version = "0.15" [deps] Blink = "ad839575-38b3-5650-b840-f874b8c74a25" diff --git a/README.md b/README.md index 4a83a763..841a83c1 100644 --- a/README.md +++ b/README.md @@ -16,16 +16,7 @@ Check out the [docs](http://juliaplots.org/PlotlyJS.jl/stable)! ## Installation -If you intend to use the [Electron display](http://juliaplots.github.io/PlotlyJS.jl/syncplots/#electronplot) or any of its features (recommended) you will need to enter the following at the Julia REPL: - -```julia -using Blink -Blink.AtomShell.install() -``` - -Note that this is a one time process. - -Also, if you have issues building this package because of installation of the MbedTLS package please see [this issue](https://github.com/sglyon/PlotlyJS.jl/issues/83). +If you have issues building this package because of installation of the MbedTLS package please see [this issue](https://github.com/sglyon/PlotlyJS.jl/issues/83). ### Jupyterlab diff --git a/deps/find_attr_groups.jl b/deps/find_attr_groups.jl index 28cde4bf..27aaabe2 100644 --- a/deps/find_attr_groups.jl +++ b/deps/find_attr_groups.jl @@ -10,7 +10,7 @@ _symbol_dict(d::AbstractDict) = function main() - data = _symbol_dict(JSON.parsefile(joinpath(artifact"plotly-artifacts", "plot-schema.json"))) + data = _symbol_dict(JSON.parsefile(joinpath(artifact"plotly-artifacts", "plot-schema.json")))[:schema] nms = Set{Symbol}() function add_to_names!(d::AbstractDict) diff --git a/deps/generate_artifacts.jl b/deps/generate_artifacts.jl index 41e146e5..49730cab 100644 --- a/deps/generate_artifacts.jl +++ b/deps/generate_artifacts.jl @@ -1,22 +1,24 @@ # This script gets run once, on a developer's machine, to generate artifacts using Pkg.Artifacts +using Downloads -artifacts_toml = joinpath(dirname(@__DIR__), "Artifacts.toml") +function generate_artifacts(ver="latest",repo="https://github.com/JuliaPlots/PlotlyJS.jl") + artifacts_toml = joinpath(dirname(@__DIR__), "Artifacts.toml") -rm(artifacts_toml) + # if Artifacts.toml does not exist we also do not have to remove it + isfile(artifacts_toml) && rm(artifacts_toml) -plotschema_url = "https://api.plot.ly/v2/plot-schema?sha1" -plotschema_hash = create_artifact() do artifact_dir - download(plotschema_url, joinpath(artifact_dir, "plotschema.json")) -end -bind_artifact!(artifacts_toml, "plotschema", plotschema_hash; download_info = [ - (plotschema_url, plotschema_hash) -]) + plotschema_url = "https://api.plot.ly/v2/plot-schema?sha1" + plotly_url = "https://cdn.plot.ly/plotly-$ver.min.js" + + plotlyartifacts_hash = create_artifact() do artifact_dir + Downloads.download(plotschema_url, joinpath(artifact_dir, "plot-schema.json")) + Downloads.download(plotly_url, joinpath(artifact_dir, "plotly.min.js")) + end + + tarball_hash = archive_artifact(plotlyartifacts_hash, "plotly-artifacts-$ver.tar.gz") -plotly_url = "https://cdn.plot.ly/plotly-latest.min.js" -plotly_hash = create_artifact() do artifact_dir - download(plotly_url, joinpath(artifact_dir, "plotly-latest.min.js")) + bind_artifact!(artifacts_toml, "plotly-artifacts", plotlyartifacts_hash; download_info = [ + ("$repo/releases/download/plotly-artifacts-$ver/plotly-artifacts-$ver.tar.gz", tarball_hash) + ]) end -bind_artifact!(artifacts_toml, "plotly", plotly_hash; download_info = [ - (plotly_url, plotly_hash) -]) diff --git a/deps/make_schema_docs.jl b/deps/make_schema_docs.jl index c15cda86..370e844f 100644 --- a/deps/make_schema_docs.jl +++ b/deps/make_schema_docs.jl @@ -73,7 +73,7 @@ struct Schema function Schema() _path = joinpath(artifact"plotly-artifacts", "plot-schema.json") - schema = _symbol_dict(JSON.parse(read(_path, String))) + schema = _symbol_dict(JSON.parse(read(_path, String)))[:schema] traces = Dict{Symbol,TraceSchema}() for (k, v) in schema[:traces]