-
Notifications
You must be signed in to change notification settings - Fork 55
148 lines (142 loc) · 4.63 KB
/
build.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
name: Build ruby.wasm
on:
push:
branches: [main]
tags: ["*"]
paths-ignore:
- "*.md"
- "docs/**"
pull_request:
workflow_call:
inputs:
publish:
type: boolean
description: "Whether to publish or not"
default: true
prerel_name:
type: string
description: "Pre-release name to be released"
required: true
secrets:
NODE_AUTH_TOKEN:
required: true
jobs:
lint:
runs-on: ubuntu-20.04
if: ${{ github.event_name == 'pull_request' }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- run: sudo apt-get install clang-format
- run: ./tools/clang-format-diff.sh
- run: rake check:bindgen
- run: git diff --exit-code
build-builder-image:
strategy:
fail-fast: false
matrix:
entry:
- { target: wasm32-unknown-wasi }
- { target: wasm32-unknown-emscripten }
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
with:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
- uses: docker/metadata-action@v4
id: meta
with:
images: ghcr.io/${{ github.repository_owner }}/ruby.wasm/builder/${{ matrix.entry.target }}
- uses: docker/build-push-action@v5
with:
context: builders/${{ matrix.entry.target }}
push: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/tags/*' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-rake-task-matrix:
runs-on: ubuntu-20.04
outputs:
entries: ${{ steps.set-matrix.outputs.entries }}
steps:
- uses: actions/checkout@v4
- run: rake ci:pin_build_manifest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@v3
with:
name: build-manifest
path: build_manifest.json
- name: Set matrix
id: set-matrix
run: |
echo "entries=$(rake ci:rake_task_matrix)" >> $GITHUB_OUTPUT
rake-tasks:
strategy:
fail-fast: false
matrix:
entry: ${{ fromJson(needs.build-rake-task-matrix.outputs.entries) }}
needs: [build-rake-task-matrix]
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v3
with:
name: build-manifest
- uses: actions/[email protected]
with:
path: ./rubies
key: ${{ matrix.entry.rubies_cache_key }}
- uses: docker/setup-buildx-action@v2
- uses: docker/build-push-action@v5
id: builder-image
with:
context: builders/${{ matrix.entry.builder }}
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.2"
bundler-cache: true
- run: ./bin/setup
- name: Pre-release configuration
run: rake ${{ matrix.entry.prerelease }}[${{ inputs.prerel_name }}]
if: ${{ inputs.prerel_name != '' && matrix.entry.prerelease != '' }}
- name: rake ${{ matrix.entry.task }}
run: docker run -v "$GITHUB_WORKSPACE:/home/me/build" -w /home/me/build -e "RUBYWASM_UID=$(id -u)" -e "RUBYWASM_GID=$(id -g)" -e "GNUMAKEFLAGS=-j$((1 + $(nproc --all)))" ${{ steps.builder-image.outputs.imageid }} rake ${{ matrix.entry.task }}
- name: rake ${{ matrix.entry.test }}
run: rake ${{ matrix.entry.test }}
if: ${{ matrix.entry.test != '' }}
- uses: actions/upload-artifact@v3
if: ${{ matrix.entry.artifact }}
with:
name: ${{ matrix.entry.artifact_name }}
path: ${{ matrix.entry.artifact }}
release-artifacts:
needs: [rake-tasks]
runs-on: ubuntu-20.04
if: ${{ startsWith(github.ref, 'refs/tags/') || inputs.publish }}
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v3
with:
name: build-manifest
- uses: actions/download-artifact@v3
with:
path: release
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- run: echo "PREREL_NAME=${{ inputs.prerel_name }}" >> $GITHUB_ENV
- run: rake "ci:publish[${PREREL_NAME:-$GITHUB_REF_NAME}]"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}