Relax version range to include 0.21 #13
Workflow file for this run
This file contains 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
name: Deploy to GitHub | |
on: | |
push: | |
tags: | |
- '*' | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
env: | |
EMSCRIPTEN_VERSION: '3.1.55' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Clone gh-pages branch into nested directory | |
uses: actions/checkout@v4 | |
with: | |
ref: gh-pages | |
path: gh-pages | |
- name: Configure Git user | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
- name: Get tag name | |
id: tag | |
run: | | |
tag=$(basename "${{ github.ref }}") | |
echo "tag=$tag" >> $GITHUB_OUTPUT | |
- name: Set up Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
- name: Install Emscripten | |
uses: mymindstorm/setup-emsdk@v14 | |
with: | |
version: ${{ env.EMSCRIPTEN_VERSION }} | |
- name: Install dependencies | |
run: npm install | |
- name: Compile grammar | |
run: npm run generate | |
- name: Build Wasm binary | |
run: npm run build-wasm | |
- name: Deploy to GitHub Releases | |
run: | | |
tag="${{ steps.tag.outputs.tag }}" | |
gh release create "$tag" --title "$tag" | |
gh release upload "$tag" tree-sitter-kotlin.wasm | |
env: | |
GH_TOKEN: ${{ github.token }} | |
GH_REPO: ${{ github.repository }} | |
- name: Deploy to GitHub Pages | |
run: | | |
sha="$(git rev-parse --short HEAD)" | |
tag="${{ steps.tag.outputs.tag }}" | |
echo "==> Replacing Wasm binary..." | |
rm -rf gh-pages/assets/tree-sitter-kotlin* | |
mkdir -p "gh-pages/assets/tree-sitter-kotlin-$tag" | |
cp tree-sitter-kotlin.wasm "gh-pages/assets/tree-sitter-kotlin-$tag" | |
tree gh-pages/assets | |
echo "==> Updating version on website..." | |
sed -i "s|\(LANGUAGE_BASE_URL = \"\)[^\"]*\(\"\)|\1assets/tree-sitter-kotlin-$tag\2|g" gh-pages/index.html | |
sed -i "s|\(<span class=\"version\">\)[^<]*\(</span>\)|\1$tag\2|g" gh-pages/index.html | |
echo "==> Committing and pushing gh-pages branch..." | |
cd gh-pages | |
git add . | |
git commit -m "Deploy tree-sitter-kotlin $tag ($sha)" | |
git push |