-
Notifications
You must be signed in to change notification settings - Fork 0
289 lines (249 loc) · 8.59 KB
/
main.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
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
name: Main Linux Workflow
on:
push:
branches:
- release*
tags:
- v*
pull_request:
types: [opened, synchronize, reopened, labeled]
branches:
- main
paths-ignore:
- "**/*.md"
schedule:
- cron: "0 0 * * *" # nightly build
workflow_dispatch: # manual trigger
jobs:
build-x86_64:
if: "github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'linux')"
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04]
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- name: Install
shell: bash
run: scripts/install.sh -m local-install
- name: Pack
shell: bash
run: scripts/pack.sh -o home-cli-x86_64.run
- name: Uninstall
shell: bash
run: scripts/uninstall.sh
- name: Unpack
shell: bash
run: bash ./home-cli-x86_64.run -- -m install --install-dir ${{ github.workspace }}/home-cli-x86_64
- uses: actions/upload-artifact@v3
with:
name: home-cli-pack-x86_64
path: home-cli-x86_64.run
build-arm64:
if: "github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'linux')"
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04]
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- uses: uraimo/run-on-arch-action@v2
name: Run commands
with:
arch: aarch64
distro: ubuntu20.04
# Mount the artifacts directory as /artifacts in the container
dockerRunArgs: |
--volume "${PWD}:/workspace"
env: |
HOMECLI_PRINT_PROGRESS: false
install: |
apt update -y
apt install -y python3 python3-pip curl libfuse-dev git
# Set an output parameter `uname` for use in subsequent steps
run: |
uname -a
cd /workspace
scripts/install.sh -m local-install
scripts/pack.sh -o home-cli-arm64.run
scripts/uninstall.sh
bash home-cli-arm64.run -- -m install --install-dir /workspace/home-cli-arm64
- uses: actions/upload-artifact@v3
with:
name: home-cli-pack-arm64
path: home-cli-arm64.run
pre-release:
runs-on: ubuntu-20.04
if: github.event_name == 'workflow_dispatch' || github.event_name == 'schedule'
needs:
- build-x86_64
- build-arm64
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 0 # Ensure we have access to all commit history
- name: Set up Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Fetch all tags and branches
run: |
git fetch --all
- name: Check if nightly tag is on the latest main commit
id: check_nightly
run: |
# Get the latest commit hash on the main branch
MAIN_LATEST=$(git rev-parse origin/main)
# Get the commit hash of the nightly tag, if it exists
if git rev-parse nightly >/dev/null 2>&1; then
NIGHTLY_COMMIT=$(git rev-parse nightly)
else
NIGHTLY_COMMIT=""
fi
# Compare the hashes
if [ "$MAIN_LATEST" = "$NIGHTLY_COMMIT" ]; then
echo "Nightly tag is already up-to-date with the latest main commit."
echo "::set-output name=should_run::false"
else
echo "Nightly tag is not up-to-date with the latest main commit."
echo "::set-output name=should_run::true"
fi
- name: Delete Legacy Pre-Release
if: steps.check_nightly.outputs.should_run == 'true'
uses: actions/github-script@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data: releases } = await github.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo,
});
for (const release of releases) {
if (release.prerelease) {
await github.repos.deleteRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: release.id,
});
}
}
- name: Delete old nightly tag
if: steps.check_nightly.outputs.should_run == 'true'
run: |
if git rev-parse nightly >/dev/null 2>&1; then
git tag -d nightly
git push origin :refs/tags/nightly
else
echo "No existing nightly tag found"
fi
- name: Create new nightly tag
if: steps.check_nightly.outputs.should_run == 'true'
run: |
git tag nightly
git push origin nightly
- name: Create Pre-Release
if: steps.check_nightly.outputs.should_run == 'true'
id: create_pre_release
uses: actions/create-release@v1
with:
tag_name: nightly
release_name: Pre-Release
draft: false
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/download-artifact@v3
if: steps.check_nightly.outputs.should_run == 'true'
with:
name: home-cli-pack-x86_64
- uses: actions/download-artifact@v3
if: steps.check_nightly.outputs.should_run == 'true'
with:
name: home-cli-pack-arm64
- name: Upload Pre-Release Assets x86_64
if: steps.check_nightly.outputs.should_run == 'true'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_pre_release.outputs.upload_url }}
asset_path: ./home-cli-x86_64.run
asset_name: home-cli-x86_64.run
asset_content_type: application/octet-stream
- name: Upload Pre-Release Assets arm64
if: steps.check_nightly.outputs.should_run == 'true'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_pre_release.outputs.upload_url }}
asset_path: ./home-cli-arm64.run
asset_name: home-cli-arm64.run
asset_content_type: application/octet-stream
release:
runs-on: ubuntu-20.04
needs:
- build-x86_64
- build-arm64
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Create Release
id: create_release
uses: actions/create-release@v1
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/download-artifact@v3
with:
name: home-cli-pack-x86_64
- uses: actions/download-artifact@v3
with:
name: home-cli-pack-arm64
- name: Upload Assets x86_64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./home-cli-x86_64.run
asset_name: home-cli-x86_64.run
asset_content_type: application/octet-stream
- name: Upload Assets arm64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./home-cli-arm64.run
asset_name: home-cli-arm64.run
asset_content_type: application/octet-stream
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install huggingface_hub
- name: Authenticate with Hugging Face
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: |
huggingface-cli login --token $HF_TOKEN --add-to-git-credential
- name: Upload file to Hugging Face
run: |
huggingface-cli upload BrightXiaoHan/HOME home-cli-x86_64.run home-cli-x86_64.run
huggingface-cli upload BrightXiaoHan/HOME home-cli-arm64.run home-cli-arm64.run
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}