Skip to content

Commit 04b2e1c

Browse files
committed
[bradh352]: add build workflow
1 parent b25d4c6 commit 04b2e1c

File tree

1 file changed

+97
-0
lines changed

1 file changed

+97
-0
lines changed

.github/workflows/buildsonic.yaml

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Build Sonic
2+
on:
3+
push:
4+
pull_request:
5+
workflow_dispatch:
6+
7+
concurrency:
8+
group: ${{ github.ref }}
9+
cancel-in-progress: true
10+
11+
env:
12+
SONIC_BUILD_JOBS: 8
13+
SONIC_CONFIG_MAKE_JOBS: 8
14+
SONIC_CONFIG_BUILD_JOBS: 8
15+
SONIC_VERSION_CONTROL_COMPONENTS: none
16+
MIRROR_SNAPSHOT: n
17+
SONIC_DPKG_CACHE_METHOD: cache
18+
19+
jobs:
20+
build:
21+
runs-on: self-hosted
22+
name: "Build Sonic"
23+
steps:
24+
- name: Install needed packages
25+
run: |
26+
sudo apt-get update
27+
sudo apt-get install -y sudo curl wget ca-certificates cmake ninja-build autoconf automake libtool g++ pkg-config python3-pip git
28+
sudo apt-get dist-upgrade -y --assume-yes
29+
- name: Install j2cli
30+
run: |
31+
pip3 install --user j2cli
32+
- name: Clean up from prior runs
33+
run: |
34+
docker image prune --all --force
35+
docker builder prune --all --force
36+
mydir=`pwd`
37+
sudo rm -rf *
38+
sudo rm -rf .git
39+
cd ..
40+
sudo rm -rf ${mydir}
41+
mkdir -p ${mydir}
42+
cd ${mydir}
43+
sudo rm -rf /var/cache/sonic
44+
sudo mkdir -p /var/cache/sonic/artifacts
45+
sudo chown $USER: /var/cache/sonic/artifacts
46+
sudo chmod 777 /var/cache/sonic/artifacts
47+
- name: Checkout sonic-build
48+
uses: actions/checkout@v4
49+
with:
50+
submodules: "recursive"
51+
fetch-depth: 0
52+
- name: "Broadcom: Configure"
53+
run: |
54+
make init
55+
make configure PLATFORM=broadcom
56+
- name: "Broadcom: Make target/sonic-broadcom.bin"
57+
run: |
58+
make target/sonic-broadcom.bin
59+
cp -f target/sonic-broadcom.bin .
60+
- name: "Broadcom: Cleanup"
61+
run: |
62+
sudo rm -rf target
63+
- name: "Mellanox: Configure"
64+
run: |
65+
make init
66+
make configure PLATFORM=mellanox
67+
- name: "Mellanox: Make target/sonic-mellanox.bin"
68+
run: |
69+
make target/sonic-mellanox.bin
70+
cp -f target/sonic-mellanox.bin .
71+
- name: "Broadcom: upload artifact"
72+
uses: actions/upload-artifact@v4
73+
with:
74+
name: "sonic-broadcom.bin"
75+
path: 'sonic-broadcom.bin'
76+
if-no-files-found: error
77+
overwrite: true
78+
retention-days: 30
79+
- name: "Mellanox: upload artifact"
80+
uses: actions/upload-artifact@v4
81+
with:
82+
name: "sonic-mellanox.bin"
83+
path: 'sonic-mellanox.bin'
84+
if-no-files-found: error
85+
overwrite: true
86+
retention-days: 30
87+
- name: Upload Release
88+
uses: softprops/action-gh-release@v2
89+
if: startsWith(github.ref, 'refs/tags/')
90+
with:
91+
draft: false
92+
make_latest: true
93+
generate_release_notes: true
94+
files: |
95+
sonic-broadcom.bin
96+
sonic-mellanox.bin
97+
fail_on_unmatched_files: true

0 commit comments

Comments
 (0)