chore(main): release 0.1.5 (#37) #37
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
| name: Publish packages | |
| on: | |
| push: | |
| tags: | |
| - "*" | |
| workflow_dispatch: | |
| inputs: | |
| ref: | |
| description: "Ref to publish" | |
| required: false | |
| permissions: | |
| contents: write | |
| id-token: write | |
| attestations: write | |
| env: | |
| REF: ${{ inputs.ref || github.ref_name }} | |
| REPO_NAME: tree-sitter-mdn | |
| TREE_SITTER_ABI_VERSION: 14 | |
| jobs: | |
| github: | |
| # See: https://github.com/tree-sitter/workflows/blob/5369718a08f77b4137e79f309a246e328e9459ad/.github/workflows/release.yml | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| persist-credentials: false | |
| ref: ${{ env.REF }} | |
| - name: Set up Emscripten | |
| uses: mymindstorm/setup-emsdk@6ab9eb1bda2574c4ddb79809fc9247783eaf9021 # v14 | |
| with: | |
| version: "3.1.64" | |
| - name: Set up tree-sitter CLI | |
| uses: tree-sitter/setup-action/cli@c4c258862a6a7e43a7aef152256bbf659972c408 # v2 | |
| - name: Install dependencies | |
| run: |- | |
| if jq -e "$JQ_SCRIPT" package.json >/dev/null; then | |
| npm i --ignore-scripts --omit peer --omit optional | |
| fi | |
| env: | |
| JQ_SCRIPT: >- | |
| .dependencies + .devDependencies | | |
| with_entries(select( | |
| (.key | startswith("tree-sitter-")) | |
| and (.key != "tree-sitter-cli") | |
| )) | | |
| length > 0 | |
| - name: Generate parser | |
| shell: bash | |
| run: | | |
| while read -r grammar; do | |
| grammar_dir=$(dirname "$grammar") | |
| pushd "$grammar_dir" | |
| tree-sitter generate | |
| popd > /dev/null | |
| done < <(find . -name grammar.js -not -path './node_modules/*') | |
| - name: Build Wasm binaries | |
| shell: bash | |
| run: |- | |
| while read -r grammar; do | |
| tree-sitter build --wasm "${grammar%/grammar.js}" | |
| done < <(find . -name grammar.js -not -path './node_modules/*') | |
| - name: Create source code tarball | |
| run: | | |
| git ls-files > "$RUNNER_TEMP/files" | |
| while read -r grammar; do | |
| : "$(dirname "$grammar")"; : "${_/\./}"; src_dir="$_${_:+/}src" | |
| printf '%s\n' >> "$RUNNER_TEMP/files" \ | |
| "$src_dir"/parser.c "$src_dir"/grammar.json \ | |
| "$src_dir"/node-types.json "$src_dir"/tree_sitter/* | |
| done < <(find . -name grammar.js -not -path './node_modules/*') | |
| tar cvzf "$REPO_NAME.tar.gz" -T <(sort -u "$RUNNER_TEMP/files") | |
| - name: Generate attestations | |
| uses: actions/attest-build-provenance@977bb373ede98d70efdf65b84cb5f73e068dcc2a # v3.0.0 | |
| with: | |
| subject-path: | | |
| *.wasm | |
| ${{ env.REPO_NAME }}.tar.gz | |
| - name: Update GitHub release | |
| run: gh release upload "$REF" *.wasm "$REPO_NAME.tar.gz" --clobber | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| crates: | |
| # See: https://github.com/tree-sitter/workflows/blob/5369718a08f77b4137e79f309a246e328e9459ad/.github/workflows/package-crates.yml | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| persist-credentials: false | |
| ref: ${{ env.REF }} | |
| - name: Set up Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c # v1.15.2 | |
| with: | |
| toolchain: stable | |
| - name: Set up tree-sitter CLI | |
| uses: tree-sitter/setup-action/cli@c4c258862a6a7e43a7aef152256bbf659972c408 # v2 | |
| - name: Install dependencies | |
| run: |- | |
| if jq -e "$JQ_SCRIPT" package.json >/dev/null; then | |
| npm i --ignore-scripts --omit peer --omit optional | |
| fi | |
| env: | |
| JQ_SCRIPT: >- | |
| .dependencies + .devDependencies | | |
| with_entries(select( | |
| (.key | startswith("tree-sitter-")) | |
| and (.key != "tree-sitter-cli") | |
| )) | | |
| length > 0 | |
| - name: Regenerate parser | |
| run: | | |
| while read -r grammar; do | |
| grammar_dir=$(dirname "$grammar") | |
| cd "$grammar_dir" | |
| tree-sitter generate | |
| cd - > /dev/null | |
| done < <(find . -name grammar.js -not -path './node_modules/*' -not -path './.build/*') | |
| - name: Auth (crates.io) | |
| uses: rust-lang/crates-io-auth-action@b7e9a28eded4986ec6b1fa40eeee8f8f165559ec # v1.0.3 | |
| id: auth | |
| - name: Publish (crates.io) | |
| run: cargo publish --allow-dirty | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} |