Create versioned releases of pandoc-wasm (released as wasm-pandoc on npmjs.com) #26
Workflow file for this run
This file contains hidden or 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
| on: [push, pull_request, published] | ||
| name: Build, deploy and release | ||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| pages: write | ||
| id-token: write | ||
| contents: write | ||
| steps: | ||
| - name: setup-alex-happy | ||
| run: | | ||
| pushd "$(mktemp -d)" | ||
| cabal path --installdir >> "$GITHUB_PATH" | ||
| cabal update | ||
| cabal install \ | ||
| alex \ | ||
| happy | ||
| popd | ||
| - name: setup-ghc-wasm | ||
| 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 | ||
| FLAVOUR=9.12 ./setup.sh | ||
| ~/.ghc-wasm/add_to_github_path.sh | ||
| popd | ||
| - name: Checkout Pandoc-wasm | ||
| uses: actions/checkout@v4 | ||
| - name: Extract versions from version.txt | ||
| id: extract-version | ||
| run: | | ||
| VERSION=$(cat version.txt) | ||
| echo "Extracted version: $VERSION" | ||
| PANDOC_VERSION=$(echo $VERSION | cut -d '+' -f 2) | ||
| echo "Extracted Pandoc version: $VERSION" | ||
| echo "VERSION=$VERSION" >> $GITHUB_ENV | ||
| echo "PANDOC_VERSION=$PANDOC_VERSION" >> $GITHUB_ENV | ||
| - name: Checkout Pandoc | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| repository: jgm/pandoc | ||
| ref: ${{ env.PANDOC_VERSION }} | ||
| path: pandoc | ||
| - name: Patch Pandoc sources | ||
| run: | | ||
| cd pandoc | ||
| patch -p1 < ../patch/pandoc.patch | ||
| cd .. | ||
| - name: gen-plan-json | ||
| run: | | ||
| pushd pandoc | ||
| wasm32-wasi-cabal build pandoc-cli --dry-run | ||
| popd | ||
| - name: wasm-cabal-cache | ||
| 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 | ||
| - name: build | ||
| run: | | ||
| pushd pandoc | ||
| wasm32-wasi-cabal build pandoc-cli | ||
| popd | ||
| - name: dist | ||
| 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 | ||
| - name: test | ||
| run: | | ||
| wasmtime run --dir $PWD::/ -- dist/pandoc.wasm pandoc/README.md -o pandoc/README.rst | ||
| head --lines=20 pandoc/README.rst | ||
| - name: Zip dist folder | ||
| run: | | ||
| zip -r pandoc-wasm-${{ env.VERSION }}.zip dist/ | ||
| - name: Upload zipped file as artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: pandoc-wasm-${{ env.VERSION }}.zip | ||
| path: pandoc-wasm-${{ env.VERSION }}.zip | ||
| - name: Upload to release | ||
| if: ${{ github.event_name == 'published' }} | ||
| uses: svenstaro/upload-release-action@v2 | ||
| with: | ||
| repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
| file: pandoc-wasm-${{ env.VERSION }}.zip | ||
| asset_name: pandoc-wasm-${{ env.VERSION }}.zip | ||
| tag: ${{ github.ref }} | ||
| overwrite: true | ||
| - name: upload-pages-artifact | ||
| uses: actions/upload-pages-artifact@v3 | ||
| with: | ||
| path: dist | ||
| retention-days: 90 | ||
| - name: deploy-pages | ||
| uses: actions/deploy-pages@v4 | ||