-
Notifications
You must be signed in to change notification settings - Fork 0
106 lines (102 loc) · 3.22 KB
/
build.yml
File metadata and controls
106 lines (102 loc) · 3.22 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
name: Build CLI
on:
push:
branches: [ main ]
tags:
- 'cli-v*'
pull_request:
branches: [ main ]
workflow_dispatch:
workflow_call:
inputs:
artifacts-for-extension:
required: false
type: boolean
default: false
permissions:
contents: read
actions: read
jobs:
build-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Set up OCaml
uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: 5.3.0
dune-cache: false
- name: Get version
id: get_version
run: |
if [[ $GITHUB_REF == refs/tags/cli-v* ]]; then
echo "VERSION=${GITHUB_REF#refs/tags/cli-v}" >> $GITHUB_OUTPUT
else
echo "VERSION=latest" >> $GITHUB_OUTPUT
fi
- name: Install dependencies
run: opam install . --deps-only --with-test
- name: Build project
run: opam exec -- dune build
- name: Create executable directory
run: mkdir -p dist
- name: Copy executable
run: cp _build/default/bin/main.exe dist/rescriptdep
- name: Set executable permissions
run: chmod +x dist/rescriptdep
- name: Create tar archive
run: |
cd dist
tar -czf rescriptdep-darwin-x64-${{ steps.get_version.outputs.VERSION }}.tar.gz rescriptdep
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: rescriptdep-darwin-x64-${{ steps.get_version.outputs.VERSION }}
path: dist/rescriptdep-darwin-x64-${{ steps.get_version.outputs.VERSION }}.tar.gz
retention-days: 7
build-linux:
runs-on: ubuntu-latest
container:
image: ocaml/opam:alpine-ocaml-5.3
options: --user root
steps:
- uses: actions/checkout@v4
- name: Get version
id: get_version
run: |
if [[ $GITHUB_REF == refs/tags/cli-v* ]]; then
echo "VERSION=${GITHUB_REF#refs/tags/cli-v}" >> $GITHUB_OUTPUT
else
echo "VERSION=latest" >> $GITHUB_OUTPUT
fi
- name: Install system dependencies
run: |
apk add --no-cache linux-headers build-base musl-dev
- name: Initialize opam
run: |
opam init --disable-sandboxing -y
opam switch list
- name: Install OCaml dependencies
run: |
eval $(opam env)
opam install . --deps-only --with-test -y
- name: Build project
run: |
eval $(opam env)
opam exec -- dune build --profile static
- name: Create executable directory
run: mkdir -p dist
- name: Copy executable
run: cp _build/default/bin/main.exe dist/rescriptdep
- name: Set executable permissions
run: chmod +x dist/rescriptdep
- name: Create tar archive
run: |
cd dist
tar -czf rescriptdep-linux-x64-${{ steps.get_version.outputs.VERSION }}.tar.gz rescriptdep
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: rescriptdep-linux-x64-${{ steps.get_version.outputs.VERSION }}
path: dist/rescriptdep-linux-x64-${{ steps.get_version.outputs.VERSION }}.tar.gz
retention-days: 7