|
| 1 | +name: Build |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + branches: |
| 6 | + - '**' |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - '**' |
| 10 | + |
| 11 | +permissions: write-all |
| 12 | + |
| 13 | +jobs: |
| 14 | + cross-build: |
| 15 | + name: 'Cross build' |
| 16 | + runs-on: ubuntu-latest |
| 17 | + continue-on-error: true |
| 18 | + strategy: |
| 19 | + matrix: |
| 20 | + target: [ |
| 21 | + # Windows |
| 22 | + 'x86_64-w64-mingw32', |
| 23 | + 'i686-w64-mingw32', |
| 24 | + 'aarch64-w64-mingw32', |
| 25 | + |
| 26 | + # macOS |
| 27 | + 'aarch64-unknown-apple-darwin', |
| 28 | + 'x86_64-unknown-apple-darwin', |
| 29 | + |
| 30 | + # Linux (glibc) |
| 31 | + 'x86_64-unknown-linux-gnu', |
| 32 | + 'i386-unknown-linux-gnu', |
| 33 | + 'arm-unknown-linux-gnueabi', |
| 34 | + 'arm-unknown-linux-gnueabihf', |
| 35 | + 'aarch64-unknown-linux-gnu', |
| 36 | + |
| 37 | + # Linux (musl) |
| 38 | + 'aarch64-unknown-linux-musl', |
| 39 | + 'x86_64-unknown-linux-musl', |
| 40 | + 'armv6-unknown-linux-musleabihf', |
| 41 | + 'armv7-unknown-linux-musleabihf', |
| 42 | + 'i386-unknown-linux-musl', |
| 43 | + |
| 44 | + # FreeBSD |
| 45 | + 'x86_64-unknown-freebsd', |
| 46 | + 'aarch64-unknown-freebsd', |
| 47 | + 'i386-unknown-freebsd', |
| 48 | + |
| 49 | + # NetBSD |
| 50 | + 'i386-unknown-netbsdelf', |
| 51 | + 'x86_64-unknown-netbsd', |
| 52 | + |
| 53 | + # DragonFly BSD |
| 54 | + 'x86_64-unknown-dragonfly', |
| 55 | + |
| 56 | + # Android |
| 57 | + 'x86_64-unknown-linux-android', |
| 58 | + 'i686-unknown-linux-android21', |
| 59 | + 'aarch64-unknown-linux-android', |
| 60 | + 'riscv64-unknown-linux-android', |
| 61 | + 'armv7-unknown-linux-androideabi21', |
| 62 | + 'mips64el-unknown-linux-android', |
| 63 | + 'mipsel-unknown-linux-android21' |
| 64 | + ] |
| 65 | + steps: |
| 66 | + - uses: actions/checkout@main |
| 67 | + with: |
| 68 | + submodules: true |
| 69 | + - name: Install required dependencies |
| 70 | + run: | |
| 71 | + sudo apt-get update |
| 72 | + sudo apt-get install build-essential autoconf libtool |
| 73 | + - name: Cross-compile Pino to ${{ matrix.target }} |
| 74 | + run: | |
| 75 | + if [[ '${{ matrix.target }}' = *'-linux-musl'* ]]; then |
| 76 | + declare -r RAIDEN_TAG='gcc-15' |
| 77 | + declare -r RAIDEN_TARBALL='/tmp/toolchain.tar.xz' |
| 78 | + declare -r RAIDEN_URL="https://github.com/AmanoTeam/musl-gcc-cross/releases/download/${RAIDEN_TAG}/x86_64-unknown-linux-gnu.tar.xz" |
| 79 | + |
| 80 | + curl --connect-timeout '10' --retry '15' --retry-all-errors --fail --silent --location --url "${RAIDEN_URL}" --output "${RAIDEN_TARBALL}" |
| 81 | + tar --directory="$(dirname "${RAIDEN_TARBALL}")" --extract --file="${RAIDEN_TARBALL}" |
| 82 | + |
| 83 | + export RAIDEN_HOME='/tmp/musl-gcc-cross' |
| 84 | + export PATH="${RAIDEN_HOME}/bin:${PATH}" |
| 85 | + |
| 86 | + source "${RAIDEN_HOME}/build/autotools/${{ matrix.target }}.sh" |
| 87 | + elif [[ '${{ matrix.target }}' = *'-linux-gnu'* ]]; then |
| 88 | + declare -r OBGGCC_TAG='gcc-16' |
| 89 | + declare -r OBGGCC_TARBALL='/tmp/toolchain.tar.xz' |
| 90 | + declare -r OBGGCC_URL="https://github.com/AmanoTeam/obggcc/releases/download/${OBGGCC_TAG}/x86_64-unknown-linux-gnu.tar.xz" |
| 91 | + |
| 92 | + curl --connect-timeout '10' --retry '15' --retry-all-errors --fail --silent --location --url "${OBGGCC_URL}" --output "${OBGGCC_TARBALL}" |
| 93 | + tar --directory="$(dirname "${OBGGCC_TARBALL}")" --extract --file="${OBGGCC_TARBALL}" |
| 94 | + |
| 95 | + export OBGGCC_ARM_MODE='true' |
| 96 | + |
| 97 | + export OBGGCC_HOME='/tmp/obggcc' |
| 98 | + export PATH="${OBGGCC_HOME}/bin:${PATH}" |
| 99 | + |
| 100 | + source "${OBGGCC_HOME}/build/autotools/${{ matrix.target }}.sh" |
| 101 | + elif [[ '${{ matrix.target }}' = *'-freebsd' ]]; then |
| 102 | + declare -r LOKI_TAG='gcc-16' |
| 103 | + declare -r LOKI_TARBALL='/tmp/toolchain.tar.xz' |
| 104 | + declare -r LOKI_URL="https://github.com/AmanoTeam/freebsd-gcc-cross/releases/download/${LOKI_TAG}/x86_64-unknown-linux-gnu.tar.xz" |
| 105 | + |
| 106 | + curl --silent --connect-timeout '10' --retry '15' --retry-all-errors --fail --location --url "${LOKI_URL}" --output "${LOKI_TARBALL}" |
| 107 | + tar --directory="$(dirname "${LOKI_TARBALL}")" --extract --file="${LOKI_TARBALL}" |
| 108 | + |
| 109 | + export LOKI_HOME='/tmp/freebsd-gcc-cross' |
| 110 | + export PATH="${LOKI_HOME}/bin:${PATH}" |
| 111 | + |
| 112 | + source "${LOKI_HOME}/build/autotools/${{ matrix.target }}.sh" |
| 113 | + elif [[ '${{ matrix.target }}' = *'-netbsd'* ]]; then |
| 114 | + declare -r DAKINI_TAG='gcc-15' |
| 115 | + declare -r DAKINI_TARBALL='/tmp/toolchain.tar.xz' |
| 116 | + declare -r DAKINI_URL="https://github.com/AmanoTeam/netbsd-gcc-cross/releases/download/${DAKINI_TAG}/x86_64-unknown-linux-gnu.tar.xz" |
| 117 | + |
| 118 | + curl --connect-timeout '10' --retry '15' --retry-all-errors --fail --silent --location --url "${DAKINI_URL}" --output "${DAKINI_TARBALL}" |
| 119 | + tar --directory="$(dirname "${DAKINI_TARBALL}")" --extract --file="${DAKINI_TARBALL}" |
| 120 | + |
| 121 | + export DAKINI_HOME='/tmp/netbsd-gcc-cross' |
| 122 | + export PATH="${DAKINI_HOME}/bin:${PATH}" |
| 123 | + |
| 124 | + source "${DAKINI_HOME}/build/autotools/${{ matrix.target }}.sh" |
| 125 | + elif [[ '${{ matrix.target }}' = *'-dragonfly' ]]; then |
| 126 | + declare -r VENTI_TAG='gcc-16' |
| 127 | + declare -r VENTI_TARBALL='/tmp/toolchain.tar.xz' |
| 128 | + declare -r VENTI_URL="https://github.com/AmanoTeam/dragonfly-gcc-cross/releases/download/${VENTI_TAG}/x86_64-unknown-linux-gnu.tar.xz" |
| 129 | + |
| 130 | + curl --connect-timeout '10' --retry '15' --retry-all-errors --fail --silent --location --url "${VENTI_URL}" --output "${VENTI_TARBALL}" |
| 131 | + tar --directory="$(dirname "${VENTI_TARBALL}")" --extract --file="${VENTI_TARBALL}" |
| 132 | + |
| 133 | + export VENTI_HOME='/tmp/dragonfly-gcc-cross' |
| 134 | + export PATH="${VENTI_HOME}/bin:${PATH}" |
| 135 | + |
| 136 | + source "${VENTI_HOME}/build/autotools/${{ matrix.target }}.sh" |
| 137 | + elif [[ '${{ matrix.target }}' = *'-mingw32' ]]; then |
| 138 | + declare -r MINGW_TAG='gcc-16' |
| 139 | + declare -r MINGW_TARBALL='/tmp/toolchain.tar.xz' |
| 140 | + declare -r MINGW_URL="https://github.com/AmanoTeam/mingw-gcc-cross/releases/download/${MINGW_TAG}/x86_64-unknown-linux-gnu.tar.xz" |
| 141 | + |
| 142 | + curl --connect-timeout '10' --retry '15' --retry-all-errors --fail --silent --location --url "${MINGW_URL}" --output "${MINGW_TARBALL}" |
| 143 | + tar --directory="$(dirname "${MINGW_TARBALL}")" --extract --file="${MINGW_TARBALL}" |
| 144 | + |
| 145 | + export MINGW_HOME='/tmp/mingw-gcc-cross' |
| 146 | + export PATH="${MINGW_HOME}/bin:${PATH}" |
| 147 | + |
| 148 | + source "${MINGW_HOME}/build/autotools/${{ matrix.target }}.sh" |
| 149 | + elif [[ '${{ matrix.target }}' = *'-darwin' ]]; then |
| 150 | + curl \ |
| 151 | + --silent \ |
| 152 | + --show-error \ |
| 153 | + --fail \ |
| 154 | + --url 'https://raw.githubusercontent.com/AmanoTeam/darwin-clang-cross/refs/heads/master/main.sh' \ |
| 155 | + | bash -s -- install |
| 156 | + |
| 157 | + export DARWIN_HOME='/tmp/darwin-clang-cross' |
| 158 | + export PATH="${DARWIN_HOME}/bin:${PATH}" |
| 159 | + |
| 160 | + source "${DARWIN_HOME}/build/autotools/${{ matrix.target }}.sh" |
| 161 | + elif [[ '${{ matrix.target }}' = *'-android'* ]]; then |
| 162 | + declare -r PINO_TAG='gcc-16' |
| 163 | + declare -r PINO_TARBALL='/tmp/toolchain.tar.xz' |
| 164 | + declare -r PINO_URL="https://github.com/AmanoTeam/Pino/releases/download/${PINO_TAG}/x86_64-unknown-linux-gnu.tar.xz" |
| 165 | + |
| 166 | + curl --connect-timeout '10' --retry '15' --retry-all-errors --fail --silent --location --url "${PINO_URL}" --output "${PINO_TARBALL}" |
| 167 | + tar --directory="$(dirname "${PINO_TARBALL}")" --extract --file="${PINO_TARBALL}" |
| 168 | + |
| 169 | + export PINO_HOME='/tmp/android-gcc-cross' |
| 170 | + export PATH="${PINO_HOME}/bin:${PATH}" |
| 171 | + |
| 172 | + source "${PINO_HOME}/build/autotools/${{ matrix.target }}.sh" |
| 173 | + fi |
| 174 | + |
| 175 | + echo "CROSS_COMPILE_TRIPLET=${CROSS_COMPILE_TRIPLET}" >> "${GITHUB_ENV}" |
| 176 | + |
| 177 | + bash './build.sh' "${CROSS_COMPILE_TRIPLET}" |
| 178 | + - name: Create logs |
| 179 | + if: always() |
| 180 | + run: | |
| 181 | + declare logs='' |
| 182 | + |
| 183 | + while read file; do |
| 184 | + logs+="${file} " |
| 185 | + done <<< $(find "/tmp/"*"/build" -wholename '*.log' -o -wholename '*.yaml' -o -wholename '*Makefile') |
| 186 | + |
| 187 | + tar --create --file=- ${logs} | xz --threads='0' --compress -9 > '/tmp/logs.tar.xz' |
| 188 | + - name: Upload logs |
| 189 | + if: always() |
| 190 | + uses: actions/upload-artifact@main |
| 191 | + with: |
| 192 | + name: ${{ matrix.target }}-logs |
| 193 | + if-no-files-found: error |
| 194 | + path: | |
| 195 | + /tmp/logs.tar.xz |
| 196 | + - name: Generate tarball |
| 197 | + run: | |
| 198 | + if [[ '${{ env.CROSS_COMPILE_TRIPLET }}' = *'-mingw32' ]]; then |
| 199 | + declare tarball_filename='/tmp/${{ env.CROSS_COMPILE_TRIPLET }}.7z' |
| 200 | + cd '/tmp' |
| 201 | + 7z a "${tarball_filename}" 'autotools' \ |
| 202 | + -t7z \ |
| 203 | + -mx=9 \ |
| 204 | + -m0=lzma2:d=128m:fb=128 \ |
| 205 | + -ms=on \ |
| 206 | + -mmt="$(nproc)" |
| 207 | + else |
| 208 | + declare tarball_filename='/tmp/${{ env.CROSS_COMPILE_TRIPLET }}.tar.xz' |
| 209 | + tar --directory='/tmp' --create --file=- 'autotools' | xz --threads='0' --extreme --memlimit-compress='100%' --compress -9 > "${tarball_filename}" |
| 210 | + fi |
| 211 | + sha256sum "${tarball_filename}" | sed 's|/tmp/||' > "${tarball_filename}.sha256" |
| 212 | + - name: Upload artifact |
| 213 | + uses: actions/upload-artifact@main |
| 214 | + with: |
| 215 | + name: ${{ env.CROSS_COMPILE_TRIPLET }} |
| 216 | + if-no-files-found: error |
| 217 | + path: | |
| 218 | + /tmp/${{ env.CROSS_COMPILE_TRIPLET }}.* |
| 219 | +
|
| 220 | + release: |
| 221 | + needs: cross-build |
| 222 | + runs-on: ubuntu-latest |
| 223 | + name: Create release |
| 224 | + steps: |
| 225 | + - name: Download all artifacts |
| 226 | + uses: actions/download-artifact@main |
| 227 | + - name: Create release |
| 228 | + uses: softprops/action-gh-release@master |
| 229 | + with: |
| 230 | + tag_name: rolling |
| 231 | + name: 'GCC tools' |
| 232 | + files: ./*/*-{unknown,w64,apple}-*.{tar.xz,7z}* |
| 233 | + draft: false |
| 234 | + prerelease: false |
| 235 | + fail_on_unmatched_files: true |
| 236 | + body: '* Initial release' |
| 237 | + env: |
| 238 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 239 | + |
0 commit comments