File tree Expand file tree Collapse file tree 4 files changed +90
-0
lines changed
Expand file tree Collapse file tree 4 files changed +90
-0
lines changed Original file line number Diff line number Diff line change 22
33This directory contains various examples of Go projects with CGO and cross-compilation scripts that use this Docker image.
44
5+ * [ ci] ( ci ) - CI/CD examples for Gitlab CI and GitHub Actions.
56* [ hello] ( hello ) - Simple app that uses CGO with WinAPI.
67* [ sqlite-app] ( sqlite-app ) - Example that uses CGO for SQLite driver.
Original file line number Diff line number Diff line change 1+ # GitLab CI example for cross-compiling for Windows
2+ stages :
3+ - build
4+
5+ build_windows_386 :
6+ stage : build
7+ image : x1unix/go-mingw:1.22 # Tag is desired Go version.
8+ variables :
9+ GOARCH : 386
10+ script :
11+ - go build -o myapp-386.exe .
12+ artifacts :
13+ paths :
14+ - myapp-386.exe
15+ expire_in : 1 week
16+
17+ build_windows_amd64 :
18+ stage : build
19+ image : x1unix/go-mingw:1.22
20+ variables :
21+ GOARCH : amd64
22+ script :
23+ - go build -o myapp-amd64.exe .
24+ artifacts :
25+ paths :
26+ - myapp-amd64.exe
27+ expire_in : 1 week
28+
29+ build_windows_arm64 :
30+ stage : build
31+ image : x1unix/go-mingw:1.22
32+ variables :
33+ GOARCH : arm64
34+ script :
35+ - go build -o myapp-arm64.exe .
36+ artifacts :
37+ paths :
38+ - myapp-arm64.exe
39+ expire_in : 1 week
Original file line number Diff line number Diff line change 1+ # CI/CD examples
2+
3+ * [ .gitlab-ci.yml] (GitLab CI)
4+ * [ github-workflow-example.yml] (GitHub Actions workflow example)
Original file line number Diff line number Diff line change 1+ # This is GitHub actions workflow example.
2+ # Put this into `.github/workflows` directory to use.
3+ name : Go Build for Windows
4+
5+ # Rules to trigger job, customize for your needs.
6+ on :
7+ push :
8+ branches :
9+ - main
10+ pull_request :
11+ branches :
12+ - main
13+
14+ jobs :
15+ build :
16+ runs-on : ubuntu-latest
17+ strategy :
18+ matrix :
19+ goarch : ['386', 'amd64', 'arm64']
20+ env :
21+ GO_VERSION : ' 1.22' # Define the Go version here
22+
23+ container :
24+ image : x1unix/go-mingw:${{ env.GO_VERSION }}
25+
26+ steps :
27+ - name : Checkout code
28+ uses : actions/checkout@v3
29+
30+ - name : Set up Go
31+ uses : actions/setup-go@v3
32+ with :
33+ go-version : ${{ env.GO_VERSION }}
34+
35+ - name : Build for Windows
36+ run : |
37+ echo "Building for Windows ${{ matrix.goarch }}"
38+ go build -o myapp-${{ matrix.goarch }}.exe .
39+ env :
40+ GOARCH : ${{ matrix.goarch }}
41+
42+ - name : Upload Artifact
43+ uses : actions/upload-artifact@v3
44+ with :
45+ name : myapp-${{ matrix.goarch }}
46+ path : myapp-${{ matrix.goarch }}.exe
You can’t perform that action at this time.
0 commit comments