-
Notifications
You must be signed in to change notification settings - Fork 0
166 lines (134 loc) · 5.15 KB
/
ci.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
name: Actions CI
on: push
env:
CUATRO_HEX_KEY: ${{ secrets.CUATRO_HEX_KEY }}
jobs:
bless:
name: Bless
runs-on: ubuntu-latest
env:
MIX_ENV: test
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Determine the elixir version
run: echo "ELIXIR_VERSION=$(grep -h elixir .tool-versions | awk '{ print $2 }' | awk -F - '{print $1}')" >> $GITHUB_ENV
- name: Determine the otp version
run: echo "OTP_VERSION=$(grep -h erlang .tool-versions | awk '{ print $2 }')" >> $GITHUB_ENV
- name: Setup Elixir and Erlang versions
uses: erlef/setup-beam@v1
with:
elixir-version: ${{ env.ELIXIR_VERSION }}
otp-version: ${{ env.OTP_VERSION }}
- name: Restore the deps cache
uses: actions/cache@v4
id: deps-cache
with:
path: deps
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
restore-keys: |
${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-
- name: Restore the _build cache
uses: actions/cache@v4
id: build-cache
with:
path: _build
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-build-mixlockhash-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
restore-keys: |
${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-build-
- name: Fetch mix dependencies
if: steps.deps-cache.outputs.cache-hit != 'true'
run: |
mix local.rebar --force
mix local.hex --force
mix deps.get
- name: Compile dependencies
if: steps.deps-cache.outputs.cache-hit != 'true'
run: mix deps.compile
- name: Compile
run: mix compile --warnings-as-errors --force
- name: Coveralls
run: mix coveralls
- name: Check formatting
run: mix format --check-formatted
- name: Credo
run: mix credo
publish-hex-package:
name: Publish Hex Package ⬆️☁️
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
env:
MIX_ENV: dev
needs:
- bless
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Determine the elixir version
run: echo "ELIXIR_VERSION=$(grep -h elixir .tool-versions | awk '{ print $2 }' | awk -F - '{print $1}')" >> $GITHUB_ENV
- name: Determine the otp version
run: echo "OTP_VERSION=$(grep -h erlang .tool-versions | awk '{ print $2 }')" >> $GITHUB_ENV
- name: Setup Elixir and Erlang versions
uses: erlef/setup-beam@v1
with:
elixir-version: ${{ env.ELIXIR_VERSION }}
otp-version: ${{ env.OTP_VERSION }}
- name: Restore the deps cache
uses: actions/cache@v4
id: deps-cache
with:
path: deps
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
restore-keys: |
${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-
- name: Restore the _build cache
uses: actions/cache@v4
id: build-cache
with:
path: _build
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-build-mixlockhash-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
restore-keys: |
${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-build-
- name: Fetch mix dependencies
if: steps.deps-cache.outputs.cache-hit != 'true'
run: |
mix local.rebar --force
mix local.hex --force
mix deps.get
- name: Compile dependencies
if: steps.deps-cache.outputs.cache-hit != 'true'
run: mix deps.compile
- name: Generate documentation
run: mix docs
- name: Determine the tag version
env:
GITHUB_REF: ${{ github.ref }}
run: echo "TAG=$(echo "$GITHUB_REF" | awk -F / '{print $3}')" >> $GITHUB_ENV
- name: Write the tag version to .version
run: echo $TAG > .version
- name: Determine the repository name
run: echo "REPOSITORY=$(echo $GITHUB_REPOSITORY | awk -F / '{print $2}')" >> $GITHUB_ENV
- name: Create a GitHub Release
id: create_release
uses: NFIBrokerage/create-release@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.TAG }}
release_name: Release ${{ env.TAG }}
draft: false
prerelease: false
- name: Publish library
run: mix hex.publish --yes
env:
HEX_API_KEY: ${{ secrets.HEX_PUBLISH_KEY }}
- name: Notify ops channel of build success
run: >
curl
-X POST
-H 'Content-type:application/json'
-d "{\"text\":\":hexpm: package published for $REPOSITORY $(git tag -ln $TAG)\"}"
$SLACK_WEBHOOK
env:
SLACK_WEBHOOK: ${{ secrets.OPS_CHANNEL_SLACK_WEBHOOK }}
# Generated by Elixir.Gaas.Generators.Simple.Actions.LibraryCi