Skip to content

Commit

Permalink
Produce binaries for releases (#19)
Browse files Browse the repository at this point in the history
A zip file containing the standalone vsql-cli and vsql-server can be
downloaded from the Github Releases page to use vsql without needing a
V compilication environment.

At the moment only macOS and windows binaries are produced because
linux cross compilation is not working for me yet:
vlang/v#10992

Fixes #17
  • Loading branch information
elliotchance committed Jul 29, 2021
1 parent baa523a commit 898951f
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
38 changes: 37 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,52 @@ on:
jobs:
run:
name: Run
runs-on: ubuntu-latest
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up V version latest
uses: nocturlab/setup-vlang-action@v1
with:
v-version: master
id: v

- name: Verify fmt
run: v fmt -verify .

- name: Run SQL tests
run: v -stats -prod test vsql

- name: Prepare version
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- name: Build macOS binaries
run: |
v -prod vsql-cli.v
v -prod vsql-server.v
zip vsql-$RELEASE_VERSION-macos.zip vsql-cli vsql-server
# See https://github.com/vlang/v/issues/10992
#- name: Build linux binaries
# run: |
# v -os linux -prod vsql-cli.v
# v -os linux -prod vsql-server.v
# zip vsql-$RELEASE_VERSION-linux.zip vsql-cli vsql-server

# Cross compiling for windows takes a long time because mingw-w64 has to be
# installed. So we only run this when we're doing a release.
- name: Build windows binaries
if: startsWith(github.ref, 'refs/tags/')
run: |
brew install mingw-w64
v -os windows -prod vsql-cli.v
v -os windows -prod vsql-server.v
zip vsql-$RELEASE_VERSION-windows.zip vsql-cli.exe vsql-server.exe
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
vsql-$RELEASE_VERSION-macos.zip
vsql-$RELEASE_VERSION-windows.zip
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
**/.DS_Store
vsql-cli
vsql-server
*.vsql
6 changes: 3 additions & 3 deletions vsql-server.v
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ fn write_command_complete(client_id int, mut conn net.TcpConn, result vsql.Resul
// TODO(elliotchance): This is a hack that will probably cause issues.
mut tag := 'SELECT $result.rows.len'
if result.columns == ['msg'] && result.rows.len == 1 {
tag = result.rows[0].get_string('msg')
tag = result.rows[0].get_string('msg') or { '$err' }
}

mut msg_len := 4 // self
Expand Down Expand Up @@ -220,15 +220,15 @@ fn write_data_row(mut conn net.TcpConn, columns []string, row vsql.Row) {
mut msg_len := 4 // self
msg_len += 2 // cols
for column in columns {
v := row.get_string(column)
v := row.get_string(column) or { '$err' }
msg_len += 4 + v.len
}

write_int32(mut conn, msg_len)
write_int16(mut conn, i16(columns.len))

for column in columns {
v := row.get_string(column)
v := row.get_string(column) or { '$err' }
write_int32(mut conn, v.len)
write_bytes(mut conn, v.bytes())
}
Expand Down

0 comments on commit 898951f

Please sign in to comment.