-
Notifications
You must be signed in to change notification settings - Fork 105
128 lines (111 loc) · 3.91 KB
/
release.yml
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
name: DDSHOP-release
on:
push:
tags:
- v*
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
go_version:
- 1.17
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go_version }}
# Cache go build cache, used to speedup go test
- name: Setup Golang caches
uses: actions/cache@v3
with:
path: |
/go/pkg/.cache/go-build
/go/pkg/mod
key: ${{ runner.os }}-golang-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-golang-
- name: Setup Golang with cache
uses: magnetikonline/action-golang-cache@v2
with:
go-version: ${{ matrix.go_version }}
- name: Mod download
run: go mod download
- run: |
mkdir -p build
- name: Build with xgo
uses: TianTianBigWang/ghaction-xgo@master
with:
xgo_version: v0.1
go_version: ${{ matrix.go_version }}
pkg: cmd/ddshop
dest: build
prefix: ddshop
targets: windows/amd64,linux/arm64,linux/amd64,darwin/arm64,darwin/amd64
v: true
x: false
race: false
ldflags: -s -w
buildmode: default
- name: Move
run: |
ls ./build
mkdir -p release
mv $GITHUB_WORKSPACE/build/ddshop-darwin-10.16-amd64 release/ddshop_darwin_amd64 && chmod +x release/ddshop_darwin_amd64
mv $GITHUB_WORKSPACE/build/ddshop-darwin-10.16-arm64 release/ddshop_darwin_arm64 && chmod +x release/ddshop_darwin_arm64
mv $GITHUB_WORKSPACE/build/ddshop-linux-amd64 release/ddshop_linux_amd64 && chmod +x release/ddshop_linux_amd64
mv $GITHUB_WORKSPACE/build/ddshop-windows-4.0-amd64.exe release/ddshop_windows_amd64.exe
cd release
tar -zcvf ddshop_darwin_amd64.tar.gz ddshop_darwin_amd64
tar -zcvf ddshop_darwin_arm64.tar.gz ddshop_darwin_arm64
tar -zcvf ddshop_linux_amd64.tar.gz ddshop_linux_amd64
zip -q -r ddshop_windows_amd64.zip ddshop_windows_amd64.exe
- name: Release
uses: softprops/action-gh-release@v1
with:
files: |
release/ddshop_linux_amd64.tar.gz
release/ddshop_windows_amd64.zip
release/ddshop_darwin_amd64.tar.gz
release/ddshop_darwin_arm64.tar.gz
docker-release:
runs-on: ubuntu-latest
strategy:
matrix:
target:
- Dockerfile: build/Dockerfile
steps:
- uses: actions/checkout@v3
- name: Prepare
id: prepare
run: |
TAG=${GITHUB_REF#refs/tags/}
DATE=$(date +'%Y-%m-%d_%H-%M-%S')
echo ::set-output name=full_tag_name::${TAG}
echo ::set-output name=full_date_tag::${DATE}
echo ::set-output name=latest_tag::latest
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@master
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_SECRET }}
- name: Build and publish ${{ matrix.target.Dockerfile }}
uses: docker/build-push-action@v2
with:
context: .
push: true
builder: ${{ steps.buildx.outputs.name }}
file: ${{ matrix.target.Dockerfile }}
platforms: linux/amd64,linux/arm64,linux/arm
cache-from: type=gha,scope=${{ github.workflow }}
cache-to: type=gha,mode=max,scope=${{ github.workflow }}
tags: |
zc2638/ddshop:${{ steps.prepare.outputs.full_tag_name }}
zc2638/ddshop:${{ steps.prepare.outputs.full_date_tag }}
zc2638/ddshop:${{ steps.prepare.outputs.latest_tag }}