Skip to content

Create versioned releases of pandoc-wasm #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 69 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
31d06a4
update pandoc repo
johanneswilm Feb 10, 2025
75fbbed
Update links
johanneswilm Feb 10, 2025
c92ad77
Update README.md
johanneswilm Feb 10, 2025
3259e24
use patch for build
johanneswilm Feb 11, 2025
41623ec
Merge branch 'master' of github.com:johanneswilm/pandoc-wasm
johanneswilm Feb 11, 2025
9d68a29
clarify readme wording
johanneswilm Feb 11, 2025
9f59d23
Upload releases to ga run when not tagged
johanneswilm Feb 11, 2025
15afec9
actions/upload-artifact@v4
johanneswilm Feb 11, 2025
4d9de2e
fix filename
johanneswilm Feb 11, 2025
25ad35c
change reference to VERSION
johanneswilm Feb 11, 2025
e1317d4
use env.VERSION
johanneswilm Feb 11, 2025
94f0e68
use tagged pandoc version
johanneswilm Feb 11, 2025
a92165e
reorganize github actions
johanneswilm Feb 11, 2025
4d78291
switch github events release type
johanneswilm Feb 11, 2025
d99cc8b
github action events change
johanneswilm Feb 11, 2025
5245d39
0.2+3.6.3
johanneswilm Feb 11, 2025
dd1429e
Add package.json
johanneswilm Feb 11, 2025
59f7aeb
fix package.json syntax
johanneswilm Feb 11, 2025
c59abb7
0.3+3.6.3
johanneswilm Feb 11, 2025
5632d85
reorganize zipping
johanneswilm Feb 11, 2025
d633022
Merge branch 'main' of github.com:johanneswilm/pandoc-wasm
johanneswilm Feb 11, 2025
23ce56a
Use semver (requirement by npm)
johanneswilm Feb 11, 2025
ac6efee
set up for distribution via npm
johanneswilm Feb 11, 2025
6cf1ed2
Add maintainership. make exports work, add example to readme.
johanneswilm Feb 13, 2025
055a9dc
lint
johanneswilm Feb 13, 2025
96ec06d
lint
johanneswilm Feb 13, 2025
e1f914d
release to releases branch (while waiting for npm access)
johanneswilm Feb 13, 2025
e4062a4
0.5.1
johanneswilm Feb 13, 2025
ecdf7cb
Add mediafile output
johanneswilm Feb 13, 2025
ecf8fa9
0.6.0
johanneswilm Feb 13, 2025
58f19c3
correct dependency
johanneswilm Feb 13, 2025
45fa144
0.6.1
johanneswilm Feb 13, 2025
b743e09
update URLs
johanneswilm Feb 27, 2025
fccda16
disable distribution via releases branch
johanneswilm Feb 27, 2025
0757b87
0.6.2
johanneswilm Feb 27, 2025
d729384
add readme and license files to npm
johanneswilm Feb 27, 2025
dc9eb6b
refactor github actions script
johanneswilm Feb 27, 2025
54ef47e
change dir for patching
johanneswilm Feb 27, 2025
4e6606c
add pandoc build caching
johanneswilm Feb 27, 2025
fcae9ce
fix cache key reference
johanneswilm Feb 27, 2025
b633593
add pre-commit
johanneswilm Feb 27, 2025
bf77d0b
add extra files
johanneswilm Feb 27, 2025
a42e4a3
difference reference to reference variables
johanneswilm Feb 27, 2025
ea06f47
variable refernece change
johanneswilm Feb 27, 2025
73cee5c
remove unused shellcheck checker
johanneswilm Feb 27, 2025
9b75df5
disambigious variable names
johanneswilm Feb 27, 2025
238ec75
fix cache extraction
johanneswilm Feb 27, 2025
f3e28b7
fix url
johanneswilm Feb 27, 2025
5e0b198
pre-commit==4.1.0
johanneswilm Feb 27, 2025
d2a5624
switch to pre-commit action
johanneswilm Feb 27, 2025
6d3a56e
style changes
johanneswilm Feb 27, 2025
82ff51a
lint: add quotes
johanneswilm Feb 27, 2025
9fe1336
always deploy pages
johanneswilm Feb 27, 2025
0331c8c
0.6.3
johanneswilm Feb 27, 2025
eb0ce81
output github ref name
johanneswilm Feb 27, 2025
bd5849e
0.6.4
johanneswilm Feb 27, 2025
d3fe83a
github pages not for tag
johanneswilm Feb 27, 2025
de5a283
different ref reference
johanneswilm Feb 27, 2025
5567650
reset tagging, giving up
johanneswilm Feb 27, 2025
b4f0480
publish on release - does not seem to work with tag
johanneswilm Feb 27, 2025
a866526
0.6.5
johanneswilm Feb 27, 2025
29f2328
Revert "publish on release - does not seem to work with tag"
johanneswilm Feb 27, 2025
7514486
test publishign with tags again
johanneswilm Feb 27, 2025
19aa032
0.6.6
johanneswilm Feb 27, 2025
4a41420
pandoc 3.6.4
johanneswilm Mar 24, 2025
f3aa330
0.7.0
johanneswilm Mar 24, 2025
59297a8
update patch
johanneswilm Mar 24, 2025
2935bcc
pin ghc-wasm-meta
johanneswilm Mar 25, 2025
65d5776
0.7.1
johanneswilm Mar 25, 2025
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
254 changes: 213 additions & 41 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,87 +1,259 @@
name: build
name: Build, deploy, and release

on:
merge_group:
pull_request:
push:
branches:
- master
workflow_dispatch:
pull_request:

jobs:
build:
name: build
pre-commit:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run pre-commit
uses: pre-commit/[email protected]
prepare:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.extract-version.outputs.version }}
pandoc_version: ${{ steps.extract-version.outputs.pandoc_version }}
wasm_cache_key: ${{ steps.extract-version.outputs.wasm_cache_key }}
wasm_cache_hit: ${{ steps.cache-wasm.outputs.cache-hit }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Extract versions for ${{ github.ref }}
id: extract-version
run: |
VERSION=$(jq -r .version package.json)
PANDOC_VERSION=$(cat pandoc-version.txt)
{
echo "version=${VERSION}";
echo "pandoc_version=${PANDOC_VERSION}";
echo "wasm_cache_key=wasm-${PANDOC_VERSION}-${{ hashFiles('patch/pandoc.patch') }}";
} >> "$GITHUB_OUTPUT"
# Check if we already have the optimized WASM in cache
- name: Check WASM cache
id: cache-wasm
uses: actions/cache/restore@v4
with:
path: dist/pandoc.wasm
key: ${{ steps.extract-version.outputs.wasm_cache_key }}

build-wasm:
needs: prepare
if: needs.prepare.outputs.wasm_cache_hit != 'true'
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4

# Cache Haskell tools
- name: Cache Haskell tools
id: cache-tools
uses: actions/cache@v4
with:
path: |
~/.cabal
~/.ghc-wasm
key: haskell-tools-${{ needs.prepare.outputs.pandoc_version }}
restore-keys: |
haskell-tools-

- name: setup-alex-happy
- name: Setup build tools
if: steps.cache-tools.outputs.cache-hit != 'true'
run: |
pushd "$(mktemp -d)"
cabal path --installdir >> "$GITHUB_PATH"
temp_dir=$(mktemp -d)
pushd "$temp_dir"
cabal update
cabal install \
alex \
happy
cabal install alex happy
echo "$HOME/.cabal/bin" >> "$GITHUB_PATH"
popd

- name: setup-ghc-wasm
- name: Setup GHC-WASM
if: steps.cache-tools.outputs.cache-hit != 'true'
run: |
pushd "$(mktemp -d)"
curl -f -L --retry 5 https://gitlab.haskell.org/haskell-wasm/ghc-wasm-meta/-/archive/master/ghc-wasm-meta-master.tar.gz | tar xz --strip-components=1
temp_dir=$(mktemp -d)
pushd "$temp_dir"
curl -f -L --retry 5 https://gitlab.haskell.org/haskell-wasm/ghc-wasm-meta/-/archive/92ff0eb8541eb0a6097922e3532c3fd44d2f7db4/ghc-wasm-meta-92ff0eb8541eb0a6097922e3532c3fd44d2f7db4.tar.gz | tar xz --strip-components=1
FLAVOUR=9.12 ./setup.sh
~/.ghc-wasm/add_to_github_path.sh
popd

- name: checkout
uses: actions/checkout@v4
- name: Add cached tools to PATH
if: steps.cache-tools.outputs.cache-hit == 'true'
run: |
echo "$HOME/.cabal/bin" >> "$GITHUB_PATH"
~/.ghc-wasm/add_to_github_path.sh

- name: checkout
- name: Checkout Pandoc
uses: actions/checkout@v4
with:
repository: haskell-wasm/pandoc
ref: wasm
repository: jgm/pandoc
ref: ${{ needs.prepare.outputs.pandoc_version }}
path: pandoc

- name: gen-plan-json
- name: Patch Pandoc
run: |
pushd pandoc
patch -p1 < ../patch/pandoc.patch
popd

- name: Generate Cabal plan
run: |
pushd pandoc
wasm32-wasi-cabal build pandoc-cli --dry-run
popd

- name: wasm-cabal-cache
# Cache Cabal dependencies and build artifacts
- name: Cache Cabal dependencies
uses: actions/cache@v4
with:
key: wasm-cabal-cache-${{ hashFiles('pandoc/dist-newstyle/cache/plan.json') }}
restore-keys: wasm-cabal-cache-
path: |
~/.ghc-wasm/.cabal/store
pandoc/dist-newstyle
key: wasm-cabal-cache-${{ needs.prepare.outputs.pandoc_version }}-${{ hashFiles('pandoc/dist-newstyle/cache/plan.json') }}
restore-keys: |
wasm-cabal-cache-${{ needs.prepare.outputs.pandoc_version }}-
wasm-cabal-cache-

- name: build
- name: Build Pandoc WASM
run: |
pushd pandoc
wasm32-wasi-cabal build pandoc-cli
popd

- name: dist
- name: Optimize WASM
run: |
mkdir dist
wasm-opt --low-memory-unused --converge --gufa --flatten --rereloop -Oz $(find pandoc -type f -name pandoc.wasm) -o dist/pandoc.wasm
cp frontend/*.html frontend/*.js dist
mkdir -p dist
WASM_PATH=$(find pandoc -name pandoc.wasm -type f)
wasm-opt --low-memory-unused --converge --gufa --flatten --rereloop -Oz "$WASM_PATH" -o dist/pandoc.wasm
cp src/*.js dist/

- name: test
- name: Test build
run: |
wasmtime run --dir $PWD::/ -- dist/pandoc.wasm pandoc/README.md -o pandoc/README.rst
head --lines=20 pandoc/README.rst
wasmtime run --dir "$PWD"::/ -- dist/pandoc.wasm pandoc/README.md -o pandoc/README.rst
head -20 pandoc/README.rst

- name: upload-pages-artifact
uses: actions/upload-pages-artifact@v3
- name: Save to cache
uses: actions/cache/save@v4
with:
path: dist/pandoc.wasm
key: ${{ needs.prepare.outputs.wasm_cache_key }}

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: wasm-build
path: dist
retention-days: 90

- name: deploy-pages
post-process:
needs: [prepare, build-wasm]
if: always() # Run even if build-wasm is skipped
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

# Either get the artifact from build-wasm or from cache
- name: Download built artifact
if: needs.prepare.outputs.wasm_cache_hit != 'true'
uses: actions/download-artifact@v4
with:
name: wasm-build
path: dist

# This step only runs if we hit the cache
- name: Restore from cache
if: needs.prepare.outputs.wasm_cache_hit == 'true'
uses: actions/cache/restore@v4
with:
path: dist/pandoc.wasm
key: ${{ needs.prepare.outputs.wasm_cache_key }}
fail-on-cache-miss: true

# Combine with JS files - they're not part of the cache key
# but we need them in the artifact
- name: Ensure JS files are included
run: |
cp src/*.js dist/

- name: Upload final artifact
uses: actions/upload-artifact@v4
with:
name: wasm-pandoc-${{ needs.prepare.outputs.version }}
path: dist

deploy-pages:
needs: [prepare, post-process]
if: always() && !startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Download artifact
uses: actions/download-artifact@v4
with:
name: wasm-pandoc-${{ needs.prepare.outputs.version }}
path: dist

- name: Prepare demo
run: |
cp dist/pandoc.wasm demo/

- name: Upload pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: demo

- name: Deploy to Pages
uses: actions/deploy-pages@v4

release:
needs: [prepare, post-process]
if: always() && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Download artifact
uses: actions/download-artifact@v4
with:
name: wasm-pandoc-${{ needs.prepare.outputs.version }}
path: dist

- name: Add metadata files
run: cp {package.json,README.md,LICENSE} dist/

- name: Create release package
run: |
pushd dist
zip -r ../wasm-pandoc-${{ needs.prepare.outputs.version }}.zip .
popd

- name: Upload release asset
uses: softprops/action-gh-release@v2
with:
files: wasm-pandoc-${{ needs.prepare.outputs.version }}.zip
token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "22"
registry-url: "https://registry.npmjs.org"

- name: Publish to NPM
run: |
cd dist
npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/pandoc
34 changes: 34 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-yaml
# Check YAML files for syntax errors, particularly useful for GitHub Actions workflows
files: \.ya?ml$
- id: trailing-whitespace
# Ensure no trailing whitespace
- id: end-of-file-fixer
# Ensure files end with a newline
- id: check-added-large-files
# Prevent large files from being committed
args: ['--maxkb=500']
- id: check-merge-conflict
# Check for merge conflict strings
- id: check-json
# Validate JSON files
- id: detect-private-key
# Prevent accidental commit of private keys

- repo: https://github.com/rhysd/actionlint
rev: v1.7.7
hooks:
- id: actionlint
# Lint GitHub Actions workflows
files: ^\.github/workflows/

- repo: https://github.com/biomejs/pre-commit
rev: v1.9.4
hooks:
- id: biome-check
# #entry: biome check --files-ignore-unknown=true --no-errors-on-unmatched --fix --unsafe
# additional_dependencies: ["@biomejs/[email protected]"]
Loading