-
Notifications
You must be signed in to change notification settings - Fork 11
203 lines (174 loc) · 6.71 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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
name: "MetaCall Distributable Linux Release"
on:
workflow_dispatch:
pull_request:
push:
tags:
- 'v*.*.*'
branches:
- master
env:
GHR_VERSION: 0.17.0
# GITHUB_TOKEN - From default secrets
# GITHUB_REPOSITORY - Default variable
jobs:
build:
name: Build and Package
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
arch: [amd64, 386]
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Check out the repo
uses: actions/checkout@v4
- name: Build the base image for ${{ matrix.arch }}
run: |
docker buildx build \
--platform linux/${{ matrix.arch }} \
-t metacall/distributable_linux \
--load \
-f Dockerfile .
- name: Install additional channels and pull for ${{ matrix.arch }}
run: |
docker run \
--platform linux/${{ matrix.arch }} \
--privileged \
--name tmp \
metacall/distributable_linux sh -c 'guix pull'
docker commit tmp metacall/distributable_linux
docker rm -f tmp
- name: Build dependencies for ${{ matrix.arch }}
run: |
docker run \
--platform linux/${{ matrix.arch }} \
--privileged \
--name tmp \
metacall/distributable_linux /metacall/scripts/deps.sh
docker commit tmp metacall/distributable_linux
docker rm -f tmp
- name: Build tarball for ${{ matrix.arch }}
run: |
docker run \
--platform linux/${{ matrix.arch }} \
--rm \
-v `pwd`/out:/metacall/pack \
--privileged \
metacall/distributable_linux /metacall/scripts/build.sh
mv out/tarball.tar.gz out/metacall-tarball-linux-${{ matrix.arch }}.tar.gz
- name: Upload tarball artifact for ${{ matrix.arch }}
uses: actions/upload-artifact@v4
with:
name: built-tarball-${{ matrix.arch }}
path: out/metacall-tarball-linux-${{ matrix.arch }}.tar.gz
test:
name: Test
runs-on: ubuntu-latest
needs: build
strategy:
fail-fast: false
matrix:
arch: [amd64, 386]
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Download tarball artifact for ${{ matrix.arch }}
uses: actions/download-artifact@v4
with:
name: built-tarball-${{ matrix.arch }}
path: out/
- name: Prepare tarball for ${{ matrix.arch }}
run: mv out/metacall-tarball-linux-${{ matrix.arch }}.tar.gz out/tarball.tar.gz
- name: Generate a unique ID for invalidating the cache of test layers
run: echo "CACHE_INVALIDATE=$(date +%s)" >> $GITHUB_ENV
- name: Test CLI for ${{ matrix.arch }}
run: |
docker buildx build \
--platform linux/${{ matrix.arch }} \
--build-arg CACHE_INVALIDATE=${{ env.CACHE_INVALIDATE }} \
-t metacall/distributable_linux_test:cli \
-f tests/cli/Dockerfile .
- name: Test C for ${{ matrix.arch }}
run: |
docker buildx build \
--platform linux/${{ matrix.arch }} \
--build-arg CACHE_INVALIDATE=${{ env.CACHE_INVALIDATE }} \
-t metacall/distributable_linux_test:c \
-f tests/c/Dockerfile .
- name: Test Python for ${{ matrix.arch }}
run: |
docker buildx build \
--platform linux/${{ matrix.arch }} \
--build-arg CACHE_INVALIDATE=${{ env.CACHE_INVALIDATE }} \
-t metacall/distributable_linux_test:python \
-f tests/python/Dockerfile .
- name: Test Node for ${{ matrix.arch }}
run: |
docker buildx build \
--platform linux/${{ matrix.arch }} \
--build-arg CACHE_INVALIDATE=${{ env.CACHE_INVALIDATE }} \
-t metacall/distributable_linux_test:node \
-f tests/node/Dockerfile .
- name: Test TypeScript for ${{ matrix.arch }}
run: |
docker buildx build \
--platform linux/${{ matrix.arch }} \
--build-arg CACHE_INVALIDATE=${{ env.CACHE_INVALIDATE }} \
-t metacall/distributable_linux_test:typescript \
-f tests/typescript/Dockerfile .
publish-github:
name: Publish on GitHub
runs-on: ubuntu-latest
needs: test
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Check out the repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download tarball artifacts for all architectures
uses: actions/download-artifact@v4
with:
merge-multiple: true
path: out/
- name: Load GHR binary
run: |
curl -sL https://github.com/tcnksm/ghr/releases/download/v${GHR_VERSION}/ghr_v${GHR_VERSION}_linux_amd64.tar.gz | tar zx
chmod +x ghr_v${GHR_VERSION}_linux_amd64/ghr
mv ghr_v${GHR_VERSION}_linux_amd64/ghr /usr/local/bin
- name: Export variables
run: |
echo "GH_REPO_OWNER=${GITHUB_REPOSITORY_OWNER}" >> $GITHUB_ENV
echo "GH_REPO_NAME=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV
export PREVIOUS_TAG=$(git describe HEAD^1 --abbrev=0 --tags)
echo "PREVIOUS_TAG=${PREVIOUS_TAG}" >> $GITHUB_ENV
echo "GIT_HISTORY<<EOF" >> $GITHUB_ENV
echo "$(git log --no-merges --format="- %s" ${PREVIOUS_TAG}..HEAD)" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Publish package to GitHub Releases
run: |
if [[ "${PREVIOUS_TAG}" == "" ]]; then export GIT_HISTORY=$(git log --no-merges --format="- %s"); fi
export CI_COMMIT_TAG="${{ github.ref_name }}"
export RELEASE_DATE=$(date '+%Y-%m-%d')
echo "MetaCall Distributable Linux ${CI_COMMIT_TAG} [${RELEASE_DATE}] - ${GH_REPO_OWNER}/${GH_REPO_NAME}:${CI_COMMIT_SHA}" && echo "${GIT_HISTORY}"
ghr -t "${{ secrets.GITHUB_TOKEN }}" -u "${GH_REPO_OWNER}" -r "${GH_REPO_NAME}" -c "${CI_COMMIT_SHA}" -n "MetaCall Distributable Linux ${CI_COMMIT_TAG} [${RELEASE_DATE}]" -b "${GIT_HISTORY}" -replace "${CI_COMMIT_TAG}" `pwd`/out/*
install-test:
name: Trigger Install Test Workflow
runs-on: ubuntu-latest
needs: publish-github
if: startsWith(github.ref, 'refs/tags/v')
steps:
- uses: convictional/[email protected]
with:
owner: metacall
repo: install
github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
workflow_file_name: test-linux.yml
wait_workflow: true
ref: master