Upgrade tsx to v4.0.0 #308
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, test and deploy webR | |
on: | |
push: | |
branches: | |
- "main" | |
tags: | |
- "v*.*" | |
workflow_dispatch: | |
jobs: | |
build: | |
name: Build webR | |
runs-on: ubuntu-latest | |
container: ghcr.io/r-wasm/flang-wasm:main | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 'lts/*' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Set npm dist-tag to "next" if pre-release version | |
if: contains(github.ref_name, '-dev') || contains(github.ref_name, '-rc') | |
run: echo "DIST_TAG=next" >> $GITHUB_ENV | |
- name: Install required system packages | |
run: apt-get update && apt-get install -y gh jq sudo | |
- uses: r-lib/actions/setup-r@v2 | |
with: | |
use-public-rspm: true | |
- uses: quarto-dev/quarto-actions/setup@v2 | |
- name: Install required R packages for building documentation | |
run: Rscript -e 'install.packages(c("rmarkdown", "rvest"))' | |
- name: Configure webR for flang | |
env: | |
EMFC: /opt/flang/host/bin/flang-new | |
run: ./configure | |
- name: Setup Emscripten PATH | |
run: echo "/opt/emsdk:/opt/emsdk/upstream/emscripten" >> $GITHUB_PATH | |
- name: Set Emscripten EM_NODE_JS | |
run: echo "EM_NODE_JS=$(which node)" >> $GITHUB_ENV | |
- name: Set the webR CDN URL as the BASE_URL | |
run: echo "BASE_URL=https://webr.r-wasm.org/${{ github.ref_name }}/" > "$HOME/.webr-config.mk" | |
shell: bash | |
- name: Build all optional wasm libs | |
env: | |
EMSDK: /opt/emsdk | |
run: cd libs && make all | |
- name: Build webR | |
env: | |
EMSDK: /opt/emsdk | |
run: make && make check-pr | |
shell: bash | |
- name: Build webR documentation | |
run: cd src/docs && make | |
shell: bash | |
- name: Publish to npm | |
if: "!contains(github.ref_name, 'main')" | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
run: cd src && make publish | |
- name: Report code coverage | |
uses: codecov/codecov-action@v3 | |
with: | |
files: src/coverage/lcov.info | |
flags: unittests | |
name: codecov-webr | |
fail_ci_if_error: true | |
verbose: true | |
token: ${{ secrets.CC_TOKEN }} | |
- name: Archive webR build artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: webr-dist | |
path: | | |
dist | |
- name: Archive webR documentation artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: webr-docs | |
path: | | |
src/docs/_site | |
deploy: | |
name: Deploy webR to S3 | |
needs: build | |
runs-on: ubuntu-latest | |
environment: deploy | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- name: Download build archive | |
uses: actions/download-artifact@v3 | |
with: | |
name: webr-dist | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: ${{ secrets.AWS_ROLE }} | |
aws-region: ${{ secrets.AWS_REGION }} | |
- name: Upload files to S3 bucket | |
run: | | |
aws s3 sync . s3://${{ secrets.AWS_S3_BUCKET }}/_webr/${{ github.ref_name }}/ | |
aws s3 cp --exclude "*" --include "*.data" --include "*.so" --recursive \ | |
--content-type="application/wasm" --metadata-directive="REPLACE" \ | |
s3://${{ secrets.AWS_S3_BUCKET }}/_webr/${{ github.ref_name }}/ \ | |
s3://${{ secrets.AWS_S3_BUCKET }}/_webr/${{ github.ref_name }}/ | |
deploy_docs: | |
name: Deploy webR documentation to S3 | |
needs: build | |
runs-on: ubuntu-latest | |
environment: deploy | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- name: Download docs archive | |
uses: actions/download-artifact@v3 | |
with: | |
name: webr-docs | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: ${{ secrets.AWS_ROLE }} | |
aws-region: ${{ secrets.AWS_REGION }} | |
- name: Upload files to S3 bucket | |
run: | | |
aws s3 sync . s3://${{ secrets.AWS_S3_BUCKET }}/_docs/webr/${{ github.ref_name }}/ | |
build_docker: | |
name: Build Docker image | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Log in to the GitHub Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ghcr.io/${{ github.repository }} | |
- name: Build and publish Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |