-
Notifications
You must be signed in to change notification settings - Fork 16
156 lines (138 loc) · 5.64 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
name: Build and deploy shinylive
on:
push:
branches: [main, deploy]
pull_request:
branches: [main]
release:
types: [published]
workflow_run:
workflows: [Update py-shiny submodule]
types:
- completed
jobs:
build:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write # Needed for svenstaro/upload-release-action
strategy:
matrix:
python-version: ["3.11"]
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Upgrade pip
run: python -m pip install --upgrade pip
- name: Check out submodules
run: |
make submodules
- name: Build shinylive
run: |
make all
# =====================================================
# Run playwright tests
# =====================================================
# Note: These are disabled because of a circular dependency between this
# repository and Python shinylive package (which is in the py-shinylive
# repository). This set of tests does a `pip install shinylive`, but that
# package depends on this repo, and can only be updated after a release is
# made from this repo. But if these tests fail, it will block this repo
# from making a release. To fix this, we will probably need to avoid
# installing the Python package.
# - uses: actions/setup-node@v3
# with:
# node-version: "14.x"
# - name: Install dependencies
# run: yarn
# - name: Install Shinylive Python pacakge
# run: pip install shinylive
# - name: Install Playwright Browsers
# run: npx playwright install --with-deps
# - name: Run Playwright tests
# run: make test
# - uses: actions/upload-artifact@v3
# if: always()
# with:
# name: playwright-report
# path: playwright-report/
# retention-days: 30
# =====================================================
# Publish to AWS for shinylive.io
# =====================================================
- name: Configure AWS Credentials
if: github.ref == 'refs/heads/deploy'
uses: aws-actions/configure-aws-credentials@v2
env:
AWS_ACCOUNT_ID: "341745101194"
AWS_REGION: us-east-1
with:
role-to-assume: arn:aws:iam::${{ env.AWS_ACCOUNT_ID }}:role/ShinyliveDeploy
role-session-name: gha-deploy-shinylive
aws-region: ${{ env.AWS_REGION }}
- name: Deploy to S3
if: github.ref == 'refs/heads/deploy'
env:
AWS_CLOUDFRONT_DISTRIBUTION_ID: "E2SN9UWE8YY9EG"
run: |
pip install awscli
gzip -k _shinylive/r/shinylive/webr/library.data
aws s3 sync _shinylive s3://shinylive.io --delete
aws s3 cp --exclude "*" --include "*.data" --include "*.so" --recursive --content-type="application/wasm" --metadata-directive="REPLACE" s3://shinylive.io/r/shinylive/webr/ s3://shinylive.io/r/shinylive/webr/
aws s3 cp --exclude "*" --include "*.js.metadata" --recursive --content-type="text/javascript" --metadata-directive="REPLACE" s3://shinylive.io/r/shinylive/webr/ s3://shinylive.io/r/shinylive/webr/
aws s3 cp --content-encoding="gzip" --content-type="application/wasm" --metadata-directive="REPLACE" _shinylive/r/shinylive/webr/library.data.gz s3://shinylive.io/r/shinylive/webr/library.data
aws cloudfront create-invalidation --distribution-id $AWS_CLOUDFRONT_DISTRIBUTION_ID --paths "/*"
# =====================================================
# Upload _shinylive/ artifact
# =====================================================
- name: Upload _shinylive/ artifact
if: github.ref == 'refs/heads/main'
uses: actions/upload-pages-artifact@v1
with:
path: "_shinylive/"
# =====================================================
# Upload shinylive bundle on release
# =====================================================
# Ensure that if the version in package.json is "0.0.5", then release tag
# is "v0.0.5".
- name: Check that version number matches release tag
if: github.event_name == 'release'
run: |
if [ "${{github.ref}}" != refs/tags/v`node -p "require('./package.json').version"` ]; then
echo Version in package.json, prepended with \"refs/tags/v\", is \"v`node -p "require('./package.json').version"`\", which does not match git tag \"${{github.ref}}\".
exit 1
fi
- name: Build shinylive deployment bundle for release
if: github.event_name == 'release'
run: |
make dist
- name: Upload shinylive bundle to release
if: github.event_name == 'release'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: "dist/*.tar.gz"
tag: ${{ github.ref }}
file_glob: true
overwrite: true
# =====================================================
# Deploy GitHub Pages site
# =====================================================
deploy_gh_pages:
if: github.ref == 'refs/heads/main'
needs: build
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1