-
Notifications
You must be signed in to change notification settings - Fork 2
142 lines (120 loc) · 4.19 KB
/
Copy pathtest-and-release.yaml
File metadata and controls
142 lines (120 loc) · 4.19 KB
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
name: Test → Docs → Release
on:
- pull_request
- push
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
REBAR_VERSION: '3.25.1'
LATEST_ERLANG_VERSION: '28'
jobs:
# `env_to_output` works around a limitation of GitHub Actions that prevents
# the use of environment variables in places such as a workflow call's `with`
# arguments.
#
# https://github.com/actions/runner/issues/1189#issuecomment-1832389701
env_to_output:
name: Env. variable to outputs
runs-on: ubuntu-latest
outputs:
REBAR_VERSION: ${{ steps.from_env.outputs.REBAR_VERSION }}
steps:
- id: from_env
run: |
vars="
REBAR_VERSION
"
setOutput() {
echo "${1}=${!1}" >> "${GITHUB_OUTPUT}"
}
for name in $vars; do
setOutput $name
done
test:
name: Test
needs: env_to_output
uses: ./.github/workflows/test-job.yaml
with:
rebar_version: ${{ needs.env_to_output.outputs.REBAR_VERSION }}
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
dialyzer:
name: Dialyzer
runs-on: ubuntu-latest
needs: env_to_output
steps:
- uses: actions/checkout@v4
- uses: erlef/setup-beam@566deebc640988a494af16ecdf6f820fe0d3fea4
id: install-erlang
with:
otp-version: ${{ env.LATEST_ERLANG_VERSION }}
rebar3-version: ${{ env.REBAR_VERSION }}
- name: Restore Dialyzer PLT files from cache
uses: actions/cache@v4
with:
path: _build/*/rebar3_*_plt
key: dialyzer-plt-cache-${{ steps.install-erlang.outputs.otp-version }}-${{ runner.os }}-${{ hashFiles('rebar.config*') }}-v1
- name: Dialyzer
run: rebar3 clean && rebar3 as test dialyzer
build_docs:
name: Generate docs
runs-on: ubuntu-latest
needs:
- test
- dialyzer
steps:
- uses: actions/checkout@v4
- uses: erlef/setup-beam@566deebc640988a494af16ecdf6f820fe0d3fea4
with:
otp-version: ${{ env.LATEST_ERLANG_VERSION }}
rebar3-version: ${{ env.REBAR_VERSION }}
- name: Change doc version to "Development branch"
run: sed -E -i -e 's/^@version.*/@version Development branch/' doc/overview.edoc
- name: Generate
run: rebar3 edoc
- name: Ensure HTML files are there
run: ls -l doc && test -f doc/index.html
- name: Upload docs for next job
uses: actions/upload-artifact@v4
with:
name: docs_dir
path: ./doc
if-no-files-found: error
publish_docs:
name: Publish docs
runs-on: ubuntu-latest
needs: build_docs
if: github.repository == 'rabbitmq/horus' && github.ref == 'refs/heads/main'
steps:
- name: Download docs from previous job
uses: actions/download-artifact@v4
with:
name: docs_dir
path: ./doc
- name: Ensure HTML files are there
run: ls -l doc && test -f doc/index.html
- name: Publish
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./doc
publish_release:
name: Publish release
runs-on: ubuntu-latest
needs:
- test
- dialyzer
- build_docs
if: github.repository == 'rabbitmq/horus' && (startsWith(github.ref, 'refs/tags/v0') || startsWith(github.ref, 'refs/tags/v1') || startsWith(github.ref, 'refs/tags/v2') || startsWith(github.ref, 'refs/tags/v3') || startsWith(github.ref, 'refs/tags/v4') || startsWith(github.ref, 'refs/tags/v5') || startsWith(github.ref, 'refs/tags/v6') || startsWith(github.ref, 'refs/tags/v7') || startsWith(github.ref, 'refs/tags/v8') || startsWith(github.ref, 'refs/tags/v9'))
steps:
- uses: actions/checkout@v4
- uses: erlef/setup-beam@566deebc640988a494af16ecdf6f820fe0d3fea4
id: install-erlang
with:
otp-version: ${{ env.LATEST_ERLANG_VERSION }}
rebar3-version: ${{ env.REBAR_VERSION }}
- name: Publish to Hex.pm
env:
HEX_API_KEY: ${{ secrets.HEX_API_KEY }}
run: rebar3 edoc && rebar3 hex publish -r hexpm --yes