Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: release

on:
workflow_dispatch:

permissions:
contents: write

jobs:
create_release:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- name: Execute shell script
id: build_deploy
run: |
chmod +x ./build-deploy.sh
./build-deploy.sh
release_name=$(find . -name "zoekt-*.gz" | xargs -I'{}' basename "{}" | sed 's/zoekt-//' | cut -d. -f1)
echo "release_name=$release_name" >> "$GITHUB_OUTPUT"
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
repository: leboncoin/zoekt
tag_name: ${{ steps.build_deploy.outputs.release_name }}
files: zoekt-${{ steps.build_deploy.outputs.release_name }}.tar.gz
draft: false
prerelease: false
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ bazel-bin
bazel-out
bazel-testlogs
bazel-zoekt
zoekt-bin
55 changes: 55 additions & 0 deletions build-deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash

# this script packages up all the binaries, and a script (deploy.sh)
# to twiddle with the server and the binaries

set -ex

# Put the date first so we can sort.
if [[ -z "$VERSION" ]]; then
VERSION=$(date --iso-8601=minutes | tr -d ':' | sed 's|\+.*$||')
if [[ -d .git ]]; then
VERSION=${VERSION}-$(git show --pretty=format:%h -q)
fi
fi

set -u

out=zoekt-${VERSION}
mkdir -p ${out}

for d in $(find cmd/ -maxdepth 1 -type d)
do
go build \
-tags netgo \
-ldflags "-X github.com/sourcegraph/zoekt.Version=dev" \
-o ${out}/$(basename $d) \
github.com/sourcegraph/zoekt/$d
done

cat <<EOF > ${out}/deploy.sh
#!/bin/bash

echo "Set the following in the environment."
echo ""
echo ' export PATH="'$PWD'/bin:$PATH'
echo ""

set -eux

# Allow sandbox to create NS's
sudo sh -c 'echo 1 > /proc/sys/kernel/unprivileged_userns_clone'

# we mmap the entire index, but typically only want the file contents.
sudo sh -c 'echo 1 >/proc/sys/vm/overcommit_memory'

# allow bind to 80 and 443
sudo setcap 'cap_net_bind_service=+ep' bin/zoekt-webserver

EOF

chmod 755 ${out}/*

tar --owner=root --group=root -czf zoekt-deploy-${VERSION}.tar.gz ${out}/*

rm -rf ${out}
22 changes: 22 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

# this script packages up all the binaries, and a script (deploy.sh)
# to twiddle with the server and the binaries

set -ex

set -u

out=zoekt-bin
mkdir -p ${out}

for d in $(find cmd/ -maxdepth 1 -type d)
do
go build \
-tags netgo \
-ldflags "-X github.com/sourcegraph/zoekt.Version=dev" \
-o ${out}/$(basename $d) \
github.com/sourcegraph/zoekt/$d
done

chmod 755 ${out}/*
2 changes: 2 additions & 0 deletions cmd/zoekt-webserver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ func main() {

debugserver.AddHandlers(serveMux, *enablePprof)

addMCPHandlers(serveMux, searcher)

if *enableIndexserverProxy {
socket := filepath.Join(*indexDir, "indexserver.sock")
sglog.Scoped("server").Info("adding reverse proxy", sglog.String("socket", socket))
Expand Down
Loading