diff --git a/.github/workflows/Build and Deploy HTML and WASM.yml b/.github/workflows/Build and Deploy HTML and WASM.yml new file mode 100644 index 0000000..2072996 --- /dev/null +++ b/.github/workflows/Build and Deploy HTML and WASM.yml @@ -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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index bd63194..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: release - -on: - workflow_dispatch: - inputs: - releaseKind: - description: 'Kind of release' - default: 'minor' - type: choice - options: - - patch - - minor - required: true - -jobs: - rust: - name: release - runs-on: ubuntu-latest - timeout-minutes: 30 - - steps: - - name: Clone repository - uses: actions/checkout@v3 - with: - token: ${{ secrets.GH_DPRINTBOT_PAT }} - - - uses: denoland/setup-deno@v1 - - uses: dsherret/rust-toolchain-file@v1 - - - name: Bump version and tag - env: - GITHUB_TOKEN: ${{ secrets.GH_DPRINTBOT_PAT }} - GH_WORKFLOW_ACTOR: ${{ github.actor }} - run: | - git config user.email "${{ github.actor }}@users.noreply.github.com" - git config user.name "${{ github.actor }}" - deno run -A https://raw.githubusercontent.com/dprint/automation/0.5.1/tasks/publish_release.ts --${{github.event.inputs.releaseKind}} diff --git a/.gitignore b/.gitignore index 2adeffa..d9e74ad 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ **/*.rs.bk deployment/npm/plugin.wasm deployment/npm/node_modules +/dist diff --git a/scripts/build-page.sh b/scripts/build-page.sh new file mode 100755 index 0000000..aa9685a --- /dev/null +++ b/scripts/build-page.sh @@ -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=" + + + + + + dprint_plugin_markdown fork $version + + + + + + +

dprint_plugin_markdown $version

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