crazy-max / ghaction-xgo Goto Github PK
View Code? Open in Web Editor NEWGitHub Action for xgo, a Golang CGO cross compiler
Home Page: https://github.com/marketplace/actions/golang-cgo-cross-compiler
License: MIT License
GitHub Action for xgo, a Golang CGO cross compiler
Home Page: https://github.com/marketplace/actions/golang-cgo-cross-compiler
License: MIT License
Tell me what should happen
There should be a parameter where you can issue ago generate
or some other pre-build step
Tell me what happens instead
# paste your YAML workflow file here and remove sensitive data
Download the log file of your build and attach it to this issue.
Would it be possible to provide an option change for CGO_ENABLED, which are all 1 by default now.
Rainbows and unicorns unite!
logs report...
no Go files in /source
Repository URL: https://github.com/jkassis/gitall
yml:
name: xgo
on:
push:
tags:
- '*'
jobs:
xgo:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
-
name: Build
uses: crazy-max/ghaction-xgo@v2
with:
xgo_version: latest
go_version: 1.18
dest: build
prefix: myapp
targets: windows/amd64,linux/amd64,linux/arm64,darwin/arm64,darwin/amd64
v: true
x: false
race: false
ldflags: -s -w
buildmode: default
trimpath: true
63efd93484b4: Pull complete
[101](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:103)
Digest: sha256:84250633983da3f233dc8e899a5afb2b0586106f0972967c44cd87b0c083ec65
[102](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:104)
Status: Downloaded newer image for ghcr.io/crazy-max/xgo:1.18
[103](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:105)
ghcr.io/crazy-max/xgo:1.18
[104](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:106)
DBG: config: &{Repository:. Package: Prefix:myapp Remote: Branch: Dependencies: Arguments: Targets:[windows/amd64 linux/amd64 linux/arm64 darwin/arm64 darwin/amd64]}
[105](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:107)
DBG: flags: &{Verbose:true Steps:false Race:false Tags: LdFlags:-s -w Mode:default VCS: TrimPath:true}
[106](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:108)
INFO: Cross compiling . package...
[107](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:109)
INFO: Docker run --rm -v /home/runner/work/gitall/gitall/build:/build -v /tmp/xgo-cache:/deps-cache:ro -e REPO_REMOTE= -e REPO_BRANCH= -e PACK= -e DEPS= -e ARGS= -e OUT=myapp -e FLAG_V=true -e FLAG_X=false -e FLAG_RACE=false -e FLAG_TAGS= -e FLAG_LDFLAGS=-s -w -e FLAG_BUILDMODE=default -e FLAG_BUILDVCS= -e FLAG_TRIMPATH=true -e TARGETS=windows/amd64 linux/amd64 linux/arm64 darwin/arm64 darwin/amd64 -e GO111MODULE=on -v /home/runner/go:/go -v /home/runner/work/gitall/gitall:/source ghcr.io/crazy-max/xgo:1.18 .
[108](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:110)
Building /source/go.mod...
[109](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:111)
Compiling for windows/amd64...
[110](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:112)
+ CC=x86_64-w64-mingw32-gcc
[111](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:113)
+ CXX=x86_64-w64-mingw32-g++
[112](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:114)
+ GOOS=windows
[113](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:115)
+ GOARCH=amd64
[114](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:116)
+ CGO_ENABLED=1
[115](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:117)
+ CGO_CFLAGS=-D_WIN32_WINNT=0x0400
[116](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:118)
+ CGO_CXXFLAGS=-D_WIN32_WINNT=0x0400
[117](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:119)
+ go build -v -trimpath '--ldflags=-v -s -w' -o /build/myapp-windows-amd64.exe ./
[118](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:120)
no Go files in /source
[119](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:121)
Compiling for linux/amd64...
[120](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:122)
+ CC=x86_64-linux-gnu-gcc
[121](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:123)
+ CXX=x86_64-linux-gnu-g++
[122](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:124)
+ GOOS=linux
[123](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:125)
+ GOARCH=amd64
[124](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:126)
+ CGO_ENABLED=1
[125](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:127)
+ go build -v -trimpath '--ldflags=-v -s -w' -o /build/myapp-linux-amd64 ./
[126](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:128)
no Go files in /source
[127](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:129)
Compiling for linux/arm64...
[128](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:130)
+ CC=aarch64-linux-gnu-gcc
[129](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:131)
+ CXX=aarch64-linux-gnu-g++
[130](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:132)
+ GOOS=linux
[131](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:133)
+ GOARCH=arm64
[132](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:134)
+ CGO_ENABLED=1
[133](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:135)
+ go build -v -trimpath '--ldflags=-v -s -w' -o /build/myapp-linux-arm64 ./
[134](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:136)
no Go files in /source
[135](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:137)
Compiling for darwin/arm64...
[136](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:138)
+ CC=o64-clang
[137](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:139)
+ CXX=o64-clang++
[138](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:140)
+ GOOS=darwin
[139](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:141)
+ GOARCH=arm64
[140](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:142)
+ CGO_ENABLED=1
[141](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:143)
+ go build -v -trimpath -trimpath '--ldflags= -v -s -w' -o /build/myapp-darwin-arm64 ./
[142](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:144)
no Go files in /source
[143](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:145)
Compiling for darwin/amd64...
[144](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:146)
+ CC=o64-clang
[145](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:147)
+ CXX=o64-clang++
[146](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:148)
+ GOOS=darwin
[147](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:149)
+ GOARCH=amd64
[148](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:150)
+ CGO_ENABLED=1
[149](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:151)
+ go build -v -trimpath '--ldflags= -v -s -w' -o /build/myapp-darwin-amd64 ./
[150](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:152)
no Go files in /source
[151](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:153)
Cleaning up build environment...
[152](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:154)
INFO: Completed!
[153](https://github.com/jkassis/gitall/actions/runs/3614070991/jobs/6090256273#step:3:155)
Compiling for windows-4.0/amd64...
+ CC=x86_64-w64-mingw32-gcc
+ CXX=x86_64-w64-mingw32-g++
+ GOOS=windows
+ GOARCH=amd64
+ CGO_ENABLED=1
+ CGO_CFLAGS=-D_WIN32_WINNT=0x0400
+ CGO_CXXFLAGS=-D_WIN32_WINNT=0x0400
+ go build -x '--ldflags= -s -w -X main.buildTime=2022-04-28/10:12:22 -X main.versionData=0.0.1 -X main.commitId=78ad7ae1de0e695b84a0c6fc587fbe41ec64c86c -X main.author=XRSec -buildvcs=false' -o /build/htmltomd-windows-4.0-amd64.exe ./
WORK=/tmp/go-build2901126843
cd /source
git status --porcelain
error obtaining VCS status: exit status 128
Use -buildvcs=false to disable VCS stamping.
Cleaning up build environment...
INFO: Completed!
๐จ Fixing perms...
It seems that this error has occurred before #259 and was fixed in this PR #258, but in version 0.26.0, the binary file for linux_x86_64
was forgotten to be released.
GitHub actions error info
Run crazy-max/ghaction-xgo@v1
with:
xgo_version: latest
dest: build
prefix: hack-browser-data
pkg: cmd/hack-browser-data
targets: windows/amd64,windows/386,linux/386,linux/amd64,linux/arm,linux/arm64,darwin/amd64
v: true
x: false
race: false
ldflags: -s -w
buildmode: default
docker-repo: ghcr.io/crazy-max/xgo
Download and install xgo
Downloading https://github.com/crazy-max/xgo/releases/download/v0.26.0/xgo_0.26.0_linux_x86_64.tar.gz
Error: Unexpected HTTP response: 404
My action file
name: Release
on:
push:
tags:
- "*"
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v1
- name: Use Golang
uses: actions/setup-go@v1
with:
go-version: "1.20"
- name: Build with xgo
uses: crazy-max/ghaction-xgo@v1
with:
xgo_version: latest
go_version: ${{ matrix.go_version }}
dest: build
prefix: hack-browser-data
pkg: cmd/hack-browser-data
targets: windows/amd64,windows/386,linux/386,linux/amd64,linux/arm,linux/arm64,darwin/amd64
# targets: windows/amd64,windows/386,darwin/amd64,linux/arm
v: true
x: false
race: false
ldflags: -s -w
buildmode: default
...
Hi, where do the files actually go? I have set up my github action and on push it builds successfully and the target folder is build
(default) but I don't see any binary file somewhere on my repository? Should I run this setup locally on my PC?
I am using M1 Mac Pro locally.
Thank you for this!
RT.
I tried to build with your Action and result is below:
https://github.com/346lab/v2ray-core/actions/runs/41329809
Notice that when I used -x
param and there was no more verbosed outputs.
Build/
is also empty.
Also it's reported that original xgo
is working for vanilla git repo (where I forked from) .
I'm also requesting to add support for original -tag
param passing since one submodule needs that param.
- name: Generate build files
uses: crazy-max/ghaction-xgo@v2
with:
xgo_version: latest
go_version: 1.18
dest: build
pkg: "cmd/encarno"
prefix: ${{ github.event.repository.name }}
targets: linux/amd64, linux/arm64, darwin/amd64, darwin/arm64, windows/amd64
v: true
x: false
race: false
ldflags: -s -w
buildmode: default
buildvcs: false
tags: ""
- name: Checking artifacts
run: ls -la build
- name: Release artifacts
uses: ncipollo/[email protected]
with:
artifacts: >
build/${{ github.event.repository.name }}-darwin-10.16-amd64,
build/${{ github.event.repository.name }}-darwin-10.16-arm64,
build/${{ github.event.repository.name }}-linux-amd64,
build/${{ github.event.repository.name }}-linux-arm64,
build/${{ github.event.repository.name }}-windows-4.0-amd64.exe
allowUpdates: 'true'
token: ${{ secrets.GITHUB_TOKEN }}
We should see templated filename as
project_name-platform-architecture[.ext]
%NAME%-darwin-amd64
%NAME%-darwin-arm64
%NAME%-linux-amd64
%NAME%-linux-arm64
%NAME%-windows-amd64.exe
We have filename as
project_name-platform-[???]-architecture[.ext]
%NAME%-darwin-10.16-amd64
%NAME%-darwin-10.16-arm64
%NAME%-linux-amd64
%NAME%-linux-arm64
%NAME%-windows-4.0-amd64.exe
It can break links in documentation or in Dockerfile. Is it possible to switch them off?
# workflow name
name: Generate release-artifacts
# on events
on:
push:
tags:
- "*.*"
# workflow tasks
jobs:
generate:
name: Generate cross-platform builds
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/[email protected]
- name: Generate build files
uses: crazy-max/ghaction-xgo@v2
with:
xgo_version: latest
go_version: 1.18
dest: build
pkg: "cmd/encarno"
prefix: ${{ github.event.repository.name }}
targets: linux/amd64, linux/arm64, darwin/amd64, darwin/arm64, windows/amd64
v: true
x: false
race: false
ldflags: -s -w
buildmode: default
buildvcs: ""
tags: ""
- name: Checking artifacts
run: ls -la build
- name: Release artifacts
uses: ncipollo/[email protected]
with:
artifacts: >
build/${{ github.event.repository.name }}-darwin-10.16-amd64,
build/${{ github.event.repository.name }}-darwin-10.16-arm64,
build/${{ github.event.repository.name }}-linux-amd64,
build/${{ github.event.repository.name }}-linux-arm64,
build/${{ github.event.repository.name }}-windows-4.0-amd64.exe
allowUpdates: 'true'
token: ${{ secrets.GITHUB_TOKEN }}
Do you plan to merge upx in the near future?
Question... How would I go about adding tags for the build?
For example: go build --tags "netgo osusergo"
The docker image that we are pulling in CI is big, it's 5.6GB as of this writing. I'm wondering what the reason is behind this and if it can be improved by any chance.
Passing go_version: 1.20
is treated as 1.2
, which causes it to fail to download the container image.
It should treat go 1.20 as 1.20 and not 1.2
It thinks 1.20 is 1.2 and then fails to download the image
Use the above config and watch it fail.
https://github.com/databacker/mysql-backup
https://github.com/databacker/mysql-backup/actions/runs/7485946836/job/20375327323
- name: Build with xgo
uses: crazy-max/ghaction-xgo@v3
with:
xgo_version: latest
go_version: 1.20
dest: dist
targets: windows/386,windows/amd64,windows/arm64,linux/386,linux/amd64,linux/arm64,darwin/amd64,darwin/arm64
v: true
x: true
ldflags: -s -w
Run crazy-max/ghaction-xgo@v3
with:
xgo_version: latest
go_version: 1.2 <==== THIS BECAME 1.2 ๐คทโโ๏ธ
dest: dist
targets: windows/386,windows/amd64,windows/arm64,linux/386,linux/amd64,linux/arm64,darwin/amd64,darwin/arm64
v: true
x: true
ldflags: -s -w
race: false
buildmode: default
trimpath: false
...
INFO: Checking for required docker image ghcr.io/crazy-max/xgo:1.2...
not found!
INFO: Pulling ghcr.io/crazy-max/xgo:1.2 from docker registry...
Error response from daemon: manifest unknown
ERROR: Failed to pull docker image from the registry: exit status 1.
No response
I've been able to successfully use this with other build pipelines, but I'm running into an issue getting it to compile a binary for a project that is using a private submodule. I have GOPRIVATE set and I have a step that does this
- name: Configure git for private modules run: git config --global url."https://${{ secrets.RELEASE_MANAGER }}:${{ secrets.RELEASE_MANAGER_TOKEN }}@github.com".insteadOf "https://github.com"
and I know that works because if I run a go test things compile and pass. When I try to run a build immediately after the test things fail on it trying to pull down the dependency
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.