Skip to content

Commit 54d835e

Browse files
authored
Merge pull request #1 from chriskrycho/custom-deploy
Introduce GHA to publish custom version of the plugin to GH Pages
2 parents 78ec6d7 + db06988 commit 54d835e

File tree

4 files changed

+98
-37
lines changed

4 files changed

+98
-37
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Build and Deploy HTML and WASM
2+
3+
on:
4+
push:
5+
tags:
6+
- "*"
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
18+
- name: Install Rust toolchain
19+
uses: actions-rust-lang/setup-rust-toolchain@v1
20+
with:
21+
toolchain: stable
22+
target: wasm32-unknown-unknown
23+
24+
- name: Build WASM
25+
run: |
26+
cargo build --release --target wasm32-unknown-unknown --features wasm
27+
28+
- run: mkdir -p ./dist
29+
30+
- name: Rename artifact
31+
run: |
32+
ARTIFACT=target/wasm32-unknown-unknown/release/dprint_plugin_markdown.wasm
33+
UPLOAD=./dist/dprint_plugin_markdown-${{ github.ref_name }}.wasm
34+
mv ${ARTIFACT} ${UPLOAD}
35+
36+
- name: Generate HTML
37+
run: ./scripts/build-page.sh ${{ github.ref_name }}
38+
39+
- name: Setup Pages
40+
uses: actions/configure-pages@v4
41+
42+
- name: Upload HTML and WASM artifact
43+
uses: actions/upload-pages-artifact@v3
44+
with:
45+
path: ./dist
46+
47+
deploy:
48+
runs-on: ubuntu-latest
49+
50+
needs: build
51+
52+
permissions:
53+
pages: write # to deploy to Pages
54+
id-token: write # to verify the deployment originates from an appropriate source
55+
56+
environment:
57+
name: github-pages
58+
url: ${{ steps.deployment.outputs.page_url }}
59+
60+
steps:
61+
- name: Deploy to GitHub Pages
62+
id: deployment
63+
uses: actions/deploy-pages@v4

.github/workflows/release.yml

Lines changed: 0 additions & 37 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
**/*.rs.bk
44
deployment/npm/plugin.wasm
55
deployment/npm/node_modules
6+
/dist

scripts/build-page.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
if [ $# -eq 0 ]; then
6+
echo "Error: No arguments provided"
7+
exit 1
8+
fi
9+
10+
# The version should be the first argument.
11+
version="$1"
12+
13+
echo "Generating HTML page for dprint_plugin_markdown-$version.wasm"
14+
15+
page="<!doctype html>
16+
<html lang=\"en-US\">
17+
18+
<head>
19+
<meta charset=\"utf-8\">
20+
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">
21+
<title>dprint_plugin_markdown fork $version</title>
22+
<meta name=\"description\" content=\"Fork of dprint_plugin_markdown until it gets merged. Currently $version\">
23+
</head>
24+
25+
<body>
26+
27+
<!-- Add your site or application content here -->
28+
<p><a href=\"./dprint_plugin_markdown-$version.wasm\">dprint_plugin_markdown $version</a></p>
29+
30+
</body>
31+
32+
</html>"
33+
34+
echo "$page" > ./dist/index.html

0 commit comments

Comments
 (0)