-
Notifications
You must be signed in to change notification settings - Fork 232
105 lines (93 loc) · 3.36 KB
/
Container.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
name: Publish Docker image
on:
workflow_dispatch:
inputs:
tag:
description: 'Tag to build instead'
required: false
default: ''
mark_as_latest:
description: 'Mark as latest'
type: boolean
required: false
default: false
push:
tags:
- 'v*'
branches:
- master
jobs:
push_to_registry:
name: Build container - Julia ${{ matrix.julia }} - CUDA ${{ matrix.cuda }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
julia: ["1.10", "1.11"]
cuda: ["11.8", "12.6"]
include:
- julia: "1.11"
cuda: "12.6"
default: true
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Check out the package
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || github.ref_name }}
path: package
- name: Get package spec
id: pkg
run: |
if [[ -n "${{ inputs.tag }}" ]]; then
echo "ref=${{ inputs.tag }}" >> $GITHUB_OUTPUT
echo "name=${{ inputs.tag }}" >> $GITHUB_OUTPUT
elif [[ "${{ github.ref_type }}" == "tag" ]]; then
echo "ref=${{ github.ref_name }}" >> $GITHUB_OUTPUT
echo "name=${{ github.ref_name }}" >> $GITHUB_OUTPUT
else
echo "ref=${{ github.sha }}" >> $GITHUB_OUTPUT
echo "name=dev" >> $GITHUB_OUTPUT
fi
VERSION=$(grep "^version = " package/Project.toml | cut -d'"' -f2)
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Get CUDA major version
id: cuda
run: |
CUDA_MAJOR=$(echo ${{ matrix.cuda }} | cut -d'.' -f1)
echo "major=${CUDA_MAJOR}" >> $GITHUB_OUTPUT
- name: Log in to registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=raw,value=${{ steps.pkg.outputs.name }}-julia${{ matrix.julia }}-julia${{ steps.cuda.outputs.major }}
type=raw,value=${{ steps.pkg.outputs.name }},enable=${{ matrix.default == true && (github.ref_type == 'tag' || inputs.tag != '') }}
type=raw,value=latest,enable=${{ matrix.default == true && (github.ref_type == 'tag' || (inputs.tag != '' && inputs.mark_as_latest)) }}
type=raw,value=dev,enable=${{ matrix.default == true && github.ref_type == 'branch' && inputs.tag == '' }}
labels: |
org.opencontainers.image.version=${{ steps.pkg.outputs.version }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push image
uses: docker/build-push-action@v6
with:
context: .
push: true
provenance: false # the build fetches the repo again, so provenance tracking is not useful
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
JULIA_VERSION=${{ matrix.julia }}
CUDA_VERSION=${{ matrix.cuda }}
PACKAGE_SPEC=CUDA#${{ steps.pkg.outputs.ref }}