mirror of
https://github.com/tree-sitter/tree-sitter.git
synced 2026-09-10 07:26:23 -04:00
162 lines
4.4 KiB
YAML
162 lines
4.4 KiB
YAML
name: Release
|
|
|
|
on:
|
|
schedule:
|
|
- cron: '5 5 * * *'
|
|
workflow_dispatch:
|
|
inputs:
|
|
tag_name:
|
|
description: 'Tag name for release'
|
|
required: false
|
|
default: nightly
|
|
push:
|
|
tags:
|
|
- v[0-9]+.[0-9]+.[0-9]+
|
|
|
|
jobs:
|
|
build:
|
|
uses: ./.github/workflows/build.yml
|
|
with:
|
|
run-test: false
|
|
|
|
release:
|
|
name: Release on GitHub
|
|
runs-on: ubuntu-latest
|
|
needs: build
|
|
permissions:
|
|
id-token: write
|
|
attestations: write
|
|
contents: write
|
|
steps:
|
|
- if: github.event_name == 'workflow_dispatch'
|
|
env:
|
|
TAG_NAME: ${{ github.event.inputs.tag_name }}
|
|
run: echo "TAG_NAME=${TAG_NAME}" >> $GITHUB_ENV
|
|
|
|
- if: github.event_name == 'schedule'
|
|
run: echo 'TAG_NAME=nightly' >> $GITHUB_ENV
|
|
|
|
- if: github.event_name == 'push'
|
|
run: echo "TAG_NAME=${GITHUB_REF_NAME}" >> $GITHUB_ENV
|
|
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v7.0.1
|
|
|
|
- name: Download build artifacts
|
|
uses: actions/download-artifact@v8
|
|
with:
|
|
path: artifacts
|
|
|
|
- name: Display structure of downloaded files
|
|
run: ls -lR
|
|
working-directory: artifacts
|
|
|
|
- name: Prepare release artifacts
|
|
run: |
|
|
mkdir -p target web
|
|
mv artifacts/tree-sitter.wasm/* web/
|
|
|
|
tar -czf target/web-tree-sitter.tar.gz -C web .
|
|
|
|
rm -r artifacts/tree-sitter.wasm
|
|
|
|
for platform in $(cd artifacts; ls | sed 's/^tree-sitter\.//'); do
|
|
exe=$(ls artifacts/tree-sitter.$platform/tree-sitter*)
|
|
chmod +x $exe
|
|
gzip --stdout --name $exe > target/tree-sitter-$platform.gz
|
|
zip -j9 target/tree-sitter-cli-$platform.zip $exe
|
|
done
|
|
rm -rf artifacts
|
|
ls -l target/
|
|
|
|
- name: Generate attestations
|
|
uses: actions/attest-build-provenance@v4
|
|
with:
|
|
subject-path: |
|
|
target/tree-sitter-*.gz
|
|
target/tree-sitter-cli-*.zip
|
|
target/web-tree-sitter.tar.gz
|
|
|
|
- if: env.TAG_NAME == 'nightly'
|
|
run: |
|
|
echo 'PRERELEASE=--prerelease' >> $GITHUB_ENV
|
|
gh release delete nightly --yes || true
|
|
git push https://${GITHUB_ACTOR}:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY} :nightly || true
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
|
|
- name: Create release
|
|
run: |-
|
|
gh release create ${{ env.TAG_NAME }} $PRERELEASE \
|
|
target/tree-sitter-*.gz \
|
|
target/tree-sitter-cli-*.zip \
|
|
target/web-tree-sitter.tar.gz
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
|
|
crates_io:
|
|
name: Publish packages to Crates.io
|
|
if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.tag_name != 'nightly')
|
|
runs-on: ubuntu-latest
|
|
environment: crates
|
|
permissions:
|
|
id-token: write
|
|
contents: read
|
|
needs: release
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v7.0.1
|
|
|
|
- name: Set up Rust
|
|
uses: actions-rust-lang/setup-rust-toolchain@v1
|
|
|
|
- name: Set up registry token
|
|
id: auth
|
|
uses: rust-lang/crates-io-auth-action@v1
|
|
|
|
- name: Publish crates to Crates.io
|
|
uses: katyo/publish-crates@v2
|
|
with:
|
|
registry-token: ${{ steps.auth.outputs.token }}
|
|
|
|
npm:
|
|
name: Publish packages to npmjs.com
|
|
if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.tag_name != 'nightly')
|
|
runs-on: ubuntu-latest
|
|
environment: npm
|
|
permissions:
|
|
id-token: write
|
|
contents: read
|
|
needs: release
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
directory: [crates/cli/npm, lib/binding_web]
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v7.0.1
|
|
|
|
- name: Set up Node
|
|
uses: actions/setup-node@v7.0.0
|
|
with:
|
|
node-version: 24
|
|
registry-url: https://registry.npmjs.org
|
|
|
|
- name: Set up Rust
|
|
uses: actions-rust-lang/setup-rust-toolchain@v1
|
|
|
|
- name: Build wasm
|
|
if: matrix.directory == 'lib/binding_web'
|
|
run: |
|
|
cd ${{ matrix.directory }}
|
|
npm ci
|
|
npm run build
|
|
npm run build:debug
|
|
CJS=true npm run build
|
|
CJS=true npm run build:debug
|
|
npm run build:dts
|
|
|
|
- name: Publish to npmjs.com
|
|
working-directory: ${{ matrix.directory }}
|
|
run: npm publish
|