-
Notifications
You must be signed in to change notification settings - Fork 1
145 lines (122 loc) · 5.82 KB
/
pt-os.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
name: pi-topOS Build
on:
workflow_dispatch:
inputs:
repo_name:
description: 'Repository to build against'
required: true
default: 'release'
type: choice
options:
- unstable
- testing
- release
distro_name:
description: 'OS distribution'
required: true
default: 'bookworm'
type: choice
options:
- bullseye
- bookworm
jobs:
build:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
build_type_suffix: ["", "-lite"]
architecture: ["armhf", "arm64"]
steps:
- name: GitHub Environment Variables Action
uses: FranzDiebold/github-env-vars-action@v2.7.0
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: aarcangeli/load-dotenv@v1.0.0
- name: Get build type and RPi OS image name
run: |
build_type="${{ matrix.architecture }}${{ matrix.build_type_suffix }}"
echo "BUILD_TYPE=${build_type}" >> $GITHUB_ENV
echo "IMAGE_NAME=${{ env.RASPIOS_BUILD_DATE }}-raspios-${{ inputs.distro_name }}-${build_type}" >> $GITHUB_ENV
- name: Install ansible and playbook dependencies
# Install 'qemu-user-static' >v5 to allow 'arm64' chroot
# 'ubuntu-20.04' (currently latest) does not have an up-to-date version, so we install from `ubuntu-security` repo
run: |
wget http://old-releases.ubuntu.com/ubuntu/pool/universe/q/qemu/qemu-user-static_5.2+dfsg-9ubuntu3.1_amd64.deb
sudo apt-get update && sudo apt-get install -y \
ansible \
unzip \
zerofree \
./qemu-user-static_5.2+dfsg-9ubuntu3.1_amd64.deb
- name: Build
run: |
export ANSIBLE_FORCE_COLOR=true
export TERM=xterm-color
# chroot connection requires running as root
# 'ansible-playbook' is not in root user's PATH
ANSIBLE="sudo $(which ansible-playbook) -i inventory -vv"
build_type_dir="raspios_$(echo ${{ env.BUILD_TYPE }} | python3 -c "import sys; print('_'.join(reversed(sys.stdin.read().strip().split('-'))))")"
url="https://downloads.raspberrypi.org/${build_type_dir}/images/${build_type_dir}-${{ env.RASPIOS_RELEASE_DATE }}/${{ env.IMAGE_NAME }}.img.xz"
echo "==> Running get_raspios playbook..."
${ANSIBLE} --extra-vars "raspi_os_url=${url}" \
--extra-vars "image_name=${{ env.IMAGE_NAME }}" \
playbooks/get_raspios.yml
echo "==> Running mount_raspios playbook..."
${ANSIBLE} --extra-vars "image_name=${{ env.IMAGE_NAME }}" \
playbooks/mount_raspios.yml
echo "==> Running create_pi_top_os_image playbook..."
${ANSIBLE} playbooks/create_pi_top_os_image.yml
echo "==> Running mount_pi_top_os playbook..."
${ANSIBLE} playbooks/mount_pi_top_os.yml
echo "==> Running install_pi_top_os playbook..."
${ANSIBLE} --extra-vars "repo_name=${{ inputs.repo_name }}" \
--extra-vars "distro_name=${{ inputs.distro_name }}" \
--extra-vars "top_level_pkg=pt-os${{ matrix.build_type_suffix }}" \
--extra-vars "{'full_install': ${{ matrix.build_type_suffix == '' }}}" \
playbooks/install_pi_top_os.yml
echo "==> Running configure_pi_top_os playbook..."
${ANSIBLE} --extra-vars "distro_name=${{ inputs.distro_name }}" \
--extra-vars "build_number=${{ github.run_number || github.run_id }}" \
--extra-vars "build_repo_commit=$(git rev-parse HEAD)" \
--extra-vars "build_repo_commit_short=$(git rev-parse --short HEAD)" \
--extra-vars "build_action_url=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" \
--extra-vars "build_repo_name=${{ inputs.repo_name }}" \
--extra-vars "build_type=${{ env.BUILD_TYPE }}" \
playbooks/configure_pi_top_os.yml
echo "==> Running finalise_pi_top_image playbook..."
${ANSIBLE} --extra-vars "distro_name=${{ inputs.distro_name }}" \
--extra-vars "build_number=${{ github.run_number || github.run_id }}" \
--extra-vars "build_repo_name=${{ inputs.repo_name }}" \
--extra-vars "build_type=${{ env.BUILD_TYPE }}" \
playbooks/finalise_pi_top_image.yml
echo "==> Running analyse_build playbook..."
${ANSIBLE} --extra-vars "build_number=${{ github.run_number || github.run_id }}" \
playbooks/analyse_build.yml
- name: Cleanup (to avoid CI space issues)
run: |
ls -l playbooks/artifacts
sudo rm -f playbooks/artifacts/*.zip
ls -l playbooks/artifacts
- name: Get current date
id: date
run: echo "DATE_STAMP=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
- name: Upload OS zip contents
uses: actions/upload-artifact@v3
with:
name: pi-topOS_${{ inputs.distro_name }}_${{ inputs.repo_name }}_${{ env.BUILD_TYPE }}_${{ env.DATE_STAMP }}_B${{ github.run_number || github.run_id }}
if-no-files-found: error
path: |
playbooks/artifacts/*
!**/*.zip
- name: Print metadata
run: cat playbooks/artifacts/metadata.txt
- name: Upload OS zip to GCS
uses: google-github-actions/upload-cloud-storage@v0.4.0
with:
credentials: ${{ secrets.GOOGLE_CLOUD_UPLOAD_JSON_CREDENTIALS }}
path: 'playbooks/artifacts'
glob: '**/*.zip'
parent: false
destination: ${{ secrets.GOOGLE_CLOUD_OS_UPLOAD_BUCKET }}/pi-topOS-${{ inputs.distro_name }}/