-
-
Notifications
You must be signed in to change notification settings - Fork 5
229 lines (204 loc) · 8.49 KB
/
release.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
name: release
on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+*"
jobs:
build:
name: build (${{ matrix.config.os }}, ${{ matrix.config.arch }})
runs-on: ubuntu-latest
env:
LIBUSB_DIR: /opt/lib/libusb-1.0.20/libusb/
strategy:
matrix:
config:
- os: linux
arch: amd64
cross_compile: x86_64-ubuntu16.04-linux-gnu
- os: linux
arch: 386
cross_compile: i686-ubuntu16.04-linux-gnu
- os: linux
arch: arm
cross_compile: arm-linux-gnueabihf
- os: linux
arch: arm64
cross_compile: aarch64-linux-gnu
- os: darwin
arch: amd64
cross_compile: x86_64-apple-darwin13
cross_compiler: o64-clang
- os: windows
arch: 386
cross_compile: i686-w64-mingw32
extension: .exe
container:
image: ghcr.io/arduino/crossbuild:0.1.1
credentials:
username: ${{ github.actor }}
password: ${{ secrets.RP2040_CI_PAT }}
steps:
- name: Checkout rp2040tools repository
uses: actions/checkout@v4
with:
path: rp2040tools
- name: Checkout picotool
uses: actions/checkout@v4
with:
repository: raspberrypi/picotool
path: picotool
- name: Checkout pico-sdk
uses: actions/checkout@v4
with:
repository: raspberrypi/pico-sdk
path: pico-sdk
- name: Set env vars
run: echo "PICO_SDK_PATH=${GITHUB_WORKSPACE}/pico-sdk" >> $GITHUB_ENV
- name: Set env vars for non-macos
run: echo "LIBUSBUDEV=/opt/lib/${{ matrix.config.cross_compile }}/libusbudev.a" >> $GITHUB_ENV
if: matrix.config.os != 'darwin'
- name: Set env vars for macos
run: echo "LIBUSBUDEV=$LIBUSB_DIR.libs/libusb-1.0.a" >> $GITHUB_ENV
if: matrix.config.os == 'darwin'
- name: Set env var for win
run: echo "CFLAGS="-mno-ms-bitfields $CFLAGS"" >> $GITHUB_ENV
if: matrix.config.os == 'windows'
- name: Build picotool
run: |
cd $GITHUB_WORKSPACE/picotool
if ls $GITHUB_WORKSPACE/rp2040tools/patches/picotool_*.patch 1> /dev/null 2>&1
then git apply $GITHUB_WORKSPACE/rp2040tools/patches/picotool_*.patch
fi
mkdir build
cd build
if [ "${{ matrix.config.os }}" = "darwin" ]; then
cmake -DCMAKE_C_COMPILER=${{ matrix.config.cross_compiler }} -DCMAKE_CXX_COMPILER=${{ matrix.config.cross_compiler }}++ -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -framework IOKit -framework Cocoa -pthread" -DLIBUSB_LIBRARIES=$LIBUSBUDEV -DLIBUSB_INCLUDE_DIR=$LIBUSB_DIR ..
else
cmake -DCMAKE_C_COMPILER=${{ matrix.config.cross_compile }}-gcc -DCMAKE_CXX_COMPILER=${{ matrix.config.cross_compile }}-g++ -DCMAKE_EXE_LINKER_FLAGS="-static-libgcc -static-libstdc++" -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -pthread" -DLIBUSB_LIBRARIES=$LIBUSBUDEV -DLIBUSB_INCLUDE_DIR=$LIBUSB_DIR ..
fi
make
mv picotool${{ matrix.config.extension }} /tmp/
- name: Build elf2uf2
run: |
cd $GITHUB_WORKSPACE/pico-sdk/tools/elf2uf2/
if ls $GITHUB_WORKSPACE/rp2040tools/patches/elf2uf2_*.patch 1> /dev/null 2>&1
then git apply $GITHUB_WORKSPACE/rp2040tools/patches/elf2uf2_*.patch
fi
mkdir build
cd build
if [ "${{ matrix.config.os }}" = "darwin" ]; then
cmake -DCMAKE_C_COMPILER=${{ matrix.config.cross_compiler }} -DCMAKE_CXX_COMPILER=${{ matrix.config.cross_compiler }}++ -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -framework IOKit -framework Cocoa" ..
else
cmake -DCMAKE_C_COMPILER=${{ matrix.config.cross_compile }}-gcc -DCMAKE_CXX_COMPILER=${{ matrix.config.cross_compile }}-g++ -DCMAKE_EXE_LINKER_FLAGS="-static-libgcc -static-libstdc++" ..
fi
make
mv elf2uf2${{ matrix.config.extension }} /tmp/
- name: Build pioasm
run: |
cd $GITHUB_WORKSPACE/pico-sdk/tools/pioasm/
if ls $GITHUB_WORKSPACE/rp2040tools/patches/pioasm_*.patch 1> /dev/null 2>&1
then git apply $GITHUB_WORKSPACE/rp2040tools/patches/pioasm_*.patch
fi
mkdir build
cd build
if [ "${{ matrix.config.os }}" = "darwin" ]; then
cmake -DCMAKE_C_COMPILER=${{ matrix.config.cross_compiler }} -DCMAKE_CXX_COMPILER=${{ matrix.config.cross_compiler }}++ -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -framework IOKit -framework Cocoa" ..
else
cmake -DCMAKE_C_COMPILER=${{ matrix.config.cross_compile }}-gcc -DCMAKE_CXX_COMPILER=${{ matrix.config.cross_compile }}-g++ -DCMAKE_EXE_LINKER_FLAGS="-static-libgcc -static-libstdc++" ..
fi
make
mv pioasm${{ matrix.config.extension }} /tmp/
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: tools_${{matrix.config.os}}_${{matrix.config.arch}}
path: |
/tmp/elf2uf2${{ matrix.config.extension }}
/tmp/picotool${{ matrix.config.extension }}
/tmp/pioasm${{ matrix.config.extension }}
build-go:
name: build-go (${{ matrix.config.os }}, ${{ matrix.config.arch }})
runs-on: ubuntu-latest
strategy:
matrix:
config:
- os: linux
arch: amd64
- os: linux
arch: 386
- os: linux
arch: arm
- os: linux
arch: arm64
- os: darwin
arch: amd64
- os: windows
arch: 386
extension: .exe
steps:
- name: Checkout rp2040tools repository
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: "1.16.2"
- name: Install Task
uses: arduino/setup-task@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: 3.x
- name: Build rp2040load
run: task go:build
env:
GOOS: ${{ matrix.config.os }}
GOARCH: ${{ matrix.config.arch }}
CGO_ENABLED: 0
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: rp2040load_${{matrix.config.os}}_${{matrix.config.arch}}
path: rp2040load${{ matrix.config.extension }}
create-release:
runs-on: ubuntu-latest
needs: [build, build-go]
env:
TARGET: "/tools/"
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: "us-east-1" # or https://github.com/aws/aws-cli/issues/5623
steps:
- name: Checkout rp2040tools repository # we need package_index.template
uses: actions/checkout@v4
- name: Download artifact
uses: actions/download-artifact@v3 # download all the artifacts
- name: Prepare artifacts for the release and handle package_index
run: |
mkdir release
package_index=`cat package_index.template | sed s/%%VERSION%%/${GITHUB_REF##*/}/`
declare -a target_folders=("linux_amd64" "linux_386" "linux_arm64" "linux_arm" "darwin_amd64" "windows_386")
for folder in "${target_folders[@]}"
do
chmod -v +x rp2040load_$folder/* && chmod -v +x tools_$folder/*
mv -v rp2040load_$folder/rp2040load* tools_$folder/
FILENAME=rp2040tools-${GITHUB_REF##*/}-${folder}.tar.bz2
tar -cvjf $FILENAME tools_$folder/
T_OS=`echo ${folder} | awk '{print toupper($0)}'`
SHASUM=`sha256sum ${FILENAME} | cut -f1 -d" "`
SIZE=`stat --printf="%s" ${FILENAME}`
package_index=`echo "$package_index" |
sed s/%%FILENAME_${T_OS}%%/${FILENAME}/ |
sed s/%%FILENAME_${T_OS}%%/${FILENAME}/ |
sed s/%%SIZE_${T_OS}%%/${SIZE}/ |
sed s/%%SHA_${T_OS}%%/${SHASUM}/`
done
mv -v rp2040tools*.tar.bz2 release/
echo ================== CUT ME HERE =====================
echo "${package_index}"
echo "${package_index}" > package_index_draft.json
- name: Create Github Release and upload artifacts
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
artifacts: "release/*,package_index_draft.json"
- name: Upload release files on Arduino downloads servers
run: aws s3 sync release/ s3://${{ secrets.DOWNLOADS_BUCKET }}${{ env.TARGET }}