Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use msys2 to build windows binaries #524

Merged
merged 25 commits into from
Oct 22, 2023
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 43 additions & 81 deletions .github/workflows/build-zbox.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ on:
push:
branches:
- master
- dev
- sprint*
- staging
tags:
- 'v*.*.*'
pull_request:
workflow_dispatch:

jobs:
build-linux:
Expand All @@ -24,37 +26,11 @@ 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
go-version: '1.20'

- 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:
Expand All @@ -65,51 +41,58 @@ 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: Checkout
uses: actions/checkout@v2
- 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 GITHUB_ENV
- name: Set environment variables
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
}
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: 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
# 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 @@ -123,37 +106,16 @@ jobs:
- 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

- name: cleanup workspace
run: |
rm -rf ./*
47 changes: 0 additions & 47 deletions .github/workflows/gosdk.yml

This file was deleted.

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,30 +96,58 @@ 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: Checkout
uses: actions/checkout@v2
- 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: Install
run: make install

- 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 +173,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
Loading
Loading