-
Notifications
You must be signed in to change notification settings - Fork 0
133 lines (122 loc) · 4.73 KB
/
main.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
# This workflow builds, tests and releases an Ambianic Edge binary image for Raspberry Pi
name: CI build
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the main branch
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# Build binary images
build:
name: Build and test
runs-on: ubuntu-latest
# Skip build if the commit message includes the string '[skip ci]'
if: "! contains(github.event.head_commit.message, '[skip ci]')"
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Get the version (git tag)
id: get_version
run: |
echo ${GITHUB_REF/refs\/tags\//}
echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
- name: Install pi-gen required dependencies
run: |
sudo dpkg --add-architecture i386
sudo apt-get update --fix-missing
sudo apt-get install -y coreutils quilt parted debootstrap zerofree zip dosfstools libarchive-tools libcap2-bin grep rsync xz-utils file git curl bc jq
sudo apt-get install -y qemu-user-static qemu-utils
# Checkout the latest pi-gen repo code
- name: Checkout the latest pi-gen repo code
run: |
git clone https://github.com/RPi-Distro/pi-gen.git
pushd pi-gen
pwd
ls -al
popd
# Copy ambianic image build config to pi-gen working dir
- name: Copy ambianic image build config to pi-gen working dir
run: cp ./config ./pi-gen/config
# Copy WiFi Connect stage script to pi-gen working dir
- name: Copy WiFi Connect stage script to pi-gen working dir
run: |
find ./pi-gen-stage-ambianic -name "*.sh" -exec chmod +x {} \;
cp -R ./pi-gen-stage-ambianic ./pi-gen/
ls -al ./pi-gen
# Mark stage2 image to be skipped for faster build
- name: Skip stage2 image - Standard Raspbian OS Lite
run: |
touch ./pi-gen/stage2/SKIP_IMAGES
# Run pi-gen image build script
- name: Run pi-gen script
run: |
pwd
ls -al
pushd pi-gen
pwd
# Checkout a known stable pi-gen tag
git checkout tags/2021-05-07-raspbian-buster
ls -al
# sudo CLEAN=1 BUILD_VERSION=${{ steps.get_version.outputs.VERSION }} ./build.sh -c config
sudo CLEAN=1 BUILD_VERSION=${{ steps.get_version.outputs.VERSION }} ./build.sh -c config
popd
- name: Check prepared images
run: |
ls -al ./pi-gen/deploy
# check if the expected image files are there
test -f ./pi-gen/deploy/*ambianic_edge-rpi.zip
- name: Upload artifacts for release job
uses: actions/upload-artifact@v2
with:
name: deploy
path: |
./pi-gen/deploy
# Release and publish image
release:
name: Release a new image
needs: build
runs-on: ubuntu-latest
# trigger a release only when there is a direct commit or PR merge on the master branch
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
steps:
- name: Checkout
# checkout repo to access custom semantic release scripts
uses: actions/checkout@v2
- name: Download deploy artifacts from build job
uses: actions/download-artifact@v4.1.7
with:
name: deploy
# path: ./ambianic-rpi-image/
- name: List checkout and deployment artifacts
run: |
pwd
ls -alR
- name: Semantic Release
id: semrel
uses: cycjimmy/semantic-release-action@v2
with:
# You can specify specifying version range for the extra plugins if you prefer.
extra_plugins: |
@semantic-release/changelog
@semantic-release/git
branches: |
[
'main',
]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Log new release info
if: steps.semrel.outputs.new_release_published == 'true'
run: |
echo ${{ steps.semrel.outputs.new_release_version }}
echo ${{ steps.semrel.outputs.new_release_major_version }}
echo ${{ steps.semrel.outputs.new_release_minor_version }}
echo ${{ steps.semrel.outputs.new_release_patch_version }}
- name: Finalizing run
run: |
echo Finishing pi-gen script...
echo Ambianic Edge rpi image build finished successfully!