Skip to content

Commit

Permalink
ci: bundle after the release action maybe?
Browse files Browse the repository at this point in the history
  • Loading branch information
stackmystack committed May 15, 2024
1 parent 31ce99a commit 8aea5a0
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 67 deletions.
81 changes: 23 additions & 58 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,49 +7,26 @@ jobs:
strategy:
fail-fast: false
matrix:
lang:
- bash
- c
# - cpp # FIXME: `lang` needs to handle things differently maybe because it won't generate for this
- embedded-template
- html
- java
- javascript
- json
- python
- ruby
- rust
target:
# - { platform: linux-arm, triplet: arm-linux-gnueabi }
# - { platform: linux-arm64, triplet: aarch64-linux-gnu }
- { platform: linux-x64, triplet: x86_64-linux-gnu }
# NOTE:
# Now that we depend in tree-sitter-cli to regenerate the pulled parser
# all these platform doesn't make any sense. They're simply unsupported
# in the releases of tree-sitter.
# - arm-linux-gnueabihf
# - aarch64-linux-gnu
# - mipsel-linux-gnu
# - powerpc64le-linux-gnu
#
# FIXME: tree-sitter has a known (by me) bug by now:
# ld: unknown option -soname
# It should be patched to support
# - x86_64-apple-darwin
# - x86_64h-apple-darwin
# - i386-apple-darwin
#
# NOTE: Tese are supported by multiarch/crossbuild but not tree-sitter
# - x86_64-w64-mingw32
# - i686-w64-mingw32
runs-on: ubuntu-latest
- { os: ubuntu-latest, platform: linux-x64 }
- { os: macos-latest, platform: macos-arm64 }
runs-on: ${{ matrix.target.os }}
env:
PLATFORM: ${{ matrix.target.platform }}
steps:
- uses: actions/checkout@v2
- name: Build ${{ matrix.lang }} for ${{ matrix.target.platform }}
env:
PLATFORM: ${{ matrix.target.platform }}
- name: Build for ${{ matrix.target.platform }}
run: |
./lang d bash c embedded-template html java javascript json python ruby rust
- name: Prepare git # To get tags from `git describe`
run: git fetch --prune --unshallow
- name: Make .deb
if: ${{ matrix.target.os == "ubuntu-latest" }}
run: |
./package/deb
- name: Make zip and tar
run: |
./lang d ${{ matrix.lang }}
./package/zip
- name: Release
uses: softprops/action-gh-release@v1
with:
Expand All @@ -64,27 +41,14 @@ jobs:
build-macos:
strategy:
fail-fast: false
matrix:
lang:
- bash
- c
# - cpp
- embedded-template
- html
- java
- javascript
- json
- python
- ruby
- rust
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Build ${{ matrix.lang }} for macos
- name: Build for macos
env:
PLATFORM: "macos-arm64"
run: |
./lang d ${{ matrix.lang }}
./lang d bash c embedded-template html java javascript json python ruby rust
- name: Release
uses: softprops/action-gh-release@v1
with:
Expand All @@ -103,10 +67,6 @@ jobs:
- uses: actions/checkout@v2
- name: Prepare git # To get tags from `git describe`
run: git fetch --prune --unshallow
- name: Bundle all parsers
run: |
./package/deb
./package/zip
- name: Release
uses: softprops/action-gh-release@v1
with:
Expand All @@ -116,3 +76,8 @@ jobs:
files: ref
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: list everything local
run: |
apt update -y
apt install tree -y
tree .
5 changes: 4 additions & 1 deletion lang
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,12 @@ fi
# Clone then Build Languages passed in args #
# ################################################ #

top=$(pwd)

for lang in "$@"
do

cd "$top"
GET=tree-sitter-$lang
if [ -z "$PLATFORM" ]
then
Expand All @@ -112,7 +115,7 @@ do
echo "> $lang: checking out $checkout"
git checkout "$checkout"
fi
cd ..
cd -
# Regenerate. See https://github.com/tree-sitter/tree-sitter/issues/2731
cd $GET
echo "> $lang: regenerating"
Expand Down
9 changes: 7 additions & 2 deletions package/deb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ set -euo pipefail
IFS=$'\n\t'
set -vx

arch=$(dpkg-architecture -q DEB_BUILD_ARCH)
version_num=$(git describe --tags --abbrev=0 | sed -E 's/v([0-9]+\.[0-9]+)/\1/')
commit_count=$(git rev-list --count --first-parent HEAD)

Expand All @@ -21,11 +22,15 @@ mkdir -p "$dst"
cat <<-EOF > "$debian/control"
Package: $pkg
Version: $version
Architecture: amd64
Architecture: $arch
Maintainer: Firas al-Khalil <[email protected]>
Description: A bunch of tree-sitter parsers.
EOF

cp lib/libtree-sitter-*.so "$dst"
for i in lib/*-"$PLATFORM"."$ext"
do
cp $i $(echo $i | sed -E "s/^(lib\/)(.*)-$PLATFORM(\.$ext)$/$dst\/\2\3/")
done

dpkg-deb --build "$pkg" "lib/$pkg.deb"

28 changes: 22 additions & 6 deletions package/zip
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,26 @@ set -euo pipefail
IFS=$'\n\t'
set -vx

pkg='tree-sitter-parsers'
rm -rf "$pkg"
mkdir "$pkg"
case "$OSTYPE" in
darwin*)
ext="dylib"
;;
*)
ext="so"
;;
esac

cp lib/libtree-sitter-*.dylib "$pkg"
zip "lib/$pkg.zip" "$pkg"/libtree-sitter-*.dylib
tar -cvzf "lib/$pkg.tar.gz" "$pkg"/libtree-sitter-*.dylib
pkg="tree-sitter-parsers"
dst=$pkg
pkg_name="$pkg-$PLATFORM"

rm -rf "$dst"
mkdir "$dst"

for i in lib/*-"$PLATFORM"."$ext"
do
cp $i $(echo $i | sed -E "s/^(lib\/)(.*)-$PLATFORM(\.$ext)$/$dst\/\2\3/")
done

zip "lib/$pkg_name.zip" "$dst"/*
tar -cvzf "lib/$pkg_name.tar.gz" "$dst"/*

0 comments on commit 8aea5a0

Please sign in to comment.