forked from cocogitto/cocogitto
-
Notifications
You must be signed in to change notification settings - Fork 0
209 lines (176 loc) · 7.45 KB
/
Deploy.yaml
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
name: Publish latest
on:
push:
branches:
- main
tags:
- '*'
env:
CARGO_TERM_COLOR: always
jobs:
upload_license:
name: Upload License
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/upload-artifact@v3
with:
name: LICENSE
path: LICENSE
build:
name: Build cog ${{ matrix.os }}-${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: macos-latest
target: x86_64-apple-darwin
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
- os: windows-latest
target: x86_64-pc-windows-msvc
windows: true
- os: ubuntu-latest
target: armv7-unknown-linux-musleabihf
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
cache-all-crates: "true"
key: "${{ matrix.os }}-${{ matrix.target }}"
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
- if: ${{ matrix.windows }}
uses: actions-rs/cargo@v1
with:
command: build
args: --target ${{ matrix.target }} --release --locked
- if: ${{ ! matrix.windows }}
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --target ${{ matrix.target }} --release --locked
- if: ${{ ! matrix.windows }}
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.target }}
path: target/${{ matrix.target }}/release/cog
- if: ${{ matrix.windows }}
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.target }}
path: target/${{ matrix.target }}/release/cog.exe
upload_to_release:
needs: [ build, upload_license]
name: Publish cog binaries
runs-on: ubuntu-latest
if: ${{ github.ref_type == 'tag' }}
steps:
- uses: actions/download-artifact@v3
with:
path: ~/artifacts
- name: Copy artifacts to archive
run: |
mkdir x86_64-unknown-linux-musl
cp -r /home/runner/artifacts/x86_64-unknown-linux-musl/cog x86_64-unknown-linux-musl/cog
chmod +x -R x86_64-unknown-linux-musl/cog
cp -r /home/runner/artifacts/LICENSE/LICENSE x86_64-unknown-linux-musl/
tar -czf cocogitto-x86_64-unknown-linux-musl.tar.gz x86_64-unknown-linux-musl/*
mkdir armv7-unknown-linux-musleabihf
cp -r /home/runner/artifacts/armv7-unknown-linux-musleabihf/cog armv7-unknown-linux-musleabihf/cog
chmod +x -R armv7-unknown-linux-musleabihf/cog
cp -r /home/runner/artifacts/LICENSE/LICENSE armv7-unknown-linux-musleabihf/
tar -czf cocogitto-armv7-unknown-linux-musleabihf.tar.gz armv7-unknown-linux-musleabihf/*
mkdir aarch64-unknown-linux-gnu
cp -r /home/runner/artifacts/aarch64-unknown-linux-gnu/cog aarch64-unknown-linux-gnu/cog
chmod +x -R aarch64-unknown-linux-gnu/cog
cp -r /home/runner/artifacts/LICENSE/LICENSE aarch64-unknown-linux-gnu/
tar -czf cocogitto-aarch64-unknown-linux-gnu.tar.gz aarch64-unknown-linux-gnu/*
mkdir x86_64-pc-windows-msvc
cp -r /home/runner/artifacts/x86_64-pc-windows-msvc/cog.exe x86_64-pc-windows-msvc/cog.exe
chmod +x -R x86_64-pc-windows-msvc/cog.exe
cp -r /home/runner/artifacts/LICENSE/LICENSE x86_64-pc-windows-msvc/
tar -czf cocogitto-x86_64-pc-windows-msvc.tar.gz x86_64-pc-windows-msvc/*
mkdir x86_64-apple-darwin
cp -r /home/runner/artifacts/x86_64-apple-darwin/cog x86_64-apple-darwin/cog
chmod +x -R x86_64-apple-darwin/cog
cp -r /home/runner/artifacts/LICENSE/LICENSE x86_64-apple-darwin/
tar -czf cocogitto-x86_64-apple-darwin.tar.gz x86_64-apple-darwin/*
- uses: svenstaro/upload-release-action@v1-release
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: cocogitto-x86_64-unknown-linux-musl.tar.gz
tag: ${{ github.ref }}
asset_name: cocogitto-${{ github.ref_name }}-x86_64-unknown-linux-musl.tar.gz
- uses: svenstaro/upload-release-action@v1-release
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: cocogitto-armv7-unknown-linux-musleabihf.tar.gz
tag: ${{ github.ref_name }}
asset_name: cocogitto-${{ github.ref_name }}-armv7-unknown-linux-musleabihf.tar.gz
- uses: svenstaro/upload-release-action@v1-release
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: cocogitto-aarch64-unknown-linux-gnu.tar.gz
tag: ${{ github.ref_name }}
asset_name: cocogitto-${{ github.ref_name }}-aarch64-unknown-linux-gnu.tar.gz
- uses: svenstaro/upload-release-action@v1-release
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: cocogitto-x86_64-pc-windows-msvc.tar.gz
tag: ${{ github.ref_name }}
asset_name: cocogitto-${{ github.ref_name }}-x86_64-pc-windows-msvc.tar.gz
- uses: svenstaro/upload-release-action@v1-release
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: cocogitto-x86_64-apple-darwin.tar.gz
tag: ${{ github.ref_name }}
asset_name: cocogitto-${{ github.ref_name }}-x86_64-apple-darwin.tar.gz
docker:
needs: [ build ]
name: Docker publish cog:lastest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/download-artifact@v3
with:
path: ~/artifacts
- name: Copy artifacts to build dir
run: |
mkdir -p target/x86_64-unknown-linux-musl/release/
mkdir -p target/armv7-unknown-linux-musleabihf/release/
mkdir -p target/aarch64-unknown-linux-gnu/release/
cp -r /home/runner/artifacts/x86_64-unknown-linux-musl/. target/x86_64-unknown-linux-musl/release
cp -r /home/runner/artifacts/armv7-unknown-linux-musleabihf/. target/armv7-unknown-linux-musleabihf/release
cp -r /home/runner/artifacts/aarch64-unknown-linux-gnu/. target/aarch64-unknown-linux-gnu/release
chmod +x -R target/x86_64-unknown-linux-musl/release
chmod +x -R target/armv7-unknown-linux-musleabihf/release
chmod +x -R target/aarch64-unknown-linux-gnu/release
working-directory: ./
- if: ${{ github.ref_type != 'tag' }}
name: Update multi-arch container latest
run: |
docker buildx build \
--push --platform linux/amd64,linux/arm/v7,linux/arm64/v8 \
-f docker/Dockerfile \
-t ghcr.io/cocogitto/cog:latest .
- if: ${{ github.ref_type == 'tag' }}
name: Update multi-arch container latest
run: |
docker buildx build \
--push --platform linux/amd64,linux/arm/v7,linux/arm64/v8 \
-f docker/Dockerfile \
-t ghcr.io/cocogitto/cog:${{ github.ref_name }} .