Build webview with Jupyter #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build webview with Jupyter | |
on: | |
workflow_dispatch: | |
env: | |
branch_name: webview | |
jobs: | |
test_and_build: | |
runs-on: ${{ matrix.config.os }} | |
strategy: | |
matrix: | |
config: | |
#- { os: ubuntu-latest, py: 3.8, doc: 1 } | |
- { os: windows-latest, py: "3.10", exe: 1, whl: 1 } | |
#- { os: macos-latest, py: 3.8, whl: 1 } | |
# all using to stable abi | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ env.branch_name }} | |
- name: Set up Python ${{ matrix.config.py }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.config.py }} | |
- uses: conda-incubator/setup-miniconda@v2 | |
with: | |
auto-update-conda: true | |
python-version: ${{ matrix.config.py }} | |
- name: Build installer | |
run: | | |
pwsh -command ".\$GITHUB_WORKSPACE\extra\build_conda_packed_jupyter.ps1" | |
mkdir unstable | |
pwd | |
dir dist | |
dir extra | |
mv dist\refl1d*.tar.gz "unstable\Refl1D-windows-exe-$($env:branch_name)-jupyter.tar.gz" | |
# See the following for how to upload to a release | |
# https://eugene-babichenko.github.io/blog/2020/05/09/github-actions-cross-platform-auto-releases/ | |
- name: Archive artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: artifacts | |
path: | | |
unstable/* | |
updateUnstable: | |
needs: test_and_build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Retrieve all artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: artifacts | |
- name: show files | |
run: | | |
ls * -l | |
- name: repack self-extracting | |
run: | | |
sudo apt-get install -y p7zip-full | |
mkdir self_extracting | |
curl -L https://www.7-zip.org/a/7z2106-x64.exe --output 7z.exe | |
7z e 7z.exe -aoa -oself_extracting 7z.sfx | |
tar -xzf "Refl1D-windows-exe-$branch_name-jupyter.tar.gz" -C self_extracting | |
cd self_extracting && 7z a -mhe=on -mx=1 -sfx7z.sfx "../Refl1D-$branch_name-jupyter-self-extracting.exe" refl1d*/ | |
- name: Update release assets and text | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
const fs = require('fs'); | |
const { owner, repo } = context.repo; | |
let sid_release = await github.rest.repos.getReleaseByTag({ | |
owner, | |
repo, | |
tag: "sid" | |
}); | |
await github.rest.repos.updateRelease({ | |
owner, | |
repo, | |
release_id: sid_release.data.id, | |
body: "A persistent prerelease where build artifacts for the current tip will be deposited\n\n## Last updated: " + (new Date()).toDateString() | |
}); | |
// delete existing release assets (if needed) and upload new ones: | |
const to_update = ["Refl1D-windows-exe-${{ env.branch_name }}-jupyter.tar.gz", "Refl1D-${{ env.branch_name }}-jupyter-self-extracting.exe"]; | |
for (let fn of to_update) { | |
let asset_id = (sid_release.data.assets.find((a) => (a.name == fn)) ?? {}).id; | |
if (asset_id) { | |
await github.rest.repos.deleteReleaseAsset({ | |
owner, | |
repo, | |
asset_id | |
}); | |
} | |
await github.rest.repos.uploadReleaseAsset({ | |
owner, | |
repo, | |
release_id: sid_release.data.id, | |
name: fn, | |
data: await fs.readFileSync(fn) | |
}); | |
} |