-
-
Notifications
You must be signed in to change notification settings - Fork 25
175 lines (148 loc) · 5.41 KB
/
workflow.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
name: CI
on:
pull_request:
push:
branches:
- main
jobs:
create_draft_release:
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_draft_release.outputs.upload_url }}
steps:
- name: Create draft release on tags
id: create_draft_release
if: ${{ startsWith(github.ref, 'refs/tags/') }}
uses: actions/create-release@v1.1.4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: true
prerelease: false
build:
needs: create_draft_release
strategy:
fail-fast: false
matrix:
os:
- macos-latest
- ubuntu-18.04
- windows-latest
ocaml-version:
- 4.11.1
include:
- os: macos-latest
suffix: x86_64-apple-darwin
- os: ubuntu-18.04
ocaml-version: 4.11.1
suffix: x86_64-unknown-linux-gnu
- os: ubuntu-20.04
ocaml-version: 4.11.1+musl+static+flambda
suffix: x86_64-unknown-linux-musl
- os: windows-latest
suffix: x86_64-pc-windows-gnu
stdlib_path: D:\a\caramel\caramel\_build\default\stdlib
env:
OCAML_VERSION: ${{ matrix.ocaml-version }}
OS: ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Fetch tags
id: tag
run: git fetch --tags --force
- name: Cached Infra
uses: actions/cache@v2
env:
cache-name: cached-opam
with:
path: |
~/.opam
_build
/home/runneradmin/.opam
C:\cygwin\home\runneradmin\.opam
D:\a\caramel\caramel
key: v${{ secrets.CACHE_VERSION }}-${{ matrix.os }}-${{ matrix.ocaml-version }}-${{ env.cache-name }}-${{ hashFiles('**/*.opam*') }}
restore-keys: |
v${{ secrets.CACHE_VERSION }}-${{ matrix.os }}-${{ matrix.ocaml-version }}-${{ env.cache-name }}-
v${{ secrets.CACHE_VERSION }}-${{ matrix.os }}-${{ matrix.ocaml-version }}-
v${{ secrets.CACHE_VERSION }}-${{ matrix.os }}-
- name: Use OCaml ${{ matrix.ocaml-version }}
uses: avsm/setup-ocaml@v1
with:
ocaml-version: ${{ matrix.ocaml-version }}
- name: Set git user
run: |
git config --global user.name github-actions
git config --global user.email github-actions-bot@users.noreply.github.com
- name: Define env (Unix)
if: ${{ runner.os != 'Windows' }}
run: echo "GITHUB_TAG=$(git describe --always --tags)" >> $GITHUB_ENV
- name: Define env (Windows)
if: ${{ runner.os == 'Windows' }}
run: |
echo "GITHUB_TAG=$(git describe --always --tags)" >> $Env:GITHUB_ENV
echo "CARAMEL_STDLIB_PATH=${{ matrix.stdlib_path }}" >> $Env:GITHUB_ENV
- name: Update Opam
run: opam update --yes
- name: Install dependencies
run: opam exec -- make setup
- name: Build project
run: opam exec -- make clean build uninstall install
- name: Run tests
run: opam exec -- make test
- name: Check code formatting
if: ${{ success() && startsWith(runner.os, 'Linux') }}
run: opam exec -- make fmt
- name: Create release archive (Windows)
if: ${{ success() && runner.os == 'Windows' }}
run: |
opam exec -- make release.win
- name: Create release archive (UNIX)
if: ${{ success() && runner.os != 'Windows' }}
run: |
opam exec -- make release
- name: Install dune-release to publish libraries
if: ${{ startsWith(runner.os, 'macos')}}
run: |
opam install -y dune-release
opam exec -- make release-erlang
- name: Upload erlang build artifact
if: ${{ success() && startsWith(runner.os, 'macos')}}
uses: actions/upload-artifact@v2
with:
path: erlang.tbz
name: erlang-${{ env.GITHUB_TAG }}.tbz
if-no-files-found: error
- name: Upload caramel build artifact
if: ${{ success() }}
uses: actions/upload-artifact@v2
with:
path: release.tar.gz
name: caramel-${{ env.GITHUB_TAG }}-${{ matrix.suffix }}.tar.gz
if-no-files-found: error
- name: Upload erlang library tarball
if: ${{ success() && startsWith(github.ref, 'refs/tags/') && startsWith(runner.os, 'macos')}}
id: upload-erlang-library-tarball
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_draft_release.outputs.upload_url }}
asset_path: erlang.tbz
asset_name: erlang-${{ env.GITHUB_TAG }}.tbz
asset_content_type: application/zip
- name: Upload caramel release tarball
if: ${{ success() && startsWith(github.ref, 'refs/tags/') }}
id: upload-caramel-release-tarball
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_draft_release.outputs.upload_url }}
asset_path: release.tar.gz
asset_name: caramel-${{ env.GITHUB_TAG }}-${{ matrix.suffix }}.tar.gz
asset_content_type: application/zip