Skip to content

Commit

Permalink
Merge branch 'sprint-1.11' into update-readme-staging
Browse files Browse the repository at this point in the history
# Conflicts:
#	.github/workflows/build-zbox.yaml
#	.github/workflows/release-zboxcli.yml
#	README.md
  • Loading branch information
Jayashsatolia403 committed Nov 1, 2023
2 parents 4e92da1 + 1fa3b28 commit 8061495
Show file tree
Hide file tree
Showing 10 changed files with 187 additions and 183 deletions.
214 changes: 90 additions & 124 deletions .github/workflows/build-zbox.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ on:
push:
branches:
- master
- dev
- sprint*
- staging
tags:
- 'v*.*.*'
pull_request:
workflow_dispatch:

jobs:
Expand All @@ -25,136 +26,101 @@ jobs:
- name: Setup go 1.20
uses: actions/setup-go@v2
with:
go-version: '1.20' # The Go version to download (if necessary) and use.

- name: Set GITHUB_ENV
run: |
echo "BRANCH=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
if [[ "${{github.base_ref}}" == "master" || "${{github.ref}}" == "refs/heads/master" ]]; then
echo "TAG=v0.0.0-master" >> $GITHUB_ENV
elif [[ "${{github.base_ref}}" == "dev" || "${{github.ref}}" == "refs/heads/dev" ]]; then
echo "TAG=v0.0.0-dev" >> $GITHUB_ENV
elif [[ "${{github.base_ref}}" == "staging" || "${{github.ref}}" == "refs/heads/staging" ]]; then
echo "TAG=v0.0.0-staging" >> $GITHUB_ENV
else
echo "TAG=$(echo ${GITHUB_REF#refs/tags/})" >> $GITHUB_ENV
fi
- name: Install
run: make install

- name: Zip release
run: tar -czvf zbox-linux.tar.gz ./zbox

- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: zbox-linux.tar.gz
tag: ${{ env.TAG }}
overwrite: true
file_glob: true

- name: 'Upload Artifact'
uses: actions/upload-artifact@v2
with:
name: zbox-linux
path: zbox
retention-days: 5

build-windows:
name: Build-windows
runs-on: windows-runner
steps:
- name: Setup go 1.20
uses: actions/setup-go@v2
with:
go-version: '1.20' # The Go version to download (if necessary) and use.

- name: Checkout
uses: actions/checkout@v2

- name: Set GITHUB_ENV
run: |
IF ( "${{github.base_ref}}" -eq "master" -OR "${{github.ref}}" -eq "refs/heads/master" ){
echo "TAG=v0.0.0-master" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
} ElseIf ( "${{github.base_ref}}" -eq "dev" -OR "${{github.ref}}" -eq "refs/heads/dev" ){
echo "TAG=v0.0.0-dev" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
} ElseIf ( "${{github.base_ref}}" -eq "staging" -OR "${{github.ref}}" -eq "refs/heads/staging" ){
echo "TAG=v0.0.0-staging" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
} ELSE {
echo "TAG=${{github.ref}}" | %{$_ -replace('refs/tags/', '')} | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
}
go-version: '1.20'

- name: Install
run: make install

- name: Zip release
run: |
copy zbox zbox.exe
7z a zbox-windows.zip zbox.exe
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: zbox-windows.zip
tag: ${{ env.TAG }}
overwrite: true
file_glob: true
lsb_release -a
docker run -v $PWD:/app -w /app golang:1.20 sh -c "make install"
- name: 'Upload Artifact'
uses: actions/upload-artifact@v2
with:
name: zbox-windows
name: zbox-linux
path: zbox
retention-days: 5

build-macos:
name: Build-macos
runs-on: macos-runner
steps:

- name: Setup go 1.20
uses: actions/setup-go@v2
with:
go-version: '1.20' # The Go version to download (if necessary) and use.

- name: Checkout
uses: actions/checkout@v2

- name: Set GITHUB_ENV
run: |
echo "BRANCH=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
if [[ "${{github.base_ref}}" == "master" || "${{github.ref}}" == "refs/heads/master" ]]; then
echo "TAG=v0.0.0-master" >> $GITHUB_ENV
elif [[ "${{github.base_ref}}" == "dev" || "${{github.ref}}" == "refs/heads/dev" ]]; then
echo "TAG=v0.0.0-dev" >> $GITHUB_ENV
elif [[ "${{github.base_ref}}" == "staging" || "${{github.ref}}" == "refs/heads/staging" ]]; then
echo "TAG=v0.0.0-dev" >> $GITHUB_ENV
else
echo "TAG=$(echo ${GITHUB_REF#refs/tags/})" >> $GITHUB_ENV
fi
- name: Install
run: make install
- name: Zip release
run: tar -czvf zbox-macos.tar.gz ./zbox

- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: zbox-macos.tar.gz
tag: ${{ env.TAG }}
overwrite: true
file_glob: true

- name: 'Upload Artifact'
uses: actions/upload-artifact@v2
with:
name: zbox-macos
path: zbox
retention-days: 5
# build-windows:
# name: Build-windows
# runs-on: windows-runner
# defaults:
# run:
# shell: msys2 {0}
# strategy:
# matrix:
# sys: [ MINGW64 ]
# steps:
# - uses: msys2/setup-msys2@v2
# with:
# msystem: ${{matrix.sys}}

# - name: Install libraries
# run: |
# echo 'Y'| pacman -S base-devel git gcc make

# - name: Install Clang and Go for MINGW64
# run: |
# echo 'y'| pacman -S mingw-w64-x86_64-clang mingw-w64-x86_64-go zip unzip

# - name: Set environment variables
# run: |
# export GOROOT=/mingw64/lib/go
# export GOPATH=/mingw64
# export PATH=$PATH:$GOROOT/bin
# export PATH=$PATH:/usr/bin/7z

# # use clang as a default compiler for CGO
# go env -w "CC=/mingw64/bin/clang.exe"

# - name: Checkout
# uses: actions/checkout@v2

# - name: Install
# run: make install

# - name: Zip release
# run: |
# # download dll files
# wget https://github.com/0chain/zboxcli/files/11840033/windows.dll.s.zip
# unzip -o windows.dll.s.zip
# cp zbox zbox.exe
# zip zbox-windows.zip zbox.exe libgcc_s_seh-1.dll libstdc++-6.dll libwinpthread-1.dll

# - name: 'Upload Artifact'
# uses: actions/upload-artifact@v2
# with:
# name: zbox-windows.zip
# path: zbox-windows.zip
# retention-days: 5

# - name: cleanup workspace
# run: |
# rm -Recurse ${{github.workspace}}\*
# shell: powershell

# build-macos:
# name: Build-macos
# runs-on: macos-runner
# steps:

# - name: Setup go 1.20
# uses: actions/setup-go@v2
# with:
# go-version: '1.20' # The Go version to download (if necessary) and use.

# - name: Checkout
# uses: actions/checkout@v2

# - name: Install
# run: make install

# - name: 'Upload Artifact'
# uses: actions/upload-artifact@v2
# with:
# name: zbox-macos
# path: zbox
# retention-days: 5

# - name: cleanup workspace
# run: |
# rm -rf ./*
6 changes: 3 additions & 3 deletions .github/workflows/gosdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
workflow_dispatch:
inputs:
gosdk:
description: 'The version of 0Chain GoSDK'
description: 'The 0Chain GoSDK version or branch'
required: true

jobs:
Expand All @@ -18,7 +18,7 @@ jobs:
- name: Setup go 1.20
uses: actions/setup-go@v2
with:
go-version: '1.20'
go-version: '1.20'

- name: Checkout
uses: actions/checkout@v1
Expand All @@ -44,4 +44,4 @@ jobs:
see full changelog on https://github.com/0chain/gosdk/releases/tag/${{ github.event.inputs.gosdk }}
draft: false
reviewers: cnlangzi
labels: GoSDK
labels: GoSDK
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: BUILD-ZBOXCLI
name: RELEASE-ZBOXCLI

on:
workflow_dispatch:
Expand Down Expand Up @@ -96,11 +96,34 @@ jobs:
build-windows:
name: Build-windows
runs-on: windows-runner
defaults:
run:
shell: msys2 {0}
strategy:
matrix:
sys: [ MINGW64 ]
steps:
- name: Setup go 1.20
uses: actions/setup-go@v2
- uses: msys2/setup-msys2@v2
with:
go-version: '1.20' # The Go version to download (if necessary) and use.
msystem: ${{matrix.sys}}

- name: Install libraries
run: |
echo 'Y'| pacman -S base-devel git gcc make
- name: Install Clang and Go for MINGW64
run: |
echo 'y'| pacman -S mingw-w64-x86_64-clang mingw-w64-x86_64-go zip unzip
- name: Set environment variables
run: |
export GOROOT=/mingw64/lib/go
export GOPATH=/mingw64
export PATH=$PATH:$GOROOT/bin
export PATH=$PATH:/usr/bin/7z
# use clang as a default compiler for CGO
go env -w "CC=/mingw64/bin/clang.exe"
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -110,16 +133,24 @@ jobs:

- name: Zip release
run: |
copy zbox zbox.exe
7z a zbox-windows.zip zbox.exe
# download dll files
wget https://github.com/0chain/zboxcli/files/11840033/windows.dll.s.zip
unzip -o windows.dll.s.zip
cp zbox zbox.exe
zip zbox-windows.zip zbox.exe libgcc_s_seh-1.dll libstdc++-6.dll libwinpthread-1.dll
- name: 'Upload Artifact'
uses: actions/upload-artifact@v2
with:
name: zbox-windows
path: zbox
name: zbox-windows.zip
path: zbox-windows.zip
retention-days: 5

- name: cleanup workspace
run: |
rm -Recurse ${{github.workspace}}\*
shell: powershell

build-macos:
name: Build-macos
runs-on: macos-runner
Expand All @@ -145,3 +176,7 @@ jobs:
name: zbox-macos
path: zbox
retention-days: 5

- name: cleanup workspace
run: |
rm -rf ./*
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,9 @@ GOMODCORE := $(GOMODBASE)/zcncore
VERSION_FILE := $(ROOT_DIR)/core/version/version.go
MAJOR_VERSION := "1.0"

PLATFORMOS := $(shell uname | tr "[:upper:]" "[:lower:]")

include _util/printer.mk

.PHONY: install-all herumi-all gosdk-all show

default: help show
default: help

#GO BUILD SDK
gomod-download:
Expand Down
15 changes: 1 addition & 14 deletions cmd/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,8 @@ var downloadCmd = &cobra.Command{
os.Exit(1)
}

var blobberID string
if fflags.Changed("blobber_id") {
blobberID = cmd.Flag("blobber_id").Value.String()
}

if thumbnail {
errE = allocationObj.DownloadThumbnail(localPath, remotePath, verifyDownload, statusBar, true)
} else if blobberID != "" {
errE = allocationObj.DownloadFromBlobber(blobberID, localPath, remotePath, statusBar)
} else {
if startBlock != 0 || endBlock != 0 {
errE = allocationObj.DownloadFileByBlock(localPath, remotePath, startBlock, endBlock, numBlocks, verifyDownload, statusBar, true)
Expand Down Expand Up @@ -189,12 +182,7 @@ var downloadCmd = &cobra.Command{
os.Exit(1)
}
if !statusBar.success {
// status bar always returns failure when downloading from sigle blobber. Hence returning the zero exit status
if fflags.Changed("blobber_id") {
os.Exit(0)
} else {
os.Exit(1)
}
os.Exit(1)
}

},
Expand Down Expand Up @@ -246,7 +234,6 @@ func init() {
downloadCmd.PersistentFlags().String("allocation", "", "Allocation ID")
downloadCmd.PersistentFlags().String("remotepath", "", "Remote path to download")
downloadCmd.PersistentFlags().String("localpath", "", "Local path of file to download")
downloadCmd.PersistentFlags().String("blobber_id", "", "to download the data shard present in that blobber")
downloadCmd.PersistentFlags().String("authticket", "", "Auth ticket fot the file to download if you dont own it")
downloadCmd.PersistentFlags().String("lookuphash", "", "The remote lookuphash of the object retrieved from the list")
downloadCmd.PersistentFlags().String("multidownloadjson", "", "A JSON file containing multi download options")
Expand Down

0 comments on commit 8061495

Please sign in to comment.