Skip to content

Create Release

Create Release #5

Workflow file for this run

name: Create Release
on:
push:
branch:
- gh_release_build_experimenting # TODO: remove after testing
- main
tags:
- release_test # TODO: remove after testing
- v[0-9]+.[0-9]+.[0-9]+
jobs:
build:
name: Setup
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, ubuntu-latest]
include:
- arch: x86_64
os: ubuntu-latest
- arch: macos_arm64
os: macos-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Install Node
uses: actions/setup-node@v3
with:
node-version: 20
# We need emscripten to build the wasm file
- name: Install Emscripten
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y emscripten
- name: Install Emscripten
if: matrix.os == 'macos-latest'
run: |
brew install emscripten
- name: Build Code
run: |
npm install nan # why? it is a indirect dependency already, yet it cannot be found
npm install
npm run build
zip -r tree-sitter-sql-${{ matrix.arch }}.zip src sql.so tree-sitter-sql.wasm # TODO: add version name
tar -czvf tree-sitter-sql-${{ matrix.arch }}.tar.gz src sql.so grammar.js tree-sitter-sql.wasm # TODO: add version name
- name: upload zip
uses: actions/upload-artifact@v4
with:
name: tree-sitter-sql-${{ matrix.arch }}
path: tree-sitter-sql-${{ matrix.arch }}.*
retention-days: 1
overwrite: true
prepare_artifacts:
needs: [build]
runs-on: ubuntu-latest
env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
- if: github.event_name == 'release'
run: |
TAG_NAME=${{ github.ref }}
echo "TAG_NAME=${TAG_NAME#refs/tags/}" >> $GITHUB_ENV
- name: Generate Linux Zip SHA256 checksums
run: |
cd tree-sitter-sql-x86_64
sha256sum tree-sitter-sql-x86_64.zip > tree-sitter-sql-x86_64.zip.sha256sum
echo "SHA_LINUX_64_ZIP=$(cat tree-sitter-sql-x86_64.zip.sha256sum)" >> $GITHUB_ENV
- name: Generate Linux Tar SHA256 checksums
run: |
cd tree-sitter-sql-x86_64
sha256sum tree-sitter-sql-x86_64.tar.gz > tree-sitter-sql-x86_64.tar.gz.sha256sum
echo "SHA_LINUX_64_TAR=$(cat tree-sitter-sql-x86_64.tar.gz.sha256sum)" >> $GITHUB_ENV
- name: Generate MacOS Zip SHA256 checksums
run: |
cd tree-sitter-sql-macos_arm64
sha256sum tree-sitter-sql-macos_arm64.zip > tree-sitter-sql-macos_arm64.zip.sha256sum
echo "SHA_MACOS_ARM64_ZIP=$(cat tree-sitter-sql-macos_arm64.zip.sha256sum)" >> $GITHUB_ENV
- name: Generate MacOS Tar SHA256 checksums
run: |
cd tree-sitter-sql-macos_arm64
sha256sum tree-sitter-sql-macos_arm64.tar.gz > tree-sitter-sql-macos_arm64.tar.gz.sha256sum
echo "SHA_MACOS_ARM64_TAR=$(cat tree-sitter-sql-macos_arm64.tar.gz.sha256sum)" >> $GITHUB_ENV
- name: Publish release
run: |
echo $GITHUB_ENV
echo $(git describe --tags --abbrev=0)
envsubst < "$GITHUB_WORKSPACE/.github/workflows/notes.md" > "$RUNNER_TEMP/notes.md"
gh release create $(git describe --tags --abbrev=0) --notes-file "$RUNNER_TEMP/notes.md" --target $GITHUB_SHA tree-sitter-sql-x86_64/tree-sitter-sql-x86_64.* tree-sitter-sql-macos_arm64/tree-sitter-sql-macos_arm64.*