Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/Build and Deploy HTML and WASM.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Build and Deploy HTML and WASM

on:
push:
tags:
- "*"

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
target: wasm32-unknown-unknown

- name: Build WASM
run: |
cargo build --release --target wasm32-unknown-unknown --features wasm

- run: mkdir -p ./dist

- name: Rename artifact
run: |
ARTIFACT=target/wasm32-unknown-unknown/release/dprint_plugin_markdown.wasm
UPLOAD=./dist/dprint_plugin_markdown-${{ github.ref_name }}.wasm
mv ${ARTIFACT} ${UPLOAD}

- name: Generate HTML
run: ./scripts/build-page.sh ${{ github.ref_name }}

- name: Setup Pages
uses: actions/configure-pages@v4

- name: Upload HTML and WASM artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./dist

deploy:
runs-on: ubuntu-latest

needs: build

permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
37 changes: 0 additions & 37 deletions .github/workflows/release.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
**/*.rs.bk
deployment/npm/plugin.wasm
deployment/npm/node_modules
/dist
34 changes: 34 additions & 0 deletions scripts/build-page.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

set -euo pipefail

if [ $# -eq 0 ]; then
echo "Error: No arguments provided"
exit 1
fi

# The version should be the first argument.
version="$1"

echo "Generating HTML page for dprint_plugin_markdown-$version.wasm"

page="<!doctype html>
<html lang=\"en-US\">

<head>
<meta charset=\"utf-8\">
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">
<title>dprint_plugin_markdown fork $version</title>
<meta name=\"description\" content=\"Fork of dprint_plugin_markdown until it gets merged. Currently $version\">
</head>

<body>

<!-- Add your site or application content here -->
<p><a href=\"./dprint_plugin_markdown-$version.wasm\">dprint_plugin_markdown $version</a></p>

</body>

</html>"

echo "$page" > ./dist/index.html
Loading