diff --git a/.github/workflows/distribute-zwalletcli.yml b/.github/workflows/distribute-zwalletcli-apt.yml similarity index 99% rename from .github/workflows/distribute-zwalletcli.yml rename to .github/workflows/distribute-zwalletcli-apt.yml index 1a8f619..efcd8eb 100644 --- a/.github/workflows/distribute-zwalletcli.yml +++ b/.github/workflows/distribute-zwalletcli-apt.yml @@ -1,4 +1,4 @@ -name: Build, Distribute and Test zwallet +name: Distribute zwallet using apt on: workflow_dispatch: diff --git a/.github/workflows/distribute-zwalletcli-choco.yml b/.github/workflows/distribute-zwalletcli-choco.yml new file mode 100644 index 0000000..23a8c2e --- /dev/null +++ b/.github/workflows/distribute-zwalletcli-choco.yml @@ -0,0 +1,170 @@ +name: Distribute zbox using choco + +on: + # Remove push trigger once tested + push: + branches: + - windows-build + + workflow_dispatch: + inputs: + version: + description: 'Version of zwallet to release' + required: true + default: '1.0.0' + +env: + APP_NAME: zwallet + PACKAGE_ID: zwallet + APP_VERSION: '1.17.0' # Update to ${{ github.event.inputs.version }} once tested + GO_VERSION: '1.21' + +jobs: + build: + runs-on: windows-latest + env: + SRC_DIR: ${{ github.workspace }}\src + OUTPUT_DIR: ${{ github.workspace }}\output + PACKAGE_DIR: ${{ github.workspace }}\package + + steps: + - name: Checkout Code + uses: actions/checkout@v3 + with: + path: ${{ env.SRC_DIR }} + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: ${{ env.GO_VERSION }} + + - name: Install MinGW for CGo + run: | + choco install mingw + + - name: Setup + run : | + New-Item -ItemType Directory -Force -Path "${{ env.OUTPUT_DIR }}\amd64" + New-Item -ItemType Directory -Force -Path "${{ env.PACKAGE_DIR }}" + Copy-Item -Force -Path "${{ env.SRC_DIR }}\cmd\config.yaml" -Destination "${{ env.OUTPUT_DIR }}\amd64\" + + - name: Build ${{ env.APP_NAME }} for amd64 + run: | + Set-Location -Path "${{ env.SRC_DIR }}" + $env:CGO_ENABLED="1" + $env:CC="x86_64-w64-mingw32-gcc" + $env:CXX="x86_64-w64-mingw32-g++" + $env:GOOS="windows" + $env:GOARCH="amd64" + where x86_64-w64-mingw32-gcc + where x86_64-w64-mingw32-g++ + go build -x -v -tags bn256 -ldflags "-X main.VersionStr=v${{ env.APP_VERSION }}" -o ${{ env.OUTPUT_DIR }}\amd64\${{ env.APP_NAME }}.exe . + shell: pwsh + + - name: Generate SHA256 Checksum + id: checksum + shell: pwsh + run: | + $checksum = Get-FileHash "${{ env.OUTPUT_DIR }}\amd64\${{ env.APP_NAME }}.exe" -Algorithm SHA256 + Write-Output "::set-output name=checksum::$($checksum.Hash)" + + - name: Create VERIFICATION.txt + shell: pwsh + run: | + Set-Location -Path "${{ env.PACKAGE_DIR }}" + $location = Get-Location + Write-Host "Current Directory: $location" + $files = Get-ChildItem "${{ env.PACKAGE_DIR }}" + Write-Host "Files in Directory: $files" + $verificationContent = @" + The binaries in this package were sourced from the official https://github.com/0chain/zwalletcli repository. + Verification Steps: + 1. The SHA256 checksum of the binary was calculated. + 2. Users can verify the binary themselves by running the following command: + `Get-FileHash -Algorithm SHA256 ${{ env.APP_NAME }}.exe` + Expected checksum: + ${{ steps.checksum.outputs.checksum }} + "@ + $verificationContent | Out-File -FilePath "VERIFICATION.txt" -Encoding utf8 + Write-Host "Created VERIFICATION.txt file" + Get-ChildItem "${{ env.PACKAGE_DIR }}" + $fileContent = Get-Content -Path "VERIFICATION.txt" + Write-Host "File Content: $fileContent" + + - name: Create Chocolatey Install Script + run: | + Set-Location -Path "${{ env.PACKAGE_DIR }}" + $location = Get-Location + Write-Host "Current Directory: $location" + $files = Get-ChildItem "${{ env.PACKAGE_DIR }}" + Write-Host "Files in Directory: $files" + $content = @' + $installDir = "$(Get-ToolsLocation)\zwallet" + $envPath = [System.Environment]::GetEnvironmentVariable('Path', 'Machine') + if ($envPath -notlike "*$installDir*") { + Write-Host "Adding $installDir to PATH" + [System.Environment]::SetEnvironmentVariable('Path', "$envPath;$installDir", 'Machine') + } + '@ + $content | Out-File -FilePath "chocolateyInstall.ps1" -Encoding utf8 + Write-Host "Created chocolateyInstall.ps1 file" + Get-ChildItem "${{ env.PACKAGE_DIR }}" + $fileContent = Get-Content -Path "chocolateyInstall.ps1" + Write-Host "File Content: $fileContent" + + - name: Create .nuspec file + run: | + Set-Location -Path "${{ env.PACKAGE_DIR }}" + $location = Get-Location + Write-Host "Current Directory: $location" + $files = Get-ChildItem "${{ env.PACKAGE_DIR }}" + Write-Host "Files in Directory: $files" + $content = @" + + + + ${{ env.PACKAGE_ID }} + ${{ env.APP_VERSION }} + Saswata Basu + Saswata Basu + zwallet cloud storage cli windows golang + https://github.com/0chain/zwalletcli/blob/staging/LICENSE + https://github.com/0chain/zwalletcli + https://github.com/0chain/zwalletcli + https://github.com/0chain/zwalletcli/releases/latest + zwallet is a command line interface (CLI) to demonstrate the wallet functionalities of Züs. + zwallet is a command line interface (CLI) to demonstrate the wallet functionalities of Züs. + zwallet CLI + + + + + + + + + "@ + + $content | Out-File -FilePath "zwallet.nuspec" -Encoding utf8 + Write-Host "Created .nuspec file:" + Get-ChildItem "${{ env.PACKAGE_DIR }}" + $fileContent = Get-Content -Path "zwallet.nuspec" + Write-Host "File Content: $fileContent" + + - name: Pack Chocolatey Package + run: | + Set-Location -Path "${{ env.PACKAGE_DIR }}" + $location = Get-Location + Write-Host "Current Directory: $location" + $files = Get-ChildItem "${{ env.PACKAGE_DIR }}" + Write-Host "Files in Directory: $files" + choco pack ${{ env.PACKAGE_ID }}.nuspec + + - name: Push Chocolatey Package + run: | + Set-Location -Path "${{ env.PACKAGE_DIR }}" + $location = Get-Location + Write-Host "Current Directory: $location" + $files = Get-ChildItem "${{ env.PACKAGE_DIR }}" + Write-Host "Files in Directory: $files" + choco push ${{ env.PACKAGE_ID }}.${{ env.APP_VERSION }}.nupkg --source https://push.chocolatey.org/ -k ${{ secrets.CHOCOLATEY_API_KEY }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bb2e4fa..f64235e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -90,7 +90,7 @@ jobs: cd ${{ env.OUTPUT_DIR }} zip -qq -r ${{ env.APP_NAME }}-linux-amd64.zip ${{ env.APP_NAME }} config.yaml - - name: Upload Zip for Darwin/amd64 + - name: Upload Zip for linux/amd64 uses: actions/upload-artifact@v3 with: name: ${{ env.APP_NAME }}-linux-amd64 @@ -119,7 +119,7 @@ jobs: cd ${{ env.OUTPUT_DIR }} zip -qq -r ${{ env.APP_NAME }}-linux-arm64.zip ${{ env.APP_NAME }} config.yaml - - name: Upload Zip for Darwin/arm64 + - name: Upload Zip for linux/arm64 uses: actions/upload-artifact@v3 with: name: ${{ env.APP_NAME }}-linux-arm64 @@ -160,7 +160,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v4 with: - go-version: '1.21' + go-version: ${{ env.GO_VERSION }} - name: Setup run : | @@ -219,4 +219,64 @@ jobs: 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 + + windows: + runs-on: windows-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: ${{ env.GO_VERSION }} + + - name: Install MinGW for CGo + run: | + choco install mingw + + - name: Setup + run : | + New-Item -ItemType Directory -Force -Path "${{ env.OUTPUT_DIR }}\amd64" + Copy-Item -Force -Path "${{ env.SRC_DIR }}\cmd\config.yaml" -Destination "${{ env.OUTPUT_DIR }}\amd64\" + + - name: Build ${{ env.APP_NAME }} for amd64 + run: | + Set-Location -Path "${{ env.SRC_DIR }}" + $env:CGO_ENABLED="1" + $env:CC="x86_64-w64-mingw32-gcc" + $env:CXX="x86_64-w64-mingw32-g++" + $env:GOOS="windows" + $env:GOARCH="amd64" + where x86_64-w64-mingw32-gcc + where x86_64-w64-mingw32-g++ + go build -x -v -tags bn256 -ldflags "-X main.VersionStr=v${{ env.VERSION }}" -o ${{ env.OUTPUT_DIR }}\amd64\${{ env.APP_NAME }}.exe . + shell: pwsh + + - name: Create Zip File for windows/amd64 + run: | + Set-Location -Path "${{ env.OUTPUT_DIR }}\amd64" + Compress-Archive -Path @("${{ env.APP_NAME }}.exe", "config.yaml") -DestinationPath ${{ env.APP_NAME }}-windows-amd64.zip + + - name: Upload Zip for windows/amd64 + uses: actions/upload-artifact@v3 + with: + name: ${{ env.APP_NAME }}-windows-amd64 + path: ${{ env.OUTPUT_DIR }}\amd64\${{ env.APP_NAME }}-windows-amd64.zip + + - name: Upload Release Asset for windows/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 }}-windows-amd64.zip + asset_name: ${{ env.APP_NAME }}-windows-amd64.zip asset_content_type: application/zip \ No newline at end of file