-
Notifications
You must be signed in to change notification settings - Fork 2
67 lines (56 loc) · 1.87 KB
/
build-windows.yml
File metadata and controls
67 lines (56 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
name: GitHub Build and Package Windows
on:
push:
branches:
- master
release:
types:
- created
jobs:
build:
runs-on: ubuntu-latest
env:
ImageName: 'devopcorner/k8s-context'
AppName: 'k8s-context'
strategy:
matrix:
os: [windows-latest]
arch: [amd64]
steps:
- name: Checkout code at release tag
uses: actions/checkout@v2
with:
ref: ${{ github.ref }}
- name: Set up Go environment
uses: actions/setup-go@v2
with:
go-version: 1.19
- name: Install dependencies
working-directory: src
run: |
go mod tidy
- name: Build binary
working-directory: src
run: |
GOOS=${{ matrix.os }}
GOARCH=${{ matrix.arch }}
go build -o ${{ env.AppName }}-${{ matrix.os }}-${{ matrix.arch }} main.go
- name: Create .exe package
working-directory: src
if: matrix.os == 'windows-latest'
run: |
GOOS=windows GOARCH=amd64 go build -ldflags="-H windowsgui -linkmode internal" -o ${{ env.AppName }}-${{ matrix.os }}-${{ matrix.arch }}.exe main.go
- name: Create .zip package for Windows
working-directory: src
if: matrix.os == 'windows-latest'
run: |
mkdir -p ${{ env.AppName }}-${{ matrix.os }}-${{ matrix.arch }}
cp -r ${{ env.AppName }}-${{ matrix.os }}-${{ matrix.arch }}.exe ${{ env.AppName }}-${{ matrix.os }}-${{ matrix.arch }}/${env.AppName}.exe
zip -r ${{ env.AppName }}-${{ matrix.os }}-${{ matrix.arch }}.zip ${{ env.AppName }}-${{ matrix.os }}-${{ matrix.arch }}/
- name: Upload packages
uses: actions/upload-artifact@v2
with:
name: ${{ env.AppName }}
path: |
${{ env.AppName }}-windows-amd64.exe
${{ env.AppName }}-windows-amd64.zip