3
3
push :
4
4
tags :
5
5
- ' *'
6
- workflow_dispatch :
7
6
8
7
jobs :
9
8
deploy :
10
9
runs-on : ubuntu-latest
11
10
env :
12
11
EMSCRIPTEN_VERSION : ' 3.1.55'
13
12
steps :
14
- - uses : actions/checkout@v3
13
+ - uses : actions/checkout@v4
14
+ - name : Clone gh-pages branch into nested directory
15
+ uses : actions/checkout@v4
16
+ with :
17
+ ref : gh-pages
18
+ path : gh-pages
19
+ - name : Configure Git user
20
+ run : |
21
+ git config --global user.name "github-actions[bot]"
22
+ git config --global user.email "github-actions[bot]@users.noreply.github.com"
23
+ - name : Get tag name
24
+ id : tag
25
+ run : |
26
+ tag=$(basename "${{ github.ref }}")
27
+ echo "tag=$tag" >> $GITHUB_OUTPUT
15
28
- name : Set up Node
16
29
uses : actions/setup-node@v3
17
30
with :
@@ -27,38 +40,30 @@ jobs:
27
40
- name : Build WASM binary
28
41
run : npm run build-wasm
29
42
- name : Deploy to GitHub Releases
30
- if : github.event_name != 'workflow_dispatch'
31
- uses : ncipollo/release-action@v1
32
- with :
33
- artifacts : tree-sitter-kotlin.wasm
34
- token : ${{ secrets.GITHUB_TOKEN }}
43
+ run : |
44
+ tag="${{ steps.tag.outputs.tag }}"
45
+ gh release create "$tag" --title "$tag"
46
+ gh release upload "$tag" tree-sitter-kotlin.wasm
47
+ env :
48
+ GH_TOKEN : ${{ github.token }}
49
+ GH_REPO : ${{ github.repository }}
50
+ - name : Deploy to GitHub Pages
51
+ run : |
52
+ sha="$(git rev-parse --short HEAD)"
53
+ tag="${{ steps.tag.outputs.tag }}"
54
+
55
+ echo "==> Replacing Wasm binary..."
56
+ rm -rf gh-pages/assets/tree-sitter-kotlin*
57
+ mkdir -p "gh-pages/assets/tree-sitter-kotlin-$tag"
58
+ cp tree-sitter-kotlin.wasm "gh-pages/assets/tree-sitter-kotlin-$tag"
59
+ tree gh-pages/assets
35
60
36
- # TODO: Update this to the new playground layout. This would
37
- # involve deploying the Wasm binary to
38
- #
39
- # assets/tree-sitter-kotlin-<version>/tree-sitter-kotlin.wasm
40
- #
41
- # and would also require rewriting the versions in the
42
- # index.html (both the reference to the parser binary and the
43
- # displayed version). Ideally this should be performed by a
44
- # script that generates the index.html automatically. Perhaps
45
- # we could even generate this to automatically download
46
- # web-tree-sitter and maybe even generate playground.js from
47
- # the upstream playground.
48
- #
49
- # Also, we would likely want to replace peaceiris/actions-gh-pages
50
- # with the `gh` command-line tool, which should already be
51
- # preinstalled in the runner.
61
+ echo "==> Updating version on website..."
62
+ sed -i "s|\(LANGUAGE_BASE_URL = \"\)[^\"]*\(\"\)|\1$tag\2|g" gh-pages/index.html
63
+ sed -i "s|\(<span class=\"version\">\)[^<]*\(</span>\)|\1$tag\2|g" gh-pages/index.html
52
64
53
- # - name: Set up folder for GitHub Pages deployment
54
- # run: |
55
- # mkdir public
56
- # cp tree-sitter-kotlin.wasm public/tree-sitter-parser.wasm
57
- # - name: Deploy to GitHub Pages
58
- # uses: peaceiris/actions-gh-pages@v3
59
- # with:
60
- # github_token: ${{ secrets.GITHUB_TOKEN }}
61
- # publish_dir: ./public
62
- # keep_files: true
63
- # user_name: 'github-actions[bot]'
64
- # user_email: 'github-actions[bot]@users.noreply.github.com'
65
+ echo "==> Committing and pushing gh-pages branch..."
66
+ cd gh-pages
67
+ git add .
68
+ git commit -m "Deploy tree-sitter-kotlin $tag ($sha)"
69
+ git push
0 commit comments