forked from lf-edge/eve
-
Notifications
You must be signed in to change notification settings - Fork 0
146 lines (145 loc) · 5.56 KB
/
assets.yml
File metadata and controls
146 lines (145 loc) · 5.56 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
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
---
name: Release Assets
on: # yamllint disable-line rule:truthy
workflow_call:
inputs:
tag_ref:
required: true
type: string
jobs:
create_release:
runs-on: zededa-ubuntu-2204
outputs:
release_id: ${{ steps.create_release.outputs.release_id }}
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Create GitHub Release
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
response=$(curl -s -X POST \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"tag_name": "${{ inputs.tag_ref }}",
"name": "${{ inputs.tag_ref }}",
"draft": false,
"prerelease": true
}' https://api.github.com/repos/${{ github.repository }}/releases)
release_id=$(echo "$response" | jq -r .id)
upload_url=$(echo "$response" | jq -r .upload_url | sed -e "s/{?name,label}//")
echo $upload_url
echo "release_id=$release_id" >> "$GITHUB_OUTPUT"
echo "upload_url=$upload_url" >> "$GITHUB_OUTPUT"
build:
runs-on: zededa-ubuntu-2204
needs: create_release
strategy:
fail-fast: false
matrix:
arch: [amd64, arm64]
platform: ["generic"]
hv: ["kvm"]
include:
- arch: arm64
platform: "nvidia-jp5"
hv: "kvm"
- arch: arm64
platform: "nvidia-jp6"
hv: "kvm"
- arch: amd64
platform: "generic"
hv: "kubevirt"
steps:
- name: checkout repo
uses: actions/checkout@v4
with:
ref: ${{ inputs.tag_ref }}
fetch-depth: 0
- name: Force fetch annotated tags (workaround)
# Workaround for https://github.com/actions/checkout/issues/290
run: |
git fetch --force --tags
- name: Determine architecture prefix and ref
env:
REF: ${{ inputs.tag_ref }}
run: |
echo "ARCH=${{ matrix.arch }}" >> "$GITHUB_ENV"
if [ "${{ matrix.platform }}" != "generic" ]; then
echo "PLATFORMVER=${{ matrix.platform }}-" >> "$GITHUB_ENV"
else
echo "PLATFORMVER=" >> "$GITHUB_ENV"
fi
echo "TAG=$(git describe --always --tags | grep -E '[0-9]+\.[0-9]+\.[0-9]' || echo snapshot)" >> "$GITHUB_ENV"
- name: Ensure clean assets directory
run: |
rm -rf assets && mkdir -p assets
- name: Pull the EVE release from DockerHUB or build it
run: |
HV=${{ matrix.hv }}
if [ "${{ github.event.repository.full_name }}" = "lf-edge/eve" ]; then
EVE=10.208.13.132/lfedge/eve:${TAG}-${{ env.PLATFORMVER }}${HV}-${{ env.ARCH }}
docker pull "$EVE"
else
make pkgs
make HV=${HV} ZARCH=${{ env.ARCH }} PLATFORM=${{ matrix.platform }} eve
EVE=10.208.13.132/lfedge/eve:$(make version)-${{ env.PLATFORMVER }}${HV}-${{ env.ARCH }}
fi
echo "EVE=$EVE" >> "$GITHUB_ENV"
- name: Generate EVE binary assets
run: |
docker run "$EVE" rootfs > assets/rootfs.img
docker run "$EVE" installer_raw > assets/installer.raw
docker run "$EVE" live > assets/live.raw
if [ "${{ matrix.platform }}" == "generic" ]; then
docker run "$EVE" installer_iso > assets/installer.iso
docker run "$EVE" installer_net > assets/installer-net.tar
fi
- name: Pull eve-sources and publish collected_sources.tar.gz to assets
run: |
HV=${{ matrix.hv }}
EVE_SOURCES=10.208.13.132/lfedge/eve-sources:${TAG}-${{ env.PLATFORMVER }}${HV}-${{ env.ARCH }}
docker pull "$EVE_SOURCES"
docker create --name eve_sources "$EVE_SOURCES" bash
docker export --output assets/collected_sources.tar.gz eve_sources
docker rm eve_sources
- name: Rename, create SHA256 checksums and upload files
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_ID: ${{ needs.create_release.outputs.release_id }}
UPLOAD_URL: ${{ needs.create_release.outputs.upload_url }}
run: |
# Rename all files
HV=${{ matrix.hv }}
for file in assets/*; do
base_name=$(basename "$file")
# Add ARCH + platform prefix
new_name="${ARCH}.${HV}.${{ matrix.platform }}.${base_name}"
# Rename the file
mv "$file" "assets/$new_name"
done
# Create sha256sums file and summary of file sizes
sha256_file="${ARCH}.${HV}.${{ matrix.platform }}.sha256sums"
sizes_file="${ARCH}.${HV}.${{ matrix.platform }}.sizes"
cd assets/
sha256sum * > "../$sha256_file"
du -b * > "../$sizes_file"
cd ../
mv "$sha256_file" assets/
mv "$sizes_file" assets/
# Upload files
for file in assets/*; do
file_name=$(basename $file)
echo "Uploading ${file_name}..."
upload_response=$(curl -s -X POST \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Content-Type: application/octet-stream" \
-T "$file" \
"$UPLOAD_URL?name=$file_name")
if echo "$upload_response" | jq -e .id > /dev/null; then
echo "$file_name uploaded successfully."
else
echo "Error uploading $file_name: $upload_response"
fi
done