-
-
Notifications
You must be signed in to change notification settings - Fork 0
141 lines (117 loc) · 4.22 KB
/
build.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
name: Build Isos
on:
workflow_dispatch:
jobs:
build-arm:
runs-on: [self-hosted, ARM64, BredOS]
strategy:
fail-fast: false
matrix:
iso: [mainline-iso]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: iso
- name: Install dependencies
run: |
sudo pacman -Sy --noconfirm --needed \
arch-install-scripts bash dosfstools e2fsprogs erofs-utils libarchive libisoburn mtools squashfs-tools grub
- name: Build ISO
run: |
sudo umount -R ./work/aarch64/* || true
sudo rm -rf /var/lib/pacman/db.lck ./out ./work
sudo ./iso/mkarchiso -v -w ./work -o ./out ./iso/${{ matrix.iso }}
- name: Send image to release job
run: |
scp out/*.iso $RELEASE_VM:/images/
env:
RELEASE_VM: ${{ secrets.RELEASE_VM }}
- name: Cleanup
if: always()
run: |
sudo umount -R ./work/aarch64/* || true
sudo rm -rf ./work ./out
build-x86:
runs-on: ubuntu-latest
container:
image: bredos/bredos:latest
ports:
- 80
options: --privileged
strategy:
fail-fast: false
matrix:
iso: [x86-iso]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: iso
- name: Install dependencies
run: |
init-docker
sudo pacman -Sy --noconfirm --needed \
arch-install-scripts bash dosfstools e2fsprogs erofs-utils libarchive libisoburn mtools squashfs-tools grub
- name: Build ISO
run: |
sudo ./iso/mkarchiso -v -w ./work -o ./out ./iso/${{ matrix.iso }}
- name: Send image to release job
run: |
echo "$SSH_KEY" > /tmp/.ssh/deploy_key
chmod 600 /tmp/.ssh/deploy_key
scp -i /tmp/.ssh/deploy_key -o StrictHostKeyChecking=no out/*.iso "$RELEASE_VM:/images/"
env:
SSH_KEY: ${{ secrets.SSH_KEY }}
RELEASE_VM: ${{ secrets.RELEASE_VM }}
- name: Cleanup
if: always()
run: |
sudo rm -rf ./work ./out
release:
if: always()
needs: [build-arm, build-x86]
runs-on: [self-hosted, ARM64, BredOS, emag]
steps:
- name: Set current date as tag name
id: set_tag_name
run: echo "TAG_NAME=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
- name: Create Release and Upload Each iso Individually
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
TAG_NAME: ${{ env.TAG_NAME }}
run: |
# Initialize the release body with MD5 checksums
RELEASE_BODY="MD5 Checksums:\n"
# Calculate MD5 for each iso and add it to RELEASE_BODY
for img in /images/*.iso; do
FILENAME=$(basename "$img")
MD5SUM=$(md5sum "$img" | awk '{print $1}')
RELEASE_BODY+="$FILENAME: $MD5SUM\n"
done
# Create a draft release with the MD5 checksums in the body
RELEASE_RESPONSE=$(curl -s -X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"tag_name\": \"$TAG_NAME\", \"name\": \"$TAG_NAME\", \"body\": \"$RELEASE_BODY\", \"draft\": false, \"prerelease\": true}" \
"https://api.github.com/repos/$REPO/releases")
RELEASE_ID=$(echo $RELEASE_RESPONSE | jq -r '.id')
if [ "$RELEASE_ID" == "null" ]; then
echo "Failed to create a release. Response: $RELEASE_RESPONSE"
exit 1
fi
# Upload each image file to the release
for img in /images/*.iso; do
FILENAME=$(basename "$img")
echo "Uploading $FILENAME to release $RELEASE_ID"
curl -s \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: application/octet-stream" \
-T "$img" \
"https://uploads.github.com/repos/$REPO/releases/$RELEASE_ID/assets?name=$FILENAME"
done
- name: Clean up
if: always()
run: |
rm -rf ./out/ /images/*.img.xz