-
-
Notifications
You must be signed in to change notification settings - Fork 4
121 lines (108 loc) · 4.62 KB
/
toolchain.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
on:
push:
paths:
- ".github/workflows/toolchain.yml"
- "Dockerfile.toolchain"
- "config.mak"
branches:
- main
## ##
## To trigger this workflow using `act` (https://github.com/nektos/act) you can do the following.
## Full run
## act push -j toolchain
## ##
name: Build Toolchains
jobs:
toolchain:
name: Build Toolchain - ${{ matrix.env.IMAGE_TAG }}
runs-on: ubuntu-22.04
env:
HAVE_DOCKERHUB_LOGIN: ${{ secrets.DOCKERHUB_USERNAME != '' && secrets.DOCKERHUB_TOKEN != '' }}
HAVE_GHCR_LOGIN: ${{ github.repository_owner != '' && secrets.GITHUB_TOKEN != '' }}
HAVE_QUAY_LOGIN: ${{ secrets.QUAY_USERNAME != '' && secrets.QUAY_TOKEN != '' }}
if: ${{ github.repository == 'BlackDex/rust-musl' }}
strategy:
# max-parallel: 1 # Use this when using `act`, since this could use a lot of memory
matrix:
# ARCH_COMMON_CONFIG are based upon the `"COMMON_CONFIG +=` additions extracted
# from the MUSL Dockerfiles here: https://github.com/rust-embedded/cross/tree/master/docker
env:
- IMAGE_TAG: x86_64-musl
TARGET: x86_64-unknown-linux-musl
- IMAGE_TAG: aarch64-musl
TARGET: aarch64-unknown-linux-musl
- IMAGE_TAG: armv7-musleabihf
TARGET: armv7-unknown-linux-musleabihf
ARCH_COMMON_CONFIG: "--with-arch=armv7-a --with-float=hard --with-mode=thumb --with-fpu=vfp"
- IMAGE_TAG: arm-musleabi
TARGET: arm-unknown-linux-musleabi
ARCH_COMMON_CONFIG: "--with-arch=armv6 --with-float=soft --with-mode=arm"
steps:
- name: Checkout Repo
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
# This action is messing with the host caching when using `act`
- name: Setup Docker Buildx (setup-buildx-action)
if: ${{ !env.ACT }}
uses: docker/setup-buildx-action@aa33708b10e362ff993539393ff100fa93ed6a27 # v3.5.0
with:
driver-opts: |
network=host
# Use the DOCKER_BUILDKIT=1 env when using `act`
- name: Setup Docker Buildx (DOCKER_BUILDKIT=1)
if: ${{ env.ACT }}
shell: bash
run: |
echo "DOCKER_BUILDKIT=1" | tee -a "${GITHUB_ENV}"
- name: Determine Container Date Tag
shell: bash
run: |
# Get the current date
echo "TAG_DATE=$(date +'-%Y-%m-%d')" | tee -a "${GITHUB_ENV}"
- name: Login to DockerHub
if: ${{ env.HAVE_DOCKERHUB_LOGIN == 'true' }}
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Tags for DockerHub
if: ${{ env.ACT || env.HAVE_DOCKERHUB_LOGIN == 'true' }}
shell: bash
run: |
echo "tags=blackdex/musl-toolchain:${{ matrix.env.IMAGE_TAG }},blackdex/musl-toolchain:${{ matrix.env.IMAGE_TAG }}${TAG_DATE}" \
| tee -a "${GITHUB_ENV}"
- name: Login to ghcr.io
if: ${{ env.HAVE_GHCR_LOGIN == 'true' }}
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Tags for ghcr.io
if: ${{ env.ACT || env.HAVE_GHCR_LOGIN == 'true' }}
shell: bash
run: |
echo "tags=${tags:+${tags},}ghcr.io/blackdex/musl-toolchain:${{ matrix.env.IMAGE_TAG }},ghcr.io/blackdex/musl-toolchain:${{ matrix.env.IMAGE_TAG }}${TAG_DATE}" \
| tee -a "${GITHUB_ENV}"
- name: Login to quay.io
if: ${{ env.HAVE_QUAY_LOGIN == 'true' }}
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_TOKEN }}
- name: Tags for quay.io
if: ${{ env.ACT || env.HAVE_QUAY_LOGIN == 'true' }}
shell: bash
run: |
echo "tags=${tags:+${tags},}quay.io/blackdex/musl-toolchain:${{ matrix.env.IMAGE_TAG }},quay.io/blackdex/musl-toolchain:${{ matrix.env.IMAGE_TAG }}${TAG_DATE}" \
| tee -a "${GITHUB_ENV}"
- name: Docker Build
uses: docker/build-push-action@5176d81f87c23d6fc96624dfdbcd9f3830bbe445 # v6.5.0
with:
context: .
file: ./Dockerfile.toolchain
build-args: |
TARGET=${{ matrix.env.TARGET }}
ARCH_COMMON_CONFIG=${{ matrix.env.ARCH_COMMON_CONFIG }}
tags: ${{ env.tags }}
push: ${{ !env.ACT }}