Skip to content

Commit

Permalink
Use CLI version from VERSION env or git tag (#159)
Browse files Browse the repository at this point in the history
Signed-off-by: Aravinda Vishwanathapura <[email protected]>
  • Loading branch information
aravindavk authored Jan 20, 2022
1 parent fb657e5 commit 3855c46
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/on-pr-submit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ jobs:
- name: Setup Test environment
run: binnacle -v tests/setup.t
- name: Build and Install Storage manager to nodes/containers
run: binnacle -v tests/install.t
run: VERSION="${{ github.ref_name }}" binnacle -v tests/install.t
- name: Run all Tests
run: binnacle -v tests/all
4 changes: 2 additions & 2 deletions .github/workflows/on-release-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
run: |
apk add --update --no-cache --force-overwrite sqlite-dev sqlite-static
cd mgr
shards build --production --release --static --no-debug --stats --time
VERSION="${{ github.ref_name }}" shards build --production --release --static --no-debug --stats --time
- name: Rename kadalu to kadalu-amd64
run: |
mv mgr/bin/kadalu mgr/bin/kadalu-amd64
Expand All @@ -46,7 +46,7 @@ jobs:
- name: Build
working-directory: .
run: |
docker run -i -v `pwd`:/workspace -w /workspace --rm multiarch/alpine:aarch64-edge /bin/sh -c "echo '@edge http://dl-cdn.alpinelinux.org/alpine/edge/community' >>/etc/apk/repositories; apk add --update --no-cache --force-overwrite llvm12-dev llvm12-static crystal@edge gc-dev gcc gmp-dev libatomic_ops libevent-static musl-dev pcre-dev libxml2-dev openssl-dev openssl-libs-static tzdata yaml-dev zlib-static make git g++ shards@edge yaml-static sqlite-dev sqlite-static; cd mgr; shards build --production --release --static --no-debug --stats --time"
docker run -i -v `pwd`:/workspace -w /workspace --rm multiarch/alpine:aarch64-edge /bin/sh -c "echo '@edge http://dl-cdn.alpinelinux.org/alpine/edge/community' >>/etc/apk/repositories; apk add --update --no-cache --force-overwrite llvm12-dev llvm12-static crystal@edge gc-dev gcc gmp-dev libatomic_ops libevent-static musl-dev pcre-dev libxml2-dev openssl-dev openssl-libs-static tzdata yaml-dev zlib-static make git g++ shards@edge yaml-static sqlite-dev sqlite-static; cd mgr; VERSION="${{ github.ref_name }}" shards build --production --release --static --no-debug --stats --time"
- name: Rename kadalu to kadalu-amd64
run: |
sudo mv mgr/bin/kadalu mgr/bin/kadalu-arm64
Expand Down
7 changes: 4 additions & 3 deletions mgr/src/main.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ require "option_parser"

require "./cmds/*"

VERSION = {{ `shards version #{__DIR__}`.chomp.stringify }}
# Set VERSION during build time
VERSION = {{ env("VERSION") && env("VERSION") != "" ? env("VERSION") : `git describe --always --tags --match "[0-9]*" --dirty`.chomp.stringify }}

module CLI
def self.run(args)
Expand All @@ -17,12 +18,12 @@ module CLI
end

parser_1.on("--version", "Show Version information") do
puts "kadalu #{VERSION}"
puts "Kadalu Storage #{VERSION}"
exit
end

parser_1.on("version", "Show Version information") do
puts "kadalu #{VERSION}"
puts "Kadalu Storage #{VERSION}"
exit
end

Expand Down
2 changes: 1 addition & 1 deletion tests/install.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ USE_REMOTE_PLUGIN "docker"
nodes = ["server1", "server2", "server3"]

# Static build Kadalu Storage Manager
TEST "docker run --rm -i -v $PWD:/workspace -w /workspace crystallang/crystal:1.2.0-alpine /bin/sh -c \"apk add --update --no-cache --force-overwrite sqlite-dev sqlite-static && cd mgr && shards install && shards build --static\""
TEST "docker run --rm -i -v $PWD:/workspace -w /workspace crystallang/crystal:1.2.0-alpine /bin/sh -c \"apk add --update --no-cache --force-overwrite sqlite-dev sqlite-static && cd mgr && shards install && VERSION=#{ENV.fetch("VERSION", "")} shards build --static\""

# Install the Static binary to all containers/nodes
# and copy the service files
Expand Down

0 comments on commit 3855c46

Please sign in to comment.