-
Notifications
You must be signed in to change notification settings - Fork 30
174 lines (149 loc) · 5.87 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
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
name: Build Docker image with multi-arch
on:
schedule:
- cron: '15 */8 * * *'
repository_dispatch:
types:
- build
workflow_dispatch:
inputs:
ruby_version:
required: true
default: master
description: '"master" or version nunmber ("3.1.2")'
env:
ruby_version: ${{ github.event.inputs.ruby_version || github.event.client_payload.ruby_version || 'master' }}
jobs:
build:
strategy:
fail-fast: false
matrix:
ubuntu_version:
- noble
- jammy
- focal
dev_suffix: [ '', '-dev' ]
debug_suffix: ['', '-debug']
arch: ['amd64', 'arm64']
runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }}
env:
nightly: false
push: false
ubuntu_version: "${{ matrix.ubuntu_version }}"
tag_suffix: "-${{ matrix.arch }}-${{ github.sha }}"
push_tags: ${{ inputs.ruby_version || 'master' }}${{ matrix.debug_suffix }}${{ matrix.dev_suffix }}-${{ matrix.ubuntu_version }}-${{ matrix.arch }}-${{ github.sha }}
dev_suffix: ${{ matrix.dev_suffix }}
debug_suffix: ${{ matrix.debug_suffix }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}
- uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USER }}
password: ${{ secrets.GHCR_ACCESS_TOKEN }}
- run: |
if [ "${{ env.dev_suffix }}" = "-dev" ]; then
echo "target=development" >> $GITHUB_ENV
else
echo "target=ruby" >> $GITHUB_ENV
fi
if [ "${{ env.debug_suffix }}" = "-debug" ]; then
echo "cppflags=-DENABLE_PATH_CHECK=0 -DRUBY_DEBUG=1" >> $GITHUB_ENV
echo "optflags=-O3 -fno-inline" >> $GITHUB_ENV
fi
- name: Build docker image
run: |-
rake docker:build ruby_version=${{ env.ruby_version }} \
ubuntu_version=${{ env.ubuntu_version }} \
arch=linux/${{ matrix.arch }} \
image_version_suffix=${{ env.debug_suffix }}${{ env.dev_suffix }} \
nightly=${{ env.nightly }} \
tag_suffix=${{ env.tag_suffix }} \
optflags="${{ env.optflags }}" \
cppflags="${{ env.cppflags }}" \
target=${{ env.target }} \
- name: List images
run: docker images
- name: Push docker image to rubylang
if: "${{ env.push_tags }}"
run: |-
push_tags="${{ env.push_tags }}"
for tag in $push_tags; do
docker push rubylang/ruby:$tag
done
- name: Push docker image to ghcr.io/ruby
if: "${{ env.push_tags }}"
run: |-
push_tags="${{ env.push_tags }}"
for tag in $push_tags; do
docker tag rubylang/ruby:$tag ghcr.io/ruby/ruby:$tag
docker push ghcr.io/ruby/ruby:$tag
done
- uses: ruby/action-slack@54175162371f1f7c8eb94d7c8644ee2479fcd375 # v3.2.2
with:
payload: |
{
"attachments": [{
"text": "${{ job.status }}: ${{ matrix.ubuntu_version }} ${{ matrix.arch }} ${{ matrix.debug_suffix }} ${{ matrix.dev_suffix }} <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.workflow }}>",
"color": "danger"
}]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: failure()
deploy_multiarch:
strategy:
matrix:
registry_name: [ rubylang, ghcr.io/ruby ]
ubuntu_version:
- noble
- jammy
- focal
image_version_suffix: [ '', '-dev', '-debug', '-debug-dev' ]
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}
if: ${{ matrix.registry_name == 'rubylang' }}
- uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USER }}
password: ${{ secrets.GHCR_ACCESS_TOKEN }}
if: ${{ matrix.registry_name == 'ghcr.io/ruby' }}
- name: Create manifest for ${{ matrix.registry_name }}
run: |-
rake docker:manifest:create \
registry_name="${{ matrix.registry_name }}" \
ruby_version="${{ env.ruby_version }}" \
ubuntu_version="${{ matrix.ubuntu_version }}" \
architectures="amd64 arm64" \
manifest_suffix=${{ github.sha }} \
image_version_suffix=${{ matrix.image_version_suffix }}
- name: Push manifest to ${{ matrix.registry_name }}
run: |-
rake docker:manifest:push \
registry_name="${{ matrix.registry_name }}" \
ruby_version="${{ env.ruby_version }}" \
ubuntu_version="${{ matrix.ubuntu_version }}" \
image_version_suffix=${{ matrix.image_version_suffix }}
- uses: ruby/action-slack@54175162371f1f7c8eb94d7c8644ee2479fcd375 # v3.2.2
with:
payload: |
{
"attachments": [{
"text": "${{ job.status }}: ${{ matrix.registry_name }} ${{ matrix.ubuntu_version }} ${{ matrix.image_version_suffix }} <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.workflow }}>",
"color": "danger"
}]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: failure()