-
Notifications
You must be signed in to change notification settings - Fork 4
113 lines (99 loc) · 3.59 KB
/
buildroot.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
#
# Copyright (C) 2022 Ing <https://github.com/wjz304>
#
# This is free software, licensed under the MIT License.
# See /LICENSE for more information.
#
name: Build buildroot
on:
workflow_dispatch:
inputs:
version:
description: "format %y.%-m.$i or auto"
required: false
type: string
prerelease:
description: "pre release"
default: false
type: boolean
br2ver:
description: "buildroot version"
default: "2023.08.x"
type: string
jobs:
buildroot:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@main
- name: Checkout
uses: actions/checkout@main
with:
repository: RROrg/buildroot
token: ${{ secrets.RRORG }}
path: buildroot
- name: Initialization environment
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
sudo timedatectl set-timezone "Asia/Shanghai"
# Clean up disk space
docker rmi $(docker images -q)
sudo apt update
sudo apt -y purge azure-cli* docker* llvm* google* dotnet* powershell* sphinxsearch* mysql* php*
sudo apt -y full-upgrade
sudo apt update
sudo apt install -y jq gawk cpio gettext libelf-dev qemu-utils
sudo snap install yq
df -h
- name: Calculate version
run: |
# Calculate version
VERSION=""
if [ -n "${{ inputs.version }}" ]; then
if [ "$(echo ${{ inputs.version }} | cut -d '.' -f 1,2)" = "$(date +'%y.%-m')" ]; then
VERSION="${{ inputs.version }}"
else
LATEST_TAG="$(curl -skLH "Authorization: token ${{ secrets.RRORG }}" "https://api.github.com/repos/RROrg/qr-buildroot/releases" | jq -r ".[0].tag_name" 2>/dev/null)"
if [ -n "${LATEST_TAG}" -a "$(echo ${LATEST_TAG} | cut -d '.' -f 1,2)" = "$(date +'%y.%-m')" ]; then # format %y.%-m.$i
VERSION="$(echo ${LATEST_TAG} | awk -F '.' '{$3=$3+1}1' OFS='.')"
else
VERSION="$(date +'%y.%-m').0"
fi
fi
else
VERSION=""
fi
echo "VERSION: ${VERSION}"
echo "VERSION=${VERSION}" >> $GITHUB_ENV
- name: Build buildroot
run: |
cd buildroot
chmod +x ./build_qr.sh
. ./build_qr.sh "${{ inputs.br2ver}}"
[ -n "${BUILDROOT_VERSION}" ] && echo "BUILDROOT_VERSION=${BUILDROOT_VERSION}" >> $GITHUB_ENV || exit 1
[ -n "${KERNEL_VERSION}" ] && echo "KERNEL_VERSION=${KERNEL_VERSION}" >> $GITHUB_ENV || exit 1
- name: Upload artifact
if: env.VERSION == ''
uses: actions/upload-artifact@v3
with:
name: buildroot
path: |
buildroot/.qr-buildroot/output/images/bzImage
buildroot/.qr-buildroot/output/images/rootfs.cpio.xz
# Publish a release if is a tag
- name: Release
if: env.VERSION != ''
uses: ncipollo/release-action@v1
with:
tag: ${{ env.VERSION }}
prerelease: ${{ inputs.prerelease }}
artifacts: |
buildroot/.qr-buildroot/output/images/bzImage
buildroot/.qr-buildroot/output/images/rootfs.cpio.xz
body: |
Buildroot version: ${{ env.BUILDROOT_VERSION }}
Kernel version: ${{ env.KERNEL_VERSION }}
owner: RROrg
repo: qr-buildroot
token: ${{ secrets.RRORG }}