This repository has been archived by the owner on Jan 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
159 lines (134 loc) · 7.02 KB
/
update-chromeos-kernel.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
name: Deploying chromeos kernel packages
on:
schedule:
- cron: "40 0 * * *" # run at the start of every day
workflow_dispatch:
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
env:
public_key: ${{ secrets.PUBLIC }}
private_key: ${{ secrets.PRIVATE }}
jobs:
check-sha:
runs-on: ubuntu-latest
outputs:
match_results: ${{ steps.check-shas.outputs.match_results }}
remote_tag: ${{ steps.check-shas.outputs.remote_tag }}
steps:
- name: Checking out repository code
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Download remote commit shas
id: check-shas
run: |
# Download remote sha
latest_tag=$(curl -s https://api.github.com/repos/eupnea-project/linux-kernels/releases/tags/latest-chromeos | jq -r '.id')
# fail if curl result is empty
if [[ "$latest_tag" = "null" ]]; then
echo "latest_tag is empty"
exit 1
fi
# Check remote tag against cached one
match_results=$([[ "$(cat cache/chromeos_kernel_tag-cache.txt)" == "$latest_tag" ]] && echo "true" || echo "false")
echo "match_results=$match_results" >> $GITHUB_OUTPUT
# Add sha to output
echo "remote_tag=$latest_tag" >> $GITHUB_OUTPUT
deploy-repo:
runs-on: ubuntu-latest
needs: check-sha # needs for the vars from the previous job
# Only run script when remote sha has changed, aka the results DON'T match
if: needs.check-sha.outputs.match_results == 'false'
steps:
- name: Checking out repository code
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Update local tag releases cache file
run: |
echo "${{ needs.check-sha.outputs.remote_tag }}" > cache/chromeos_kernel_tag-cache.txt
- name: Install pacman
run: |
# Add ubuntu 22.10 repo to sources
echo "deb http://archive.ubuntu.com/ubuntu mantic main universe" | sudo tee -a /etc/apt/sources.list
# Update apt sources
sudo apt-get update
# Install pacman-package-manager from ubuntu 22.10 repo
sudo apt-get -y install pacman-package-manager libarchive-tools
- name: Bump version in kernel pkgbuild file
run: |
CURRENT_VERSION=$(sed -n '3p' pkgbuild-files/chromeos-kernel.pkgbuild | sed 's/.*://' | xargs) # get current version from control file
NEXTVERSION=$(echo ${CURRENT_VERSION} | awk -F. -v OFS=. '{$NF += 1 ; print}') # bump version
sed -i "3s/.*/${NEXTVERSION}/" pkgbuild-files/chromeos-kernel.pkgbuild # update version in control file
- name: Bump version in modules pkgbuild file
run: |
CURRENT_VERSION=$(sed -n '3p' pkgbuild-files/chromeos-kernel-modules.pkgbuild | sed 's/.*://' | xargs) # get current version from control file
NEXTVERSION=$(echo ${CURRENT_VERSION} | awk -F. -v OFS=. '{$NF += 1 ; print}') # bump version
sed -i "3s/.*/${NEXTVERSION}/" pkgbuild-files/chromeos-kernel-modules.pkgbuild # update version in control file
- name: Bump version in headers pkgbuild file
run: |
CURRENT_VERSION=$(sed -n '3p' pkgbuild-files/chromeos-kernel-headers.pkgbuild | sed 's/.*://' | xargs) # get current version from control file
NEXTVERSION=$(echo ${CURRENT_VERSION} | awk -F. -v OFS=. '{$NF += 1 ; print}') # bump version
sed -i "3s/.*/${NEXTVERSION}/" pkgbuild-files/chromeos-kernel-headers.pkgbuild # update version in control file
- name: Add kernel version to headers pkgbuild file
run: |
# download bzImage
curl --silent -LO https://github.com/eupnea-project/linux-kernels/releases/download/latest-chromeos/bzImage
KERNEL_VERSION=$(file -bL ./bzImage | grep -o 'version [^ ]*' | cut -d ' ' -f 2) # get kernel version from bzImage
sed -i "s/insert_version/$KERNEL_VERSION/g" pkgbuild-files/chromeos-kernel-headers.pkgbuild # replace version in pkgbuild file
- name: Packing chromeos-kernel package
run: |
cp pkgbuild-files/chromeos-kernel.pkgbuild . # makepkg needs the pkgbuild file in the current directory
makepkg --nodeps -p chromeos-kernel.pkgbuild
- name: Packing chromeos-kernel-modules package
run: |
cp pkgbuild-files/chromeos-kernel-modules.pkgbuild . # makepkg needs the pkgbuild file in the current directory
makepkg --nodeps -p chromeos-kernel-modules.pkgbuild
- name: Packing chromeos-kernel-headers package
run: |
cp pkgbuild-files/chromeos-kernel-headers.pkgbuild . # makepkg needs the pkgbuild file in the current directory
makepkg --nodeps -p chromeos-kernel-headers.pkgbuild
- name: Downloading old repo
run: |
# Download old repo.
# Exit in case the branch doesn't exist yet
git clone --branch=gh-pages https://github.com/eupnea-project/arch-repo /tmp/arch-repo || exit 0
# Copy old repo to current directory
cp -r /tmp/arch-repo/repodata .
# Delete old kernel packages
rm -rf repodata/x86_64/eupnea-chromeos-kernel*.pkg.tar.gz
# Delete all signatures
rm -rf repodata/x86_64/*.sig
- name: Setting up arch repo
run: bash create-repo.sh
- name: Remove kernel version from spec files
run: |
KERNEL_VERSION=$(file -bL ./bzImage | grep -o 'version [^ ]*' | cut -d ' ' -f 2) # get kernel version from bzImage
sed -i "s/$KERNEL_VERSION/insert_version/g" pkgbuild-files/chromeos-kernel-headers.pkgbuild # replace version in pkgbuild file
- name: Updating files in main branch
uses: stefanzweifel/git-auto-commit-action@v4
with:
# Disable setting repo owner as commit author
commit_user_name: github-actions[bot]
commit_user_email: 41898282+github-actions[bot]@users.noreply.github.com
commit_author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
# Optional. Commit message for the created commit.
# Defaults to "Apply automatic changes"
commit_message: Update files in main branch
file_pattern: 'pkgbuild-files/chromeos-kernel*.pkgbuild cache/chromeos_kernel_tag-cache.txt'
- name: Deploying chromeos kernel packages
uses: stefanzweifel/git-auto-commit-action@v4
with:
# Disable setting repo owner as commit author
commit_user_name: github-actions[bot]
commit_user_email: 41898282+github-actions[bot]@users.noreply.github.com
commit_author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
# Optional. Commit message for the created commit.
# Defaults to "Apply automatic changes"
commit_message: Deploy system packages
branch: gh-pages
create_branch: true
# Only include needed files
file_pattern: 'repodata/* public_key.gpg'
push_options: '--force'