-
Notifications
You must be signed in to change notification settings - Fork 78
175 lines (156 loc) · 4.9 KB
/
ci.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
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
name: CI
permissions:
actions: read
checks: read
contents: write
deployments: read
id-token: write
issues: write
packages: read
pages: read
pull-requests: write
repository-projects: read
on:
pull_request:
push:
branches:
- main
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
env:
GH_TOKEN: ${{ github.token }}
ONNXRUNTIME_BUILD_DIR: ".onnxruntime"
jobs:
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
with:
components: clippy
- run: cargo clippy
unit-test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-2022, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- run: cargo test --no-default-features --features onnxruntime-from-source
smoke-test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-2022, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- run: cargo run --release --no-default-features --features onnxruntime-from-source -- 'Create a LoFi song' --secs 1 --model small-quant --no-interactive --no-playback
tag:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs:
- unit-test
- clippy
- smoke-test
steps:
- uses: actions/checkout@v4
with:
fetch-depth: '0' # https://github.com/actions/checkout/issues/217
- uses: ./.github/actions/setup
- run: cargo install cargo-release
- run: cargo release version $(.github/semver.sh) -x --no-confirm
- name: Tag
id: tag
run: |
version=`grep '^version = ' Cargo.toml | sed 's/version = //; s/\"//; s/\"//'`
git config user.name github-actions
git config user.email [email protected]
git add .
git commit -m "ci: v$version"
git tag "v$version"
git push
git push --tags
echo "version=$version" >> "$GITHUB_OUTPUT"
- run: gh release create "v${{ steps.tag.outputs.version }}"
outputs:
version: ${{ steps.tag.outputs.version }}
cargo-release:
needs: tag
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
docker-release:
needs: tag
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
with:
username: gabotechs
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- uses: docker/build-push-action@v4
with:
context: .
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64
tags: gabotechs/musicgpt:${{ needs.tag.outputs.version }},gabotechs/musicgpt:latest
homebrew-release:
needs: tag
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
repository: gabotechs/homebrew-taps
token: ${{ secrets.CI_TOKEN }}
- uses: actions/checkout@v4
with:
path: repo
- run: sed "s/<version>/${{ needs.tag.outputs.version }}/g" repo/.github/musicgpt.rb > musicgpt.rb
- run: |
git add musicgpt.rb
git config user.name github-actions
git config user.email [email protected]
git commit -m "Brew formula update for musicgpt version v${{ needs.tag.outputs.version }}"
git push
upload:
needs: tag
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: macos-latest
target: aarch64-apple-darwin
- os: windows-2022
target: x86_64-pc-windows-msvc
runs-on: ${{ matrix.os }}
env:
BUILD_HASH_FILE: 'build-hash.txt'
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
with:
targets: ${{ matrix.target }}
# Need to set the version manually here, even if it was set in the "tag" job before, that change
# does not propagate to further jobs.
- if: runner.os == 'macOS'
run: sed -i '' 's/^version = ".*"/version = "${{ needs.tag.outputs.version }}"/' Cargo.toml
- if: runner.os != 'macOS'
run: sed -i 's/^version = ".*"/version = "${{ needs.tag.outputs.version }}"/' Cargo.toml
- run: cargo build --no-default-features --release --target ${{ matrix.target }} --features onnxruntime-from-source
- run: .github/upload-artifacts.sh ${{ matrix.target }} ${{ needs.tag.outputs.version }}
shell: bash