|
| 1 | +name: release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "[0-9]+.[0-9]+.[0-9]+*" |
| 7 | + |
| 8 | +jobs: |
| 9 | + build: |
| 10 | + name: build (${{ matrix.config.os }}, ${{ matrix.config.arch }}) |
| 11 | + runs-on: |
| 12 | + ubuntu-latest |
| 13 | + env: |
| 14 | + LIBUSB_DIR: /opt/lib/libusb-1.0.20/libusb/ |
| 15 | + strategy: |
| 16 | + matrix: |
| 17 | + config: |
| 18 | + - os: linux |
| 19 | + arch: amd64 |
| 20 | + cross_compile: x86_64-ubuntu16.04-linux-gnu |
| 21 | + - os: linux |
| 22 | + arch: 386 |
| 23 | + cross_compile: i686-ubuntu16.04-linux-gnu |
| 24 | + - os: linux |
| 25 | + arch: arm |
| 26 | + cross_compile: arm-linux-gnueabihf |
| 27 | + - os: linux |
| 28 | + arch: arm64 |
| 29 | + cross_compile: aarch64-linux-gnu |
| 30 | + - os: darwin |
| 31 | + arch: amd64 |
| 32 | + cross_compile: x86_64-apple-darwin13 |
| 33 | + cross_compiler: o64-clang |
| 34 | + - os: windows |
| 35 | + arch: 386 |
| 36 | + cross_compile: i686-w64-mingw32 |
| 37 | + extension: .exe |
| 38 | + |
| 39 | + container: |
| 40 | + image: ghcr.io/arduino/crossbuild:latest |
| 41 | + credentials: |
| 42 | + username: ${{ github.actor }} |
| 43 | + password: ${{ secrets.RP2040_CI_PAT }} |
| 44 | + |
| 45 | + steps: |
| 46 | + - name: Checkout rp2040tools repository |
| 47 | + uses: actions/checkout@v2 |
| 48 | + with: |
| 49 | + path: rp2040tools |
| 50 | + |
| 51 | + - name: Checkout picotool |
| 52 | + uses: actions/checkout@v2 |
| 53 | + with: |
| 54 | + repository: raspberrypi/picotool |
| 55 | + path: picotool |
| 56 | + |
| 57 | + - name: Checkout pico-sdk |
| 58 | + uses: actions/checkout@v2 |
| 59 | + with: |
| 60 | + repository: raspberrypi/pico-sdk |
| 61 | + path: pico-sdk |
| 62 | + |
| 63 | + - name: Set env vars |
| 64 | + run: echo "PICO_SDK_PATH=${GITHUB_WORKSPACE}/pico-sdk" >> $GITHUB_ENV |
| 65 | + |
| 66 | + - name: Set env vars for non-macos |
| 67 | + run: echo "LIBUSBUDEV=/opt/lib/${{ matrix.config.cross_compile }}/libusbudev.a" >> $GITHUB_ENV |
| 68 | + if: matrix.config.os != 'darwin' |
| 69 | + |
| 70 | + - name: Set env vars for macos |
| 71 | + run: echo "LIBUSBUDEV=$LIBUSB_DIR.libs/libusb-1.0.a" >> $GITHUB_ENV |
| 72 | + if: matrix.config.os == 'darwin' |
| 73 | + |
| 74 | + - name: Set env var for win |
| 75 | + run: echo "CFLAGS="-mno-ms-bitfields $CFLAGS"" >> $GITHUB_ENV |
| 76 | + if: matrix.config.os == 'windows' |
| 77 | + |
| 78 | + - name: Build picotool |
| 79 | + run: | |
| 80 | + cd $GITHUB_WORKSPACE/picotool |
| 81 | + if ls $GITHUB_WORKSPACE/rp2040tools/patches/picotool_*.patch 1> /dev/null 2>&1 |
| 82 | + then git apply $GITHUB_WORKSPACE/rp2040tools/patches/picotool_*.patch |
| 83 | + fi |
| 84 | + mkdir build |
| 85 | + cd build |
| 86 | + if [ "${{ matrix.config.os }}" = "darwin" ]; then |
| 87 | + 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 .. |
| 88 | + else |
| 89 | + 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 .. |
| 90 | + fi |
| 91 | + make |
| 92 | + mv picotool${{ matrix.config.extension }} /tmp/ |
| 93 | +
|
| 94 | + - name: Build elf2uf2 |
| 95 | + run: | |
| 96 | + cd $GITHUB_WORKSPACE/pico-sdk/tools/elf2uf2/ |
| 97 | + if ls $GITHUB_WORKSPACE/rp2040tools/patches/elf2uf2_*.patch 1> /dev/null 2>&1 |
| 98 | + then git apply $GITHUB_WORKSPACE/rp2040tools/patches/elf2uf2_*.patch |
| 99 | + fi |
| 100 | + mkdir build |
| 101 | + cd build |
| 102 | + if [ "${{ matrix.config.os }}" = "darwin" ]; then |
| 103 | + 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" .. |
| 104 | + else |
| 105 | + 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++" .. |
| 106 | + fi |
| 107 | + make |
| 108 | + mv elf2uf2${{ matrix.config.extension }} /tmp/ |
| 109 | +
|
| 110 | + - name: Upload artifacts |
| 111 | + uses: actions/upload-artifact@v2 |
| 112 | + with: |
| 113 | + name: tools_${{matrix.config.os}}_${{matrix.config.arch}} |
| 114 | + path: | |
| 115 | + /tmp/elf2uf2${{ matrix.config.extension }} |
| 116 | + /tmp/picotool${{ matrix.config.extension }} |
| 117 | +
|
| 118 | + build-go: |
| 119 | + name: build-go (${{ matrix.config.os }}, ${{ matrix.config.arch }}) |
| 120 | + runs-on: |
| 121 | + ubuntu-latest |
| 122 | + strategy: |
| 123 | + matrix: |
| 124 | + config: |
| 125 | + - os: linux |
| 126 | + arch: amd64 |
| 127 | + - os: linux |
| 128 | + arch: 386 |
| 129 | + - os: linux |
| 130 | + arch: arm |
| 131 | + - os: linux |
| 132 | + arch: arm64 |
| 133 | + - os: darwin |
| 134 | + arch: amd64 |
| 135 | + - os: windows |
| 136 | + arch: 386 |
| 137 | + extension: .exe |
| 138 | + |
| 139 | + steps: |
| 140 | + - name: Checkout rp2040tools repository |
| 141 | + uses: actions/checkout@v2 |
| 142 | + |
| 143 | + - name: Install Go |
| 144 | + uses: actions/setup-go@v2 |
| 145 | + with: |
| 146 | + go-version: "1.15.8" |
| 147 | + |
| 148 | + - name: Build rp2040load |
| 149 | + run: go build |
| 150 | + env: |
| 151 | + GOOS: ${{ matrix.config.os }} |
| 152 | + GOARCH: ${{ matrix.config.arch }} |
| 153 | + CGO_ENABLED: 0 |
| 154 | + |
| 155 | + - name: Upload artifacts |
| 156 | + uses: actions/upload-artifact@v2 |
| 157 | + with: |
| 158 | + name: rp2040load_${{matrix.config.os}}_${{matrix.config.arch}} |
| 159 | + path: rp2040load${{ matrix.config.extension }} |
| 160 | + |
| 161 | + create-release: |
| 162 | + runs-on: |
| 163 | + ubuntu-latest |
| 164 | + needs: [build, build-go] |
| 165 | + env: |
| 166 | + TARGET: "/tools/" |
| 167 | + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 168 | + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 169 | + AWS_REGION: "us-east-1" # or https://github.com/aws/aws-cli/issues/5623 |
| 170 | + steps: |
| 171 | + - name: Download artifact |
| 172 | + uses: actions/download-artifact@v2 # download all the artifacts |
| 173 | + |
| 174 | + - name: Prepare artifacts for the release |
| 175 | + run: | |
| 176 | + mkdir release |
| 177 | + declare -a target_folders=("linux_amd64" "linux_386" "linux_arm64" "linux_arm" "darwin_amd64" "windows_386") |
| 178 | + for folder in "${target_folders[@]}" |
| 179 | + do |
| 180 | + chmod -v +x rp2040load_$folder/* && chmod -v +x tools_$folder/* |
| 181 | + mv -v rp2040load_$folder/rp2040load* tools_$folder/ |
| 182 | + tar -cvjf rp2040tools-${GITHUB_REF##*/}-$folder.tar.bz2 tools_$folder/ |
| 183 | + done |
| 184 | + mv -v rp2040tools*.tar.bz2 release/ |
| 185 | + |
| 186 | + - name: Create Github Release and upload artifacts |
| 187 | + uses: ncipollo/release-action@v1 |
| 188 | + with: |
| 189 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 190 | + artifacts: release/* |
| 191 | + |
| 192 | + - name: Upload release files on Arduino downloads servers |
| 193 | + run: aws s3 sync release/ s3://${{ secrets.DOWNLOADS_BUCKET }}${{ env.TARGET }} |
0 commit comments