-
Notifications
You must be signed in to change notification settings - Fork 11
175 lines (152 loc) · 5.32 KB
/
build-and-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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
name: Build and Release
on:
push:
pull_request:
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
# Windows builds always use linux/amd64 platform
- os: windows
arch: 386
dockerfile: ./docker/Dockerfile.windows.386
artifact: nomi-cli.zip
platform: linux/amd64
- os: windows
arch: amd64
dockerfile: ./docker/Dockerfile.windows.amd64
artifact: nomi-cli.zip
platform: linux/amd64
# Linux builds with specific architectures
- os: linux
arch: 386
dockerfile: ./docker/Dockerfile.linux.386
artifact: nomi-cli
platform: linux/amd64
- os: linux
arch: amd64
dockerfile: ./docker/Dockerfile.linux.amd64
artifact: nomi-cli
platform: linux/amd64
- os: linux
arch: arm64
dockerfile: ./docker/Dockerfile.linux.arm64
artifact: nomi-cli
platform: linux/arm64
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: ${{ matrix.platform }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set Build Version and Date
run: |
echo "BUILD_VERSION=${GITHUB_REF_NAME}" >> $GITHUB_ENV
echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV
- name: Build with Docker
run: |
docker buildx build \
--platform ${{ matrix.platform }} \
-f ${{ matrix.dockerfile }} \
-t nomi-cli-${{ matrix.os }}-${{ matrix.arch }} \
--build-arg BUILD_VERSION=${{ env.BUILD_VERSION }} \
--build-arg BUILD_DATE=${{ env.BUILD_DATE }} \
--output type=local,dest=build \
.
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: nomi-cli-${{ matrix.os }}-${{ matrix.arch }}
path: build/app/${{ matrix.artifact }}
build-darwin-arm64:
runs-on: macos-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Install Dependencies
run: bash hack/install-deps.sh
- name: Build Binary on Linux and macOS
shell: bash
env:
CGO_ENABLED: 1
run: |
go build \
-ldflags "-X main.buildDate=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
-X main.buildVersion=${{ github.ref_name }}" \
-o nomi-cli ./cmd/cli
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: nomi-cli-darwin-arm64
path: nomi-cli
release:
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
needs: [build, build-darwin-arm64]
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: nomi-cli-windows-amd64
path: artifacts/windows-amd64
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: nomi-cli-windows-386
path: artifacts/windows-386
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: nomi-cli-linux-amd64
path: artifacts/linux-amd64
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: nomi-cli-linux-386
path: artifacts/linux-386
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: nomi-cli-linux-arm64
path: artifacts/linux-arm64
- name: Download Darwin ARM64 Artifact
uses: actions/download-artifact@v4
with:
name: nomi-cli-darwin-arm64
path: artifacts/darwin-arm64
- name: Move Artifacts
run: |
mv artifacts/darwin-arm64/nomi-cli artifacts/darwin-arm64/nomi-cli-darwin-arm64
mv artifacts/linux-arm64/nomi-cli artifacts/linux-arm64/nomi-cli-linux-arm64
mv artifacts/linux-386/nomi-cli artifacts/linux-386/nomi-cli-linux-386
mv artifacts/linux-amd64/nomi-cli artifacts/linux-amd64/nomi-cli-linux-amd64
mv artifacts/windows-386/nomi-cli.zip artifacts/windows-386/nomi-cli-windows-386.zip
mv artifacts/windows-amd64/nomi-cli.zip artifacts/windows-amd64/nomi-cli-windows-amd64.zip
- uses: release-drafter/release-drafter@v5
with:
config-name: default
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: |
artifacts/windows-amd64/nomi-cli-windows-amd64.zip
artifacts/windows-386/nomi-cli-windows-386.zip
artifacts/linux-amd64/nomi-cli-linux-amd64
artifacts/linux-386/nomi-cli-linux-386
artifacts/linux-arm64/nomi-cli-linux-arm64
artifacts/darwin-arm64/nomi-cli-darwin-arm64
token: ${{ secrets.GITHUB_TOKEN }}
generate_release_notes: false