-
Notifications
You must be signed in to change notification settings - Fork 15
149 lines (129 loc) · 4.37 KB
/
build.yaml
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
name: CI
on:
push:
branches: [ main ]
tags:
- 'v*'
pull_request:
branches: [ main ]
jobs:
linux-build:
strategy:
matrix:
platform:
- { name: "linux/amd64", filename_suffix: "linux-amd64", target_arch: "x86_64", runner: "ubuntu-22.04" }
- { name: "linux/arm64", filename_suffix: "linux-arm64", target_arch: "arm64", runner: "ubuntu-22.04-arm" }
runAllTests:
- ${{ startsWith(github.ref, 'refs/tags/') }}
# exclude:
# - platform: { name: "linux/arm64", filename_suffix: "linux-arm64", target_arch: "arm64" }
# runAllTests: false
fail-fast: false
runs-on: ${{ matrix.platform.runner }}
env:
SLIPSHOW_PLATFORM: ${{ matrix.platform.name }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0 # Needed to fetch tags
# The latest tag is needed to build the release tarball but
# actions/checkout fails to fetch it properly.
# https://github.com/actions/checkout/issues/882
- name: Fetch tags
run: git fetch --tags --force origin
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v3
# with:
# image: tonistiigi/binfmt:latest
# platforms: all
- name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
# with:
# driver: docker
- name: Check images
run: docker image ls
- name: Build release tarball
# if: startsWith(github.ref, 'refs/tags/')
run: |
mkdir -p new_release; chmod a+rw new_release;
docker buildx build --platform ${{ matrix.platform.name }} --load \
--cache-to type=gha,mode=max \
--cache-from type=gha \
-f release/Dockerfile \
-t slipshow-release-${{ matrix.platform.name }} .
docker run --platform ${{ matrix.platform.name }} -v $PWD/new_release:/release \
-e VERSION=$GITHUB_REF_NAME \
-e TARGETOS=linux \
-e TARGETARCH=${{ matrix.platform.target_arch }} \
-e OUTPUT=/release \
slipshow-release-${{ matrix.platform.name }} \
opam exec -- bash release/release.sh
- name: upload archives
# if: startsWith(github.ref, 'refs/tags/')
uses: actions/upload-artifact@v4
with:
name: archives-linux-${{ matrix.platform.target_arch }}
path: new_release/*
mac-build:
strategy:
fail-fast: false
matrix:
config:
- { os: "macos-13", arch: "x86_64" }
- { os: "macos-14", arch: "arm64" }
ocaml-compiler:
- 4.14.x
runs-on: ${{ matrix.config.os }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
# See the same step in the linux build
- name: Fetch tags
run: git fetch --tags --force origin
- name: Use OCaml ${{ matrix.ocaml-compiler }}
uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: ${{ matrix.ocaml-compiler }}
- name: Install dependencies
run: opam install --deps-only --with-test --with-doc -y .
- name: Build release tarball
# if: startsWith(github.ref, 'refs/tags/')
run: |
mkdir -p new_release;
export OUTPUT=$PWD/new_release;
export TARGETOS=macos;
export TARGETARCH=${{ matrix.config.arch }};
export VERSION=$GITHUB_REF_NAME;
opam exec -- bash release/release.sh
- name: upload archives
# if: startsWith(github.ref, 'refs/tags/')
uses: actions/upload-artifact@v4
with:
name: archives-${{ matrix.config.os }}-${{ matrix.config.arch }}
path: new_release/*
release:
if: startsWith(github.ref, 'refs/tags/')
needs: [linux-build, mac-build]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
pattern: archives-*
path: archives
merge-multiple: true
- name: Release
uses: softprops/action-gh-release@v1
with:
draft: true
files: |
archives/*