-
Notifications
You must be signed in to change notification settings - Fork 0
114 lines (95 loc) · 2.86 KB
/
docker-release.yaml
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
name: Build, Docker, and Release
on:
push:
branches:
- main
- 'feature/*'
- 'fix/*'
env:
VERSION_FILE: VERSION
DOCKER_IMAGE: ghcr.io/${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux, windows, darwin]
goarch: [amd64, arm64]
exclude:
- goos: windows
goarch: arm64
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.22.x'
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Bump version
run: make version-bump
- name: Read version
id: version
run: echo "VERSION=$(cat $VERSION_FILE)" >> $GITHUB_OUTPUT
- name: Run tests
run: go test ./...
- name: Build for ${{ matrix.goos }}-${{ matrix.goarch }}
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: |
go build -o kado-${{ matrix.goos }}-${{ matrix.goarch }}
if [ "${{ matrix.goos }}" = "windows" ]; then
mv kado-${{ matrix.goos }}-${{ matrix.goarch }} kado-${{ matrix.goos }}-${{ matrix.goarch }}.exe
fi
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: kado-binaries
path: kado-*
docker:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Log in to GitHub Container Registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin
- name: Read version
id: version
run: echo "VERSION=$(cat $VERSION_FILE)" >> $GITHUB_OUTPUT
- name: Build Docker image
run: make docker-build
- name: Push Docker image to GitHub Packages
run: |
docker push ${{ env.DOCKER_IMAGE }}:latest
docker push ${{ env.DOCKER_IMAGE }}:${{ steps.version.outputs.VERSION }}
release:
needs:
- build
- docker
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Read version
id: version
run: echo "VERSION=$(cat $VERSION_FILE)" >> $GITHUB_OUTPUT
- name: Download all artifacts
uses: actions/download-artifact@v2
with:
name: kado-binaries
path: artifacts
- name: Create GitHub release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ steps.version.outputs.VERSION }}
name: Release ${{ steps.version.outputs.VERSION }}
files: artifacts/kado-*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}