Skip to content

Commit

Permalink
Merge pull request #396 from 0chain/sprint-1.17
Browse files Browse the repository at this point in the history
Sprint 1.17
  • Loading branch information
dabasov authored Sep 1, 2024
2 parents 655d77d + 4d7e2f6 commit 420c49f
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 25 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/distribute-zwalletcli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,21 +185,22 @@ jobs:
mkdir -p ${{ env.REPO_DIR }}/pool/main/z/${{ env.APP_NAME }}/
find ${{ env.DEB_DIR }} -name "*.deb"
for deb in $(find ${{ env.DEB_DIR }} -name "*.deb"); do
cp $deb ${{ env.REPO_DIR }}/pool/main/z/${{ env.APP_NAME }}/
cp -u $deb ${{ env.REPO_DIR }}/pool/main/z/${{ env.APP_NAME }}/
done
- name: Update APT repo
run: |
cd ${{ env.REPO_DIR }}
for dist in ${{ env.DISTRIBUTIONS }}; do
rm -rf dists/${dist}
mkdir -p dists/${dist}
for arch in ${{ env.ARCHITECTURES }}; do
mkdir -p dists/${dist}/main/binary-${arch}
find "pool/main/z/${{ env.APP_NAME }}" -type f -name "${{ env.APP_NAME }}_*~${dist}_${arch}.deb" | \
xargs -I {} apt-ftparchive -o Tree::dists/${dist}::Sections="main" \
-o Tree::dists/${dist}::Architectures="${arch}" \
-o Dir::ArchiveDir="${{ env.REPO_DIR }}" \
packages {} > dists/${dist}/main/binary-${arch}/Packages
packages {} >> dists/${dist}/main/binary-${arch}/Packages
done
apt-ftparchive -o APT::FTPArchive::Release::Origin="${{ env.APP_NAME }}" \
Expand Down
118 changes: 102 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ on:
description: 'Create release as draft'
required: false
default: 'true'
prerelease:
description: 'Create release as prerelease'
required: false
default: 'false'

env:
GITHUB_TOKEN: ${{ secrets.GOSDK }}
Expand All @@ -22,8 +26,25 @@ env:
GO_VERSION: 1.21

jobs:
create_release:
runs-on: ubuntu-latest
outputs:
release_id: ${{ steps.create_release.outputs.id }}
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.event.inputs.tag }}
release_name: ${{ github.event.inputs.tag }}
draft: ${{ github.event.inputs.draft }}
prerelease: ${{ github.event.inputs.prerelease }}
linux:
runs-on: ubuntu-latest
needs: create_release
env:
SRC_DIR: ${{ github.workspace }}/src
OUTPUT_DIR: ${{ github.workspace }}/output
Expand All @@ -44,6 +65,7 @@ jobs:
- name: Setup
run : |
mkdir -p ${{ env.OUTPUT_DIR }}
cp ${{ env.SRC_DIR }}/cmd/config.yaml ${{ env.OUTPUT_DIR }}
- name: Build Docker image for linux/amd64
run: |
Expand All @@ -66,7 +88,7 @@ jobs:
- name: Create Zip File for linux/amd64
run: |
cd ${{ env.OUTPUT_DIR }}
zip -qq -r ${{ env.APP_NAME }}-linux-amd64.zip ${{ env.APP_NAME }}
zip -qq -r ${{ env.APP_NAME }}-linux-amd64.zip ${{ env.APP_NAME }} config.yaml
- name: Upload Zip for Darwin/amd64
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -95,31 +117,20 @@ jobs:
- name: Create Zip File for linux/arm64
run: |
cd ${{ env.OUTPUT_DIR }}
zip -qq -r ${{ env.APP_NAME }}-linux-arm64.zip ${{ env.APP_NAME }}
zip -qq -r ${{ env.APP_NAME }}-linux-arm64.zip ${{ env.APP_NAME }} config.yaml
- name: Upload Zip for Darwin/arm64
uses: actions/upload-artifact@v3
with:
name: ${{ env.APP_NAME }}-linux-arm64
path: ${{ env.OUTPUT_DIR }}/${{ env.APP_NAME }}-linux-arm64.zip

- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.event.inputs.tag }}
release_name: ${{ github.event.inputs.tag }}
draft: ${{ github.event.inputs.draft }}
prerelease: false

- name: Upload Release Asset for Linux/amd64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: ${{ env.OUTPUT_DIR }}/${{ env.APP_NAME }}-linux-amd64.zip
asset_name: ${{ env.APP_NAME }}-linux-amd64.zip
asset_content_type: application/zip
Expand All @@ -129,8 +140,83 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: ${{ env.OUTPUT_DIR }}/${{ env.APP_NAME }}-linux-arm64.zip
asset_name: ${{ env.APP_NAME }}-linux-arm64.zip
asset_content_type: application/zip


darwin:
runs-on: macos-latest
needs: create_release
env:
SRC_DIR: ${{ github.workspace }}/src
OUTPUT_DIR: ${{ github.workspace }}/output
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
path: ${{ env.SRC_DIR }}

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'

- name: Setup
run : |
mkdir -p ${{ env.OUTPUT_DIR }}/amd64
mkdir -p ${{ env.OUTPUT_DIR }}/arm64
cp ${{ env.SRC_DIR }}/cmd/config.yaml ${{ env.OUTPUT_DIR }}/amd64/
cp ${{ env.SRC_DIR }}/cmd/config.yaml ${{ env.OUTPUT_DIR }}/arm64/
- name: Build ${{ env.APP_NAME }} for arm64
run: |
cd ${{ env.SRC_DIR }}
CGO_ENABLED=1 CGO_CFLAGS="-mmacosx-version-min=12.0" CGO_LDFLAGS="-mmacosx-version-min=12.0" GOOS=darwin GOARCH=arm64 SDKROOT=$(xcrun --sdk macosx --show-sdk-path) go build -x -v -tags bn256 -ldflags "-X main.VersionStr=v${{ env.VERSION }}" -o ${{ env.OUTPUT_DIR }}/arm64/${{ env.APP_NAME }} .
- name: Build ${{ env.APP_NAME }} for amd64
run: |
cd ${{ env.SRC_DIR }}
CGO_ENABLED=1 CGO_CFLAGS="-mmacosx-version-min=12.0" CGO_LDFLAGS="-mmacosx-version-min=12.0" GOOS=darwin GOARCH=amd64 SDKROOT=$(xcrun --sdk macosx --show-sdk-path) go build -x -v -tags bn256 -ldflags "-X main.VersionStr=v${{ env.VERSION }}" -o ${{ env.OUTPUT_DIR }}/amd64/${{ env.APP_NAME }} .
- name: Create Zip File for darwin/amd64
run: |
cd ${{ env.OUTPUT_DIR }}/amd64
zip -qq -r ${{ env.APP_NAME }}-darwin-amd64.zip ${{ env.APP_NAME }} config.yaml
- name: Upload Zip for Darwin/amd64
uses: actions/upload-artifact@v3
with:
name: ${{ env.APP_NAME }}-darwin-amd64
path: ${{ env.OUTPUT_DIR }}/amd64/${{ env.APP_NAME }}-darwin-amd64.zip

- name: Create Zip File for darwin/arm64
run: |
cd ${{ env.OUTPUT_DIR }}/arm64
zip -qq -r ${{ env.APP_NAME }}-darwin-arm64.zip ${{ env.APP_NAME }} config.yaml
- name: Upload Zip for Darwin/arm64
uses: actions/upload-artifact@v3
with:
name: ${{ env.APP_NAME }}-darwin-arm64
path: ${{ env.OUTPUT_DIR }}/arm64/${{ env.APP_NAME }}-darwin-arm64.zip

- name: Upload Release Asset for Darwin/amd64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: ${{ env.OUTPUT_DIR }}/amd64/${{ env.APP_NAME }}-darwin-amd64.zip
asset_name: ${{ env.APP_NAME }}-darwin-amd64.zip
asset_content_type: application/zip

- name: Upload Release Asset for Darwin/arm64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: ${{ env.OUTPUT_DIR }}/arm64/${{ env.APP_NAME }}-darwin-arm64.zip
asset_name: ${{ env.APP_NAME }}-darwin-arm64.zip
asset_content_type: application/zip
5 changes: 3 additions & 2 deletions network/config.yaml → cmd/config.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
---
block_worker: http://demo.zus.network/dns
block_worker: https://mainnet.zus.network/dns
signature_scheme: bls0chain
min_submit: 50
min_confirmation: 50
confirmation_chain_length: 3

max_txn_query: 5
query_sleep_time: 5
# # OPTIONAL - Uncomment to use/ Add more if you want
# preferred_blobbers:
# - http://one.devnet-0chain.net:31051
Expand Down
13 changes: 12 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
_ "embed"
"encoding/json"
"fmt"
"io/ioutil"
Expand Down Expand Up @@ -39,6 +40,9 @@ var (
cfgConfig *viper.Viper
cfgNetwork *viper.Viper
cfgWallet string

//go:embed config.yaml
configStr string
)

var rootCmd = &cobra.Command{
Expand Down Expand Up @@ -134,7 +138,14 @@ func loadConfigs() {
}

if err := cfgConfig.ReadInConfig(); err != nil {
ExitWithError("Can't read config:", err, cDir, configDir, cfgFile)
fmt.Println("Can't read config:", err, cDir, configDir, cfgFile)
fmt.Println("using default config:")
fmt.Printf("config: %v", configStr)
cfgConfig.SetConfigType("yaml")
err := cfgConfig.ReadConfig(strings.NewReader(configStr))
if err != nil {
ExitWithError("error reading default config:", err)
}
}

minSubmit = cfgConfig.GetInt("min_submit")
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/0chain/zwalletcli
go 1.21

require (
github.com/0chain/gosdk v1.16.5
github.com/0chain/gosdk v1.17.0-RC1
github.com/ethereum/go-ethereum v1.13.2
github.com/icza/bitio v1.1.0
github.com/olekukonko/tablewriter v0.0.5
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ github.com/0chain/common v0.0.7-0.20231108122201-3e2bad6b9d20 h1:c46aB5l0xbD7nc/
github.com/0chain/common v0.0.7-0.20231108122201-3e2bad6b9d20/go.mod h1:gbmUdgY4Gu2jKmnYnHr8533gcokviV3MDMs8wNk74sk=
github.com/0chain/errors v1.0.3 h1:QQZPFxTfnMcRdt32DXbzRQIfGWmBsKoEdszKQDb0rRM=
github.com/0chain/errors v1.0.3/go.mod h1:xymD6nVgrbgttWwkpSCfLLEJbFO6iHGQwk/yeSuYkIc=
github.com/0chain/gosdk v1.16.5 h1:EGtndZLj5+m8OAIzfAfjqu4llEolWuxgKQxXS0tfe7Q=
github.com/0chain/gosdk v1.16.5/go.mod h1:y7Ucdmv40VltqulZnncMNjNQ4piX5Dta5ujNmPmXnxg=
github.com/0chain/gosdk v1.17.0-RC1 h1:D3OwgmfkqW/2FR+JtjmDx+KhlCINXL5/ZWNMbbPh4lc=
github.com/0chain/gosdk v1.17.0-RC1/go.mod h1:y7Ucdmv40VltqulZnncMNjNQ4piX5Dta5ujNmPmXnxg=
github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
Expand Down
2 changes: 1 addition & 1 deletion scripts/debian/Dockerfile.build
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ COPY go.mod go.sum .
RUN go mod download
COPY . .
RUN go env
RUN CGO_ENABLED=1 go build -x -v -tags bn256 -ldflags "-X main.VersionStr=${VERSION} -linkmode 'external' -extldflags '-static'" -o /zwallet .
RUN CGO_ENABLED=1 go build -x -v -tags bn256 -ldflags "-X main.VersionStr=v${VERSION} -linkmode 'external' -extldflags '-static'" -o /zwallet .

0 comments on commit 420c49f

Please sign in to comment.