forked from frkri/ModelRunner
-
Notifications
You must be signed in to change notification settings - Fork 0
120 lines (105 loc) · 3.84 KB
/
release.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
name: Upload assets to GitHub Release and publish Docker image
on:
release:
types:
- created
env:
TAG_VERSION: ${{ github.event.release.tag_name }}
jobs:
bump-version:
name: Bump version
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Bump version in Cargo.toml and Cargo.lock
run: |
sed -i "s/^version = \".*\"/version = \"${TAG_VERSION:1}\"/" Cargo.toml
awk -v tag="${TAG_VERSION:1}" '/name = "model_runner"/{getline; sub(/version = ".+"/, "name = \"model_runner\"\nversion = \"" tag "\""); print; next}1' Cargo.lock > temp && mv temp Cargo.lock
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
branch: master
commit_message: "Release ${{ env.TAG_VERSION }}"
file_pattern: "Cargo.toml Cargo.lock"
add-release-assets:
name: Add Release assets ${{ matrix.target }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-pc-windows-gnu
archive: zip
- target: x86_64-unknown-linux-musl
archive: zip tar.gz tar.zst
# - target: x86_64-apple-darwin
# archive: zip tar.gz tar.zst
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Bump version in Cargo.toml and Cargo.lock
run: |
sed -i "s/^version = \".*\"/version = \"${TAG_VERSION:1}\"/" Cargo.toml
awk -v tag="${TAG_VERSION:1}" '/name = "model_runner"/{getline; sub(/version = ".+"/, "name = \"model_runner\"\nversion = \"" tag "\""); print; next}1' Cargo.lock > temp && mv temp Cargo.lock
- name: Compile and upload
uses: rust-build/rust-build.action@v1.4.5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
RUSTTARGET: ${{ matrix.target }}
ARCHIVE_TYPES: ${{ matrix.archive }}
image:
name: Publish docker image ${{ matrix.suffix }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
include:
- flags: "" # No optimizations
suffix: "" # '-' must be appended manually
- flags: "-C target-feature=+avx,+avx2"
suffix: "-avx"
- flags: "-C target-feature=+f16c"
suffix: "-f16c"
- flags: "-C target-feature=+avx,+avx2,+f16c"
suffix: "-avx-f16c"
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Bump version in Cargo.toml and Cargo.lock
run: |
sed -i "s/^version = \".*\"/version = \"${TAG_VERSION:1}\"/" Cargo.toml
awk -v tag="${TAG_VERSION:1}" '/name = "model_runner"/{getline; sub(/version = ".+"/, "name = \"model_runner\"\nversion = \"" tag "\""); print; next}1' Cargo.lock > temp && mv temp Cargo.lock
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
flavor: |
suffix=${{ matrix.suffix }},onlatest=true
tags: |
type=semver,pattern={{version}}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
rust_flags=${{ matrix.flags }}