Skip to content

Commit

Permalink
ci: build linux x64 lib file
Browse files Browse the repository at this point in the history
  • Loading branch information
rsdmike committed Jun 20, 2024
1 parent ba502b6 commit 3c8193f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 10 deletions.
17 changes: 7 additions & 10 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"branches": [
"main",
"next"
],
"branches": ["main", "next"],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
Expand All @@ -12,19 +9,19 @@
{
"assets": [
{
"path": "rpc_linux_x64",
"path": "rpc_linux_x64.tar.gz",
"label": "Linux x64 RPC Executable"
},
{
"path": "rpc_linux_x86",
"path": "rpc_linux_x86.tar.gz",
"label": "Linux x86 RPC Executable"
},
{
"path": "rpc_windows_x64.exe",
"path": "rpc_windows_x64.zip",
"label": "Windows x64 RPC Executable"
},
{
"path": "rpc_windows_x86.exe",
"path": "rpc_windows_x86.zip",
"label": "Windows x86 RPC Executable"
}
]
Expand All @@ -34,11 +31,11 @@
[
"@semantic-release/exec",
{
"prepareCmd": "docker build -t vprodemo.azurecr.io/rpc-go:v${nextRelease.version} . && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags \"-s -w -X 'rpc/pkg/utils.ProjectVersion=${nextRelease.version}'\" -trimpath -o rpc_linux_x64 ./cmd/main.go && CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -ldflags \"-s -w -X 'rpc/pkg/utils.ProjectVersion=${nextRelease.version}'\" -trimpath -o rpc_linux_x86 ./cmd/main.go && CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags \"-s -w -X 'rpc/pkg/utils.ProjectVersion=${nextRelease.version}'\" -trimpath -o rpc_windows_x64.exe ./cmd/main.go && CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -ldflags \"-s -w -X 'rpc/pkg/utils.ProjectVersion=${nextRelease.version}'\" -trimpath -o rpc_windows_x86.exe ./cmd/main.go",
"prepareCmd": "./build.sh ${nextRelease.version}",
"publishCmd": "docker push vprodemo.azurecr.io/rpc-go:v${nextRelease.version}",
"verifyReleaseCmd": "echo v${nextRelease.version} > .nextVersion"
}
],
"@semantic-release/git"
]
}
}
29 changes: 29 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Get version from the first argument
version=$1

docker build -t vprodemo.azurecr.io/rpc-go:v$version .

# Build for Linux
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -X 'rpc/pkg/utils.ProjectVersion=$version'" -trimpath -o rpc_linux_x64 ./cmd/main.go
CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -ldflags "-s -w -X 'rpc/pkg/utils.ProjectVersion=$version'" -trimpath -o rpc_linux_x86 ./cmd/main.go

# Build for Windows
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "-s -w -X 'rpc/pkg/utils.ProjectVersion=$version'" -trimpath -o rpc_windows_x64.exe ./cmd/main.go
CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -ldflags "-s -w -X 'rpc/pkg/utils.ProjectVersion=$version'" -trimpath -o rpc_windows_x86.exe ./cmd/main.go

# Build library for Linux
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w" -trimpath -buildmode=c-shared -o rpc.so.$version ./cmd

# Mark the Unix system outputs as executable
chmod +x rpc_linux_x64
chmod +x rpc_linux_x86

# Add them to tar files respectively
tar cvfpz rpc_linux_x64.tar.gz rpc_linux_x64
tar cvfpz rpc_linux_x86.tar.gz rpc_linux_x86
tar cvfpz rpc_linux_x86.tar.gz rpc_linux_x86
tar cvfpz rpc_so_x64.tar.gz rpc.so.$version

# Add Windows build to a zip file
zip rpc_windows_x64.zip rpc_windows_x64.exe
zip rpc_windows_x86.zip rpc_windows_x86.exe

0 comments on commit 3c8193f

Please sign in to comment.