-
-
Notifications
You must be signed in to change notification settings - Fork 35
145 lines (127 loc) · 4.81 KB
/
docker.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
---
name: Build and push docker images
on:
workflow_dispatch:
push:
tags:
- "v*"
branches:
- "main"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
packages: write
jobs:
docker_images:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
- ruby_target: x86_64-linux
- ruby_target: x86_64-linux-musl
- ruby_target: aarch64-linux
- ruby_target: aarch64-linux-musl
- ruby_target: arm-linux
- ruby_target: x86_64-darwin
- ruby_target: arm64-darwin
- ruby_target: x64-mingw32
- ruby_target: x64-mingw-ucrt
# - ruby_target: x86-mingw32
# - ruby_target: x86-linux
steps:
- uses: actions/checkout@v4
- name: Set rb-sys version variable
id: vars
run: |
version="$(ruby -r $PWD/gem/lib/rb_sys/version.rb -e 'puts RbSys::VERSION')"
echo "rb-sys-version=$version" >> $GITHUB_OUTPUT
# Test the container
- uses: actions/checkout@v4
with:
repository: "oxidize-rb/oxi-test"
path: "tmp/oxi-test"
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.1"
- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ secrets.DOCKER_HUB_USERNAME }}/${{ matrix.platform.ruby_target }}
flavor: |
latest=auto
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=sha,format=long
labels:
org.opencontainers.image.description=Image for building native Rust extensions for Ruby on ${{ matrix.platform.ruby_target }}
org.opencontainers.image.vendor=oxidize-rb
org.oxidize-rb.ruby.platform=${{ matrix.platform.ruby_target }}
- name: Docker build
uses: docker/build-push-action@v5
with:
builder: ${{ steps.buildx.outputs.name }}
context: ./docker
file: ./docker/Dockerfile.${{ matrix.platform.ruby_target }}
platforms: linux/amd64
load: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: ${{ secrets.DOCKER_HUB_USERNAME }}/${{ matrix.platform.ruby_target }}:cache-${{ steps.vars.outputs.rb-sys-version }}
cache-to: ${{ secrets.DOCKER_HUB_USERNAME }}/${{ matrix.platform.ruby_target }}:cache-${{ steps.vars.outputs.rb-sys-version }}
- name: Run tests
run: |
sudo chmod 777 tmp/oxi-test
cd tmp/oxi-test
gem install rb_sys
cargo update -p rb-sys
cargo update -p rb-sys-build
cargo update -p rb-sys-env
export RB_SYS_DOCK_UID=$(id -u)
export RB_SYS_DOCK_GID=$(id -g)
export RCD_IMAGE=${{ secrets.DOCKER_HUB_USERNAME }}/${{ matrix.platform.ruby_target }}:sha-${{ github.sha }}
rb-sys-dock --platform ${{ matrix.platform.ruby_target }} --build --version "sha-$GITHUB_SHA"
- name: Docker push
uses: docker/build-push-action@v5
with:
builder: ${{ steps.buildx.outputs.name }}
context: ./docker
file: ./docker/Dockerfile.${{ matrix.platform.ruby_target }}
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: ${{ secrets.DOCKER_HUB_USERNAME }}/${{ matrix.platform.ruby_target }}:cache-${{ steps.vars.outputs.rb-sys-version }}
cache-to: ${{ secrets.DOCKER_HUB_USERNAME }}/${{ matrix.platform.ruby_target }}:cache-${{ steps.vars.outputs.rb-sys-version }}
- name: Docker Hub Description
uses: peter-evans/dockerhub-description@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
repository: rbsys/${{ matrix.platform.ruby_target }}
readme-filepath: ./readme.md
- name: Slack Noti on Failure
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: repo,message,commit,author,action,eventName,ref,workflow,job,took,pullRequest
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: failure()