From f7a10e7b47e64d990d58eb5e0bbf4cccf36ec90e Mon Sep 17 00:00:00 2001 From: Arun Ramanathan Date: Sun, 1 Sep 2024 18:11:55 +0530 Subject: [PATCH] initial distribute workflow through choco --- ...zboxcli.yml => distribute-zboxcli-apt.yml} | 2 +- .../workflows/distribute-zboxcli-choco.yml | 90 +++++++++++++++++++ .github/workflows/release.yml | 4 +- 3 files changed, 93 insertions(+), 3 deletions(-) rename .github/workflows/{distribute-zboxcli.yml => distribute-zboxcli-apt.yml} (99%) create mode 100644 .github/workflows/distribute-zboxcli-choco.yml diff --git a/.github/workflows/distribute-zboxcli.yml b/.github/workflows/distribute-zboxcli-apt.yml similarity index 99% rename from .github/workflows/distribute-zboxcli.yml rename to .github/workflows/distribute-zboxcli-apt.yml index b930bdf5..eb5a170b 100644 --- a/.github/workflows/distribute-zboxcli.yml +++ b/.github/workflows/distribute-zboxcli-apt.yml @@ -1,4 +1,4 @@ -name: Build, Distribute and Test zbox +name: Distribute zbox using apt on: workflow_dispatch: diff --git a/.github/workflows/distribute-zboxcli-choco.yml b/.github/workflows/distribute-zboxcli-choco.yml new file mode 100644 index 00000000..0a748ef1 --- /dev/null +++ b/.github/workflows/distribute-zboxcli-choco.yml @@ -0,0 +1,90 @@ +name: Distribute zbox using choco + +on: + # Remove push trigger once tested + push: + branches: + - windows-build + + workflow_dispatch: + inputs: + version: + description: 'Version of zbox to release' + required: true + default: '1.0.0' + +env: + APP_NAME: zbox + PACKAGE_ID: zbox + 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: Create .nuspec file + run: | + Set-Location "${{ env.PACKAGE_DIR }}" + $content = @" + + + + ${{ env.PACKAGE_ID }} + ${{ env.APP_VERSION }} + https://github.com/0chain/zboxcli/blob/staging/LICENSE + https://github.com/0chain/zboxcli + zbox is a command line interface (CLI) tool to understand the capabilities of Züs dStorage and prototype your app. + + + + + + "@ + Set-Content -Path "${{ env.PACKAGE_ID }}.nuspec" -Value $content + + - name: Pack Chocolatey Package + run: | + choco pack ${{ env.PACKAGE_ID }}.nuspec + + - name: Push Chocolatey Package + run: | + 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 ccf16cf4..2a3a3c37 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -161,7 +161,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v4 with: - go-version: '1.21' + go-version: ${{ env.GO_VERSION }} - name: Setup run : | @@ -237,7 +237,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v4 with: - go-version: '1.21' + go-version: ${{ env.GO_VERSION }} - name: Install MinGW for CGo run: |