This repository has been archived by the owner on Jan 25, 2024. It is now read-only.
Deploying chromeos kernel packages #93
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploying chromeos kernel packages | |
on: | |
schedule: | |
- cron: "20 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: Installing dependencies | |
run: sudo apt-get install -y rpm createrepo-c | |
- name: Update local tag releases cache file | |
run: | | |
echo "${{ needs.check-sha.outputs.remote_tag }}" > cache/chromeos_kernel_tag-cache.txt | |
- name: Bump version in kernel spec file | |
run: | | |
CURRENT_VERSION=$(sed -n '2p' spec-files/eupnea-chromeos-kernel.spec | sed 's/.*://' | xargs) # get current version from spec file | |
NEXTVERSION=$(echo ${CURRENT_VERSION} | awk -F. -v OFS=. '{$NF += 1 ; print}') # bump version | |
sed -i "2s/.*/Version: ${NEXTVERSION}/" spec-files/eupnea-chromeos-kernel.spec # update version in spec file | |
- name: Bump version in modules spec file | |
run: | | |
CURRENT_VERSION=$(sed -n '2p' spec-files/eupnea-chromeos-kernel-modules.spec | sed 's/.*://' | xargs) # get current version from spec file | |
NEXTVERSION=$(echo ${CURRENT_VERSION} | awk -F. -v OFS=. '{$NF += 1 ; print}') # bump version | |
sed -i "2s/.*/Version: ${NEXTVERSION}/" spec-files/eupnea-chromeos-kernel-modules.spec # update version in spec file | |
- name: Bump version in headers spec file | |
run: | | |
CURRENT_VERSION=$(sed -n '2p' spec-files/eupnea-chromeos-kernel-headers.spec | sed 's/.*://' | xargs) # get current version from spec file | |
NEXTVERSION=$(echo ${CURRENT_VERSION} | awk -F. -v OFS=. '{$NF += 1 ; print}') # bump version | |
sed -i "2s/.*/Version: ${NEXTVERSION}/" spec-files/eupnea-chromeos-kernel-headers.spec # update version in spec file | |
- name: Add kernel version to spec files | |
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" spec-files/eupnea-chromeos-kernel-headers.spec # replace version in spec file | |
sed -i "s/insert_version/$KERNEL_VERSION/g" spec-files/eupnea-chromeos-kernel-modules.spec # replace version in spec file | |
- name: Packing kernel package | |
run: rpmbuild -bb spec-files/eupnea-chromeos-kernel.spec | |
- name: Packing modules package | |
run: rpmbuild -bb spec-files/eupnea-chromeos-kernel-modules.spec | |
- name: Packing headers package | |
run: rpmbuild -bb spec-files/eupnea-chromeos-kernel-headers.spec | |
- 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/rpm-repo /tmp/rpm-repo || exit 0 | |
# Copy util rpms to current directory | |
cp -r /tmp/rpm-repo/*.rpm . | |
# Delete old chromeos kernel packages | |
rm -rf ./eupnea-chromeos-kernel*.rpm | |
rm -rf ./eupnea-chromeos-kernel-modules*.rpm | |
rm -rf ./eupnea-chromeos-kernel-headers*.rpm | |
- name: Setting up rpm 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" spec-files/eupnea-chromeos-kernel-headers.spec # replace version in spec file | |
sed -i "s/$KERNEL_VERSION/insert_version/g" spec-files/eupnea-chromeos-kernel-modules.spec # replace version in spec 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: 'spec-files/eupnea-chromeos-kernel.spec spec-files/eupnea-chromeos-kernel-modules.spec spec-files/eupnea-chromeos-kernel-headers.spec cache/chromeos_kernel_tag-cache.txt' | |
- name: Deploying system 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 chromeos kernel package | |
branch: gh-pages | |
create_branch: true | |
# Only include needed files | |
file_pattern: 'repodata/* *.rpm eupnea.repo public_key.gpg' | |
push_options: '--force' |