This repository was archived by the owner on Jul 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
238 lines (199 loc) · 7.04 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
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
234
235
236
237
238
name: Go
on:
push:
branches:
- master
- 'feature/**'
tags:
- v*
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.14
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Build
run: make build_amd64
- name: Upload terrafmt for docker build
uses: actions/upload-artifact@v1
with:
name: docker-binary
path: terrafmt
publish:
name: Publish
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.14
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Build multiarch
run: make -j4
- name: Get the version
id: get_version
run: echo ::set-output name=version::${GITHUB_REF/refs\/tags\//}
- name: Create Release
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: |
Release ${{ steps.get_version.outputs.version }}
draft: false
prerelease: false
- name: Upload Release Asset Darwin 386
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./terrafmt-darwin-386.tar.gz
asset_name: terrafmt-darwin-386.tar.gz
asset_content_type: application/x-gtar
- name: Upload Release Asset Linux 386
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./terrafmt-linux-386.tar.gz
asset_name: terrafmt-linux-386.tar.gz
asset_content_type: application/x-gtar
- name: Upload Release Asset Linux amd64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./terrafmt-linux-amd64.tar.gz
asset_name: terrafmt-linux-amd64.tar.gz
asset_content_type: application/x-gtar
- name: Upload Release Asset Linux arm64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./terrafmt-linux-arm64.tar.gz
asset_name: terrafmt-linux-arm64.tar.gz
asset_content_type: application/x-gtar
- name: Upload Release Asset Linux arm
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./terrafmt-linux-arm.tar.gz
asset_name: terrafmt-linux-arm.tar.gz
asset_content_type: application/x-gtar
- name: Upload Release Asset Windows amd64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./terrafmt-windows-amd64.tar.gz
asset_name: terrafmt-windows-amd64.tar.gz
asset_content_type: application/x-gtar
- name: Save output URL
shell: bash
run: echo -n "${{ steps.create_release.outputs.upload_url }}" > output-url.txt
- name: Upload output URL
uses: actions/upload-artifact@v1
with:
name: output-url
path: output-url.txt
publish_mac:
name: Publish Mac (Signed)
runs-on: macos-latest
needs: publish
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Download output URL from Publish
uses: actions/download-artifact@v1
with:
name: output-url
- name: Set output URL
id: create_release
shell: bash
run: echo "::set-output name=upload_url::$(cat output-url/output-url.txt)"
- name: Install certs
uses: apple-actions/import-codesign-certs@v1
with:
p12-file-base64: ${{ secrets.DEVELOPER_PFX }}
p12-password: ${{ secrets.PFX_PW }}
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.14
- name: Get gon
run: wget https://github.com/mitchellh/gon/releases/download/v0.2.3/gon_macos.zip && unzip gon_macos.zip && chmod +x gon
- name: Build
run: make mac_release
env:
APPLE_APP_PW: ${{ secrets.APPLE_APP_PW}}
- name: Upload Release Asset Darwin amd64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./terrafmt-darwin-amd64.zip
asset_name: terrafmt-darwin-amd64.zip
asset_content_type: application/zip
- name: Test1
run: |
unzip terrafmt-darwin-amd64.zip
ls -lah
codesign -dv --verbose=4 'terrafmt-darwin-amd64/terrafmt'
echo '1234'
codesign -d -r- --verbose=20 'terrafmt-darwin-amd64/terrafmt'
publish-docker:
name: Publish Docker
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Get the version
id: get_version
run: echo ::set-output name=version::${GITHUB_REF/refs\/tags\//}
- name: Download terrafmt amd64
uses: actions/download-artifact@v1
with:
name: docker-binary
- name: Move binary
run: |
mv docker-binary/terrafmt terrafmt
chmod 755 terrafmt
- name: Login to docker hub
uses: actions-hub/docker/login@master
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
- name: Build :latest
run: |
docker build -t terrycain/terrafmt:latest .
docker tag terrycain/terrafmt:latest terrycain/terrafmt:${{ steps.get_version.outputs.version }}
- name: Push to docker hub :latest
uses: actions-hub/docker@master
with:
args: push terrycain/terrafmt:latest
- name: Push to docker hub :${{ steps.get_version.outputs.version }}
uses: actions-hub/docker@master
with:
args: push terrycain/terrafmt:${{ steps.get_version.outputs.version }}