Repository navigation
87 lines (81 loc) · 2.88 KB
/
Copy pathdocker-build.yaml
File metadata and controls
87 lines (81 loc) · 2.88 KB
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
name: docker-build
on:
workflow_dispatch:
inputs:
package_name:
description: 'SkyPilot PyPI package name'
required: true
type: choice
options:
- 'skypilot-nightly'
- 'skypilot'
default: 'skypilot-nightly'
version:
description: 'SkyPilot version to build (optional, uses latest from PyPI if not specified)'
required: false
type: string
workflow_call:
inputs:
package_name:
description: 'SkyPilot PyPI package name'
required: true
type: string
version:
description: 'SkyPilot version to build (optional, uses latest from PyPI if not specified)'
required: false
type: string
outputs:
version:
description: "The version fetched from PyPI"
value: ${{ jobs.build.outputs.version }}
secrets:
DOCKER_USERNAME:
required: true
DOCKER_PASSWORD:
required: true
jobs:
build:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.latest_version }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Find the release version
id: version
run: |
if [ -n "${{ inputs.version }}" ]; then
# Use the provided version
echo "Using provided version: ${{ inputs.version }}"
echo "latest_version=${{ inputs.version }}" >> $GITHUB_OUTPUT
else
# Fetch package info from PyPI
echo "Fetching package info for ${{ inputs.package_name }}"
PACKAGE_INFO=$(curl -s https://pypi.org/pypi/${{ inputs.package_name }}/json)
# Parse JSON and get the latest version
LATEST_VERSION=$(echo $PACKAGE_INFO | jq -r '.info.version')
echo "Latest version found: $LATEST_VERSION"
echo "latest_version=$LATEST_VERSION" >> $GITHUB_OUTPUT
fi
cat $GITHUB_OUTPUT
- name: Update Dockerfile version
run: |
sed -i 's/skypilot-nightly\[all\]/${{ inputs.package_name }}[all]==${{ steps.version.outputs.latest_version }}/g' Dockerfile
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: "${{ secrets.DOCKER_USERNAME }}/${{ inputs.package_name }}:latest,${{ secrets.DOCKER_USERNAME }}/${{ inputs.package_name }}:${{ steps.version.outputs.latest_version }}"
cache-from: type=gha
cache-to: type=gha,mode=max