forked from cogini/mix_deploy
-
Notifications
You must be signed in to change notification settings - Fork 0
273 lines (263 loc) · 9.89 KB
/
private-elixir-library-w-git-ops.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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
on: push
name: Privately published Elixir Library (with git ops)
env:
ELIXIR_VERSION: "1.12.3"
OTP_VERSION: "24.3.3"
jobs:
deps:
runs-on: ubuntu-20.04
env:
NARRATIVE_HEX_ORG_API_KEY: ${{ secrets.NARRATIVE_HEX_ORG_API_KEY }}
MIX_ENV: test
steps:
- name: Checking out project
uses: actions/checkout@v4
- name: "Setting up Elixir"
uses: erlef/setup-beam@v1
with:
otp-version: ${{ env.OTP_VERSION }}
elixir-version: ${{ env.ELIXIR_VERSION }}
- name: Signing into narrativeapp organisation on hex
run: mix hex.organization auth narrativeapp --key $NARRATIVE_HEX_ORG_API_KEY
- name: Downloading dependency cache
uses: actions/cache@v4
with:
path: deps
key: ${{ runner.os }}-deps
- run: mix deps.get
- name: Uploading dependencies for other jobs
uses: actions/upload-artifact@v4
with:
name: deps
path: deps/
build:
runs-on: ubuntu-20.04
needs: ["deps"]
env:
MIX_ENV: test
steps:
- name: Checking out project
uses: actions/checkout@v4
- name: "Setting up Elixir"
uses: erlef/setup-beam@v1
with:
otp-version: ${{ env.OTP_VERSION }}
elixir-version: ${{ env.ELIXIR_VERSION }}
- name: Downloading dependencies
uses: actions/download-artifact@v4
with:
name: deps
path: deps/
- name: Downloading build artifact cache
uses: actions/cache@v4
with:
path: _build
key: ${{ runner.os }}-build
- name: Run `mix compile`
run: mix compile
- name: Uploading build artifacts for other jobs
uses: actions/upload-artifact@v4
with:
name: build
path: _build/
credo:
runs-on: ubuntu-20.04
needs: ["deps", "build"]
env:
MIX_ENV: test
steps:
- name: Checking out project
uses: actions/checkout@v4
- name: "Setting up Elixir"
uses: erlef/setup-beam@v1
with:
otp-version: ${{ env.OTP_VERSION }}
elixir-version: ${{ env.ELIXIR_VERSION }}
- name: Downloading dependencies
uses: actions/download-artifact@v4
with:
name: deps
path: deps/
- name: Downloading build artifacts
uses: actions/download-artifact@v4
with:
name: build
path: _build/
- run: mix credo --strict
formatter:
runs-on: ubuntu-20.04
steps:
- name: Checking out project
uses: actions/checkout@v4
- name: "Setting up Elixir"
uses: erlef/setup-beam@v1
with:
otp-version: ${{ env.OTP_VERSION }}
elixir-version: ${{ env.ELIXIR_VERSION }}
- run: mix format --check-formatted
audit:
runs-on: ubuntu-20.04
needs: ["deps"]
env:
NARRATIVE_HEX_ORG_API_KEY: ${{ secrets.NARRATIVE_HEX_ORG_API_KEY }}
MIX_ENV: test
steps:
- name: Checking out project
uses: actions/checkout@v4
- name: "Setting up Elixir"
uses: erlef/setup-beam@v1
with:
otp-version: ${{ env.OTP_VERSION }}
elixir-version: ${{ env.ELIXIR_VERSION }}
- run: mix hex.organization auth narrativeapp --key $NARRATIVE_HEX_ORG_API_KEY
- name: Downloading dependencies
uses: actions/download-artifact@v4
with:
name: deps
path: deps/
- run: mix hex.audit
test:
runs-on: ubuntu-20.04
needs: ["deps", "build"]
env:
MIX_ENV: test
steps:
- name: Checking out project
uses: actions/checkout@v4
- name: "Setting up Elixir"
uses: erlef/setup-beam@v1
with:
otp-version: ${{ env.OTP_VERSION }}
elixir-version: ${{ env.ELIXIR_VERSION }}
- name: Downloading dependencies
uses: actions/download-artifact@v4
with:
name: deps
path: deps/
- name: Downloading build artifacts
uses: actions/download-artifact@v4
with:
name: build
path: _build/
- run: mix test
is_releasable:
runs-on: ubuntu-20.04
needs: ["deps", "test", "audit", "formatter", "credo"]
if: ${{ github.event_name == 'push' && github.ref != 'refs/heads/master'}}
env:
HEX_API_KEY: ${{ secrets.NARRATIVE_HEX_ORG_API_KEY }}
steps:
- name: Checking out project
uses: actions/checkout@v4
- name: "Setting up Elixir"
uses: erlef/setup-beam@v1
with:
otp-version: ${{ env.OTP_VERSION }}
elixir-version: ${{ env.ELIXIR_VERSION }}
- name: Downloading dependencies
uses: actions/download-artifact@v4
with:
name: deps
path: deps/
- name: Downloading build artifacts
uses: actions/download-artifact@v4
with:
name: build
path: _build/
- name: Getting app information
id: app-info
run: MIX_ENV=test mix git_ops.project_info --format github-actions
- name: Run mix hex.build
run: mix hex.build -o ${{ steps.app-info.outputs.app_name }}-${{ steps.app-info.outputs.app_version }}.tar
- name: Uploading hex package as job artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.app-info.outputs.app_name }}-${{ steps.app-info.outputs.app_version }}.tar
path: ${{ steps.app-info.outputs.app_name }}-${{ steps.app-info.outputs.app_version }}.tar
- name: Run mix docs
run: MIX_ENV=test mix docs && tar zcvf docs.tar.gz doc/
- name: Uploading documentation as job artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.app-info.outputs.app_name }}-docs-${{ steps.app-info.outputs.app_version }}.tar.gz
path: docs.tar.gz
git_ops:
runs-on: ubuntu-20.04
needs: ["deps", "test", "audit", "formatter", "credo"]
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
env:
HEX_API_KEY: ${{ secrets.NARRATIVE_HEX_ORG_API_KEY }}
steps:
- name: Checking out project
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: "Setting up Elixir"
uses: erlef/setup-beam@v1
with:
otp-version: ${{ env.OTP_VERSION }}
elixir-version: ${{ env.ELIXIR_VERSION }}
- name: Downloading dependencies
uses: actions/download-artifact@v4
with:
name: deps
path: deps/
- name: Downloading build artifacts
uses: actions/download-artifact@v4
with:
name: build
path: _build/
- name: Configure git author
run: git config user.email '41898282+github-actions[bot]@users.noreply.github.com' ; git config user.name 'github-actions'
- name: Retrieving the current app version
id: original-app-info
run: MIX_ENV=test mix git_ops.project_info --format github-actions
- name: Run mix git_ops.release
run: MIX_ENV=test mix git_ops.release --yes || true
- name: Checking for new app version
id: app-info
run: MIX_ENV=test mix git_ops.project_info --format github-actions
- name: Building hex package
if: ${{ steps.original-app-info.outputs.app_version != steps.app-info.outputs.app_version }}
run: mix hex.build -o ${{ steps.app-info.outputs.app_name }}-${{ steps.app-info.outputs.app_version }}.tar
- name: Building hex docs
if: ${{ steps.original-app-info.outputs.app_version != steps.app-info.outputs.app_version }}
run: MIX_ENV=test mix docs && tar zcvf ${{ steps.app-info.outputs.app_name }}-${{ steps.app-info.outputs.app_version }}-docs.tar.gz doc/
- name: Pushing new tag
if: ${{ steps.original-app-info.outputs.app_version != steps.app-info.outputs.app_version }}
run: git push "https://${{ github.actor }}:${{ github.token }}@github.com/${{ github.repository }}" HEAD:${{ github.ref }} refs/tags/v${{ steps.app-info.outputs.app_version }}
- name: Creating new Github release
if: ${{ steps.original-app-info.outputs.app_version != steps.app-info.outputs.app_version }}
id: create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
tag_name: v${{ steps.app-info.outputs.app_version }}
release_name: Release ${{ steps.app-info.outputs.app_name }} ${{ steps.app-info.outputs.app_version }}
body: Autogenerated by git_ops release.
- name: Uploading hex package as release artifact
if: ${{ steps.original-app-info.outputs.app_version != steps.app-info.outputs.app_version }}
id: upload-package
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: ${{ steps.app-info.outputs.app_name }}-${{ steps.app-info.outputs.app_version }}.tar
asset_name: ${{ steps.app-info.outputs.app_name }}-${{ steps.app-info.outputs.app_version }}.tar
asset_content_type: application/x-tar
- name: Uploading documentation as release artifact
if: ${{ steps.original-app-info.outputs.app_version != steps.app-info.outputs.app_version }}
id: upload-docs
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: ${{ steps.app-info.outputs.app_name }}-${{ steps.app-info.outputs.app_version }}-docs.tar.gz
asset_name: ${{ steps.app-info.outputs.app_name }}-${{ steps.app-info.outputs.app_version }}-docs.tar.gz
asset_content_type: application/gzip
- name: Publishing hex package
if: ${{ steps.original-app-info.outputs.app_version != steps.app-info.outputs.app_version }}
run: mix hex.publish --organization narrativeapp --yes