Giter Site home page Giter Site logo

crazy-max / ghaction-xgo Goto Github PK

View Code? Open in Web Editor NEW
64.0 4.0 13.0 4.16 MB

GitHub Action for xgo, a Golang CGO cross compiler

Home Page: https://github.com/marketplace/actions/golang-cgo-cross-compiler

License: MIT License

Go 7.72% TypeScript 65.34% HCL 8.10% Dockerfile 18.84%
github-actions golang cgo cross-compiler actions xgo

ghaction-xgo's People

Contributors

crazy-max avatar dependabot-preview[bot] avatar dependabot[bot] avatar github-actions[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ghaction-xgo's Issues

The docker image is very big

Description

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.

--tags

Question... How would I go about adding tags for the build?

For example: go build --tags "netgo osusergo"

How to run "go generate" before building?

Behaviour

Steps to reproduce this issue

Expected behaviour

Tell me what should happen
There should be a parameter where you can issue a go generate or some other pre-build step

Actual behavior

Tell me what happens instead

Configuration

  • Repository URL (if public):
  • Build URL (if public):
# paste your YAML workflow file here and remove sensitive data

Logs

Download the log file of your build and attach it to this issue.

Where do the files go?

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!

no Go files in /source

Behaviour

Steps to reproduce this issue

  1. copy the example config to .github/workflows/xgo.yml
  2. push a build

Expected behaviour

Rainbows and unicorns unite!

Actual behaviour

logs report...

no Go files in /source

Configuration

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

Logs

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)

go_version is misread

Support guidelines

I've found a bug and checked that ...

  • ... the documentation does not mention anything about my problem
  • ... there are no open or closed issues that are related to my problem

Description

Passing go_version: 1.20 is treated as 1.2, which causes it to fail to download the container image.

Expected behaviour

It should treat go 1.20 as 1.20 and not 1.2

Actual behaviour

It thinks 1.20 is 1.2 and then fails to download the image

Steps to reproduce

Use the above config and watch it fail.

Repository URL

https://github.com/databacker/mysql-backup

Workflow run URL

https://github.com/databacker/mysql-backup/actions/runs/7485946836/job/20375327323

YAML workflow

- 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

Workflow logs

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.

Additional info

No response

Extra version's substring in filename

Behaviour

Steps to reproduce this issue

  1. Create action with configuration
      - 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 }}
  1. Run action
  2. Check the output directory

Expected behavior

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

Actual behaviour

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?

Configuration

# 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 }}

error obtaining VCS status: exit status 128

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...

Error: Unexpected HTTP response: 404, miss linux_x86_64 release in 0.26.0

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 
...

Doesn't seem to work with private modules

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

About CGO_ENABLED

Description

Would it be possible to provide an option change for CGO_ENABLED, which are all 1 by default now.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.