Skip to content

Commit

Permalink
Generate artifacts using gh-actions (#372)
Browse files Browse the repository at this point in the history
* 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 21116a0.

* Update Artifacts.toml

* Update Artifacts.toml

* Download artifacts directly without checksum

Probably won't work...

* Revert "Download artifacts directly without checksum"

This reverts commit 038c23c.

* 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-actions[bot]@users.noreply.github.com>
  • Loading branch information
jkrimmer and github-actions[bot] authored Jun 18, 2021
1 parent 40c8c93 commit 810d322
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 31 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/artifacts.yml
Original file line number Diff line number Diff line change
@@ -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 }}"
1 change: 1 addition & 0 deletions .github/workflows/deploy_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
branches: [master]
tags: [v*]
pull_request:
workflow_dispatch:

jobs:
docdeploy:
Expand Down
6 changes: 3 additions & 3 deletions Artifacts.toml
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "PlotlyJS"
uuid = "f0f68f2c-4968-5e81-91da-67840de0976a"
authors = ["Spencer Lyon <[email protected]>"]
version = "0.14.1"
version = "0.15"

[deps]
Blink = "ad839575-38b3-5650-b840-f874b8c74a25"
Expand Down
11 changes: 1 addition & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion deps/find_attr_groups.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
32 changes: 17 additions & 15 deletions deps/generate_artifacts.jl
Original file line number Diff line number Diff line change
@@ -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)
])
2 changes: 1 addition & 1 deletion deps/make_schema_docs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 810d322

Please sign in to comment.