-
Notifications
You must be signed in to change notification settings - Fork 0
/
orb.yml
233 lines (217 loc) · 6.59 KB
/
orb.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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
version: 2.1
description: |
Easily install and use GoReleaser on CircleCI. GoReleaser is a Go (Golang)
publishing and release tool. You can publish Go projects to GitHub, Brew,
Snap, and more.
Currently supports Linux and macOS on amd64 and arm64.
display:
home_url: "https://circleci.com/developer/orbs/orb/hubci/goreleaser"
source_url: "https://github.com/hubci/goreleaser-orb"
orbs:
ci: hubci/sphere@0.2
go: circleci/go@1.7.1
executors:
cimg:
docker:
- image: cimg/go:<< parameters.go-version >>
parameters:
go-version:
type: string
linux:
machine:
image: ubuntu-2204:2023.07.2
parameters:
go-version:
type: string
mac:
macos:
xcode: 14.0.0
parameters:
go-version:
type: string
commands:
install:
description: |
Install GoReleaser in a job. This command supports Linux and macOS on both amd64 and arm64. Installs to ~/bin.
parameters:
version:
description: The GoReleaser version. This is a full SemVer version.
type: string
steps:
- ci/init
- run:
name: "Install GoReleaser"
command: |
# Ensures the directory we need exist.
# Assuming this path is in PATH should move to hubci/sphere at some point.
mkdir -p ~/bin
# Get the CPU arch. This will also move to hubci/sphere in the future
cpuArch=$( uname -m )
# set the OS name for the asset URL
case $OSD_FAMILY in
linux)
osName="Linux"
installPath=~/bin
;;
darwin)
osName="Darwin"
# this is done because CCI mac images don't have ~/bin in PATH
installPath=/usr/local/bin
;;
*)
echo "Unsupported Operating System"
exit 1
;;
esac
dlURL="https://github.com/goreleaser/goreleaser/releases/download/v<<parameters.version>>/goreleaser_${osName}_${cpuArch}.tar.gz"
curl -sSL $dlURL | $SUDO tar -xz -C ${installPath} goreleaser
release:
description: Run GoReleaser. Optionally without actually publishing.
parameters:
dry-run:
description: |
Basically runs `goreleaser --snapshot --skip=publish --clean` for
you when true.
type: boolean
default: false
config:
description: Path to the config file.
type: string
default: ./.goreleaser.yaml
steps:
- when:
condition: <<parameters.dry-run>>
steps:
- run: goreleaser --snapshot --skip=publish --clean --config=<< parameters.config >>
- unless:
condition: <<parameters.dry-run>>
steps:
- run: goreleaser --config=<< parameters.config >>
jobs:
release:
parameters:
version:
description: The GoReleaser version. This is a full SemVer version.
type: string
go-version:
description: The version of Go to build with.
type: string
dry-run:
description: |
Basically runs `goreleaser --snapshot --skip=publish --clean` for
you when true.
type: boolean
default: false
image:
description: |
Which image/executor technology to run with. Check the executors
shipped with this orb for possible values. Defaults to "cimg"
which uses the `cimg/go` Convenience Image.
type: enum
enum:
- cimg
- linux
- mac
default: cimg
checkout:
description: "Whether or not to run the CircleCI checkout step."
type: boolean
default: true
config:
description: Path to the config file.
type: string
default: ./.goreleaser.yaml
remote-docker:
description: "Whether or not to enable CircleCI's remote Docker within the job."
type: boolean
default: false
executor:
name: << parameters.image >>
go-version: << parameters.go-version >>
description: Release a Go (golang) project or do a test build.
steps:
- when:
condition: << parameters.checkout >>
steps:
- checkout
- go/install:
version: << parameters.go-version >>
- install:
version: << parameters.version >>
- when:
condition: << parameters.remote-docker >>
steps:
- setup_remote_docker:
version: "20.10.24"
- release:
dry-run: << parameters.dry-run >>
config: << parameters.config >>
examples:
main:
description: "An example of how to use the job included in the GoReleaser orb."
usage:
version: 2.1
orbs:
gor: hubci/goreleaser@2.0
workflows:
# General workflow for regular commits
main-wf:
jobs:
- test
- gor/release:
version: "1.7.0"
go-version: "1.18"
dry-run: true
# Workflow for releasing with git tags
release-wf:
jobs:
- test:
filters:
branches:
ignore: /.*/
tags:
# Simplified SemVer regex
only: /^v\d+\.\d+\.\d+$/
- gor/release:
version: "1.7.0"
go-version: "1.18"
filters:
branches:
ignore: /.*/
tags:
# Simplified SemVer regex
only: /^v\d+\.\d+\.\d+$/
jobs:
test:
docker:
- image: cimg/go:1.18
steps:
- checkout
- restore_cache:
keys:
- go-mod-v1
- run:
name: "Download Dependancies"
command: cd src && go mod download
- run:
name: "Run Tests"
command: cd src && go test
- save_cache:
key: go-mod-v1
paths:
- "/go/pkg/mod"
custom-image:
description: "An example of how to use the job included in the GoReleaser orb but with a custom image."
usage:
version: 2.1
orbs:
gor: hubci/goreleaser@2.0
workflows:
# General workflow for regular commits
main-wf:
jobs:
- gor/release:
version: "1.7.0"
go-version: "1.18"
dry-run: true
image: mac