1name: Build binary packages
2
3on:
4  workflow_dispatch:
5  workflow_call:
6  push:
7    branches:
8        - 'master'
9    tags:
10        - '*'
11
12jobs:
13  build_linux:
14    name: Build binary on Ubuntu 20.04
15    runs-on: ubuntu-20.04
16
17    steps:
18      - name: Check out code from GitHub
19        uses: actions/checkout@v4
20        with:
21          path: nanopb
22          fetch-depth: "0"
23
24      - name: Setup Python
25        uses: actions/setup-python@v5
26        with:
27          python-version: '3.8'
28
29      - name: Install dependencies
30        run: |
31          python3 -m pip install --user --upgrade scons protobuf grpcio-tools pyinstaller
32          python3 -c 'import google.protobuf; print(google.protobuf.__file__)'
33
34      - name: Build binary package
35        run: |
36          cd nanopb
37          git clean -dxf
38          tools/make_linux_package.sh
39
40      - name: Fingerprint binary
41        run: |
42          openssl sha256 nanopb/dist/*.tar.gz
43
44      - name: Upload binary
45        uses: actions/upload-artifact@v4
46        with:
47          path: nanopb/dist/*.tar.gz
48          name: nanopb-binary-linux
49
50      - name: Test binary package
51        run: |
52          tar xzf nanopb/dist/*.tar.gz
53          cd nanopb-*/tests
54          python3 -m SCons
55
56      - name: Test examples
57        run: |
58          cd nanopb-*/examples
59          (cd simple; make; ./simple)
60          (cd network_server; make)
61          (cd using_union_messages; make)
62          (cd cmake_simple; mkdir build; cd build; cmake ..; make)
63          (cd cmake_relpath; mkdir build; cd build; cmake ..; make)
64
65      - name: Run build tests
66        run: |
67          cd nanopb-*/build-tests
68          (cd cmake_with_components; mkdir build; cd build; cmake ..; make)
69          (cd legacy_cmake_relpath; mkdir build; cd build; cmake ..; make)
70          (cd legacy_cmake_simple; mkdir build; cd build; cmake ..; make)
71
72  build_windows:
73    name: Build binary on Windows 2019
74    runs-on: windows-2019
75
76    steps:
77      - name: Check out code from GitHub
78        uses: actions/checkout@v4
79        with:
80          path: nanopb
81          fetch-depth: "0"
82
83      - name: Install dependencies
84        shell: bash
85        run: |
86          python3 -m pip install --user --upgrade scons protobuf grpcio-tools pyinstaller
87          python3 -c 'import google.protobuf; print(google.protobuf.__file__)'
88
89      - name: Build binary package
90        shell: bash
91        run: |
92          cd nanopb
93          git clean -dxf
94          tools/make_windows_package.sh
95
96      - name: Fingerprint binary
97        run: |
98          openssl sha256 nanopb/dist/*.zip
99
100      - name: Upload binary
101        uses: actions/upload-artifact@v4
102        with:
103          path: nanopb/dist/*.zip
104          name: nanopb-binary-windows
105
106      - name: Test binary package
107        shell: bash
108        run: |
109          powershell "Expand-Archive nanopb/dist/*.zip"
110          ls
111          cd nanopb-*/nanopb-*/tests
112          python3 -m SCons
113
114  build_macos:
115    name: Build binary on Mac OS X 14
116    runs-on: macos-14
117
118    steps:
119      - name: Check out code from GitHub
120        uses: actions/checkout@v4
121        with:
122          path: nanopb
123          fetch-depth: "0"
124
125      - name: Install dependencies
126        run: |
127          python3 -m venv venv
128          venv/bin/python3 -m pip install --upgrade scons protobuf grpcio-tools pyinstaller
129          venv/bin/python3 -c 'import google.protobuf; print(google.protobuf.__file__)'
130
131      - name: Build binary package
132        run: |
133          source venv/bin/activate
134          cd nanopb
135          git clean -dxf
136          tools/make_mac_package.sh
137
138      - name: Fingerprint binary
139        run: |
140          openssl sha256 nanopb/dist/*.tar.gz
141
142      - name: Upload binary
143        uses: actions/upload-artifact@v4
144        with:
145          path: nanopb/dist/*.tar.gz
146          name: nanopb-binary-macos
147
148      - name: Test binary package
149        run: |
150          tar xzf nanopb/dist/*.tar.gz
151          cd nanopb-*/tests
152          ../../venv/bin/python3 -m SCons
153          cd ../examples/simple
154          make
155          ./simple
156
157
158