Skip to content

Unify build scripts #137

Unify build scripts

Unify build scripts #137

Workflow file for this run

name: Build
on:
workflow_dispatch:
branches:
- '**'
push:
branches:
- '**'
jobs:
native-build:
name: 'Native build'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
with:
submodules: true
- name: Check for cache
id: check-cache
uses: actions/cache@main
with:
key: gcc-15
lookup-only: true
path: |
/tmp/x86_64-linux-gnu.tar.xz
/tmp/x86_64-linux-gnu.tar.xz.sha256
- name: Build Venti
if: ${{ steps.check-cache.outputs.cache-hit != 'true' }}
run: |
bash './build.sh' 'native'
- name: Create logs
if: always()
run: |
declare logs=''
while read file; do
logs+="${file} "
done <<< $(find "/tmp/"*"/build" -wholename '*/config.log')
tar --create --file=- ${logs} | xz --threads='0' --compress -9 > '/tmp/logs.tar.xz'
- name: Upload logs
if: always()
uses: actions/upload-artifact@main
with:
name: logs
if-no-files-found: error
path: |
/tmp/logs.tar.xz
- name: Generate tarball
if: ${{ steps.check-cache.outputs.cache-hit != 'true' }}
run: |
declare tarball_filename='/tmp/x86_64-linux-gnu.tar.xz'
tar --directory='/tmp' --create --file=- 'venti' | xz --threads='0' --compress -9 > "${tarball_filename}"
sha256sum "${tarball_filename}" | sed 's|/tmp/||' > "${tarball_filename}.sha256"
- name: Upload artifact
if: ${{ steps.check-cache.outputs.cache-hit != 'true' }}
uses: actions/upload-artifact@main
with:
name: native-toolchain
if-no-files-found: error
path: |
/tmp/x86_64-linux-gnu.tar.xz
/tmp/x86_64-linux-gnu.tar.xz.sha256
- name: Cache artifact
if: ${{ steps.check-cache.outputs.cache-hit != 'true' }}
uses: actions/cache@main
with:
key: gcc-15
path: |
/tmp/x86_64-linux-gnu.tar.xz
/tmp/x86_64-linux-gnu.tar.xz.sha256
cross-build:
name: 'Cross build'
needs: native-build
runs-on: ubuntu-latest
continue-on-error: true
strategy:
matrix:
target: [
# macOS
'aarch64-unknown-apple-darwin',
'x86_64-unknown-apple-darwin',
# Linux (glibc)
'x86_64-unknown-linux-gnu',
'i386-unknown-linux-gnu',
'arm-unknown-linux-gnueabi',
'arm-unknown-linux-gnueabihf',
'aarch64-unknown-linux-gnu',
# Linux (musl)
'aarch64-unknown-linux-musl',
'x86_64-unknown-linux-musl',
'armv6-unknown-linux-musleabihf',
'armv7-unknown-linux-musleabihf',
'i386-unknown-linux-musl',
# FreeBSD
'x86_64-unknown-freebsd',
'aarch64-unknown-freebsd',
'i386-unknown-freebsd',
# NetBSD
'i386-unknown-netbsdelf',
'x86_64-unknown-netbsd',
'aarch64-unknown-netbsd',
# DragonFly BSD
'x86_64-unknown-dragonfly',
# Android
'x86_64-unknown-linux-android',
'i686-unknown-linux-android21',
'aarch64-unknown-linux-android',
'riscv64-unknown-linux-android',
'armv7-unknown-linux-androideabi21',
]
steps:
- uses: actions/checkout@main
with:
submodules: true
- name: Restore from cache
uses: actions/cache@main
with:
key: gcc-15
fail-on-cache-miss: true
path: |
/tmp/x86_64-linux-gnu.tar.xz
/tmp/x86_64-linux-gnu.tar.xz.sha256
- name: Setup toolchain
run: |
tar --directory='/tmp' --extract --file='/tmp/x86_64-linux-gnu.tar.xz'
mv '/tmp/venti' '/tmp/venti-toolchain'
- name: Cross-compile Venti to ${{ matrix.target }}
run: |
source './tools/setup_toolchain.sh'
if [[ '${{ matrix.target }}' = *'-linux-musl'* ]]; then
declare -r RAIDEN_TAG='gcc-15'
declare -r RAIDEN_TARBALL='/tmp/toolchain.tar.xz'
declare -r RAIDEN_URL="https://github.com/AmanoTeam/Raiden/releases/download/${RAIDEN_TAG}/x86_64-unknown-linux-gnu.tar.xz"
curl --show-error --connect-timeout '10' --retry '15' --retry-all-errors --fail --silent --location --url "${RAIDEN_URL}" --output "${RAIDEN_TARBALL}"
tar --directory="$(dirname "${RAIDEN_TARBALL}")" --extract --file="${RAIDEN_TARBALL}"
export RAIDEN_HOME='/tmp/raiden'
export PATH="${RAIDEN_HOME}/bin:${PATH}"
source "${RAIDEN_HOME}/build/autotools/${{ matrix.target }}.sh"
elif [[ '${{ matrix.target }}' = *'-linux-gnu'* ]]; then
declare -r OBGGCC_TAG='gcc-16'
declare -r OBGGCC_TARBALL='/tmp/toolchain.tar.xz'
declare -r OBGGCC_URL="https://github.com/AmanoTeam/obggcc/releases/download/${OBGGCC_TAG}/x86_64-unknown-linux-gnu.tar.xz"
curl --show-error --connect-timeout '10' --retry '15' --retry-all-errors --fail --silent --location --url "${OBGGCC_URL}" --output "${OBGGCC_TARBALL}"
tar --directory="$(dirname "${OBGGCC_TARBALL}")" --extract --file="${OBGGCC_TARBALL}"
export OBGGCC_HOME='/tmp/obggcc'
export PATH="${OBGGCC_HOME}/bin:${PATH}"
source "${OBGGCC_HOME}/build/autotools/${{ matrix.target }}.sh"
elif [[ '${{ matrix.target }}' = *'-freebsd' ]]; then
declare -r LOKI_TAG='gcc-15'
declare -r LOKI_TARBALL='/tmp/toolchain.tar.xz'
declare -r LOKI_URL="https://github.com/AmanoTeam/Loki/releases/download/${LOKI_TAG}/x86_64-unknown-linux-gnu.tar.xz"
curl --silent --connect-timeout '10' --retry '15' --retry-all-errors --fail --location --url "${LOKI_URL}" --output "${LOKI_TARBALL}"
tar --directory="$(dirname "${LOKI_TARBALL}")" --extract --file="${LOKI_TARBALL}"
export LOKI_HOME='/tmp/loki'
export PATH="${LOKI_HOME}/bin:${PATH}"
source "${LOKI_HOME}/build/autotools/${{ matrix.target }}.sh"
elif [[ '${{ matrix.target }}' = *'-netbsd'* ]]; then
declare -r DAKINI_TAG='gcc-15'
declare -r DAKINI_TARBALL='/tmp/toolchain.tar.xz'
declare -r DAKINI_URL="https://github.com/AmanoTeam/Dakini/releases/download/${DAKINI_TAG}/x86_64-unknown-linux-gnu.tar.xz"
curl --show-error --connect-timeout '10' --retry '15' --retry-all-errors --fail --silent --location --url "${DAKINI_URL}" --output "${DAKINI_TARBALL}"
tar --directory="$(dirname "${DAKINI_TARBALL}")" --extract --file="${DAKINI_TARBALL}"
export DAKINI_HOME='/tmp/dakini'
export PATH="${DAKINI_HOME}/bin:${PATH}"
source "${DAKINI_HOME}/build/autotools/${{ matrix.target }}.sh"
elif [[ '${{ matrix.target }}' = *'-dragonfly' ]]; then
# declare -r VENTI_TAG='gcc-15'
# declare -r VENTI_TARBALL='/tmp/toolchain.tar.xz'
# declare -r VENTI_URL="https://github.com/AmanoTeam/Venti/releases/download/${VENTI_TAG}/x86_64-unknown-linux-gnu.tar.xz"
# curl --show-error --connect-timeout '10' --retry '15' --retry-all-errors --fail --silent --location --url "${VENTI_URL}" --output "${VENTI_TARBALL}"
# tar --directory="$(dirname "${VENTI_TARBALL}")" --extract --file="${VENTI_TARBALL}"
# export VENTI_HOME='/tmp/venti'
export PATH="${VENTI_HOME}/bin:${PATH}"
source "${VENTI_HOME}/build/autotools/${{ matrix.target }}.sh"
elif [[ '${{ matrix.target }}' = *'-haiku' ]]; then
declare -r SIL_TAG='gcc-15'
declare -r SIL_TARBALL='/tmp/toolchain.tar.xz'
declare -r SIL_URL="https://github.com/AmanoTeam/Sil/releases/download/${SIL_TAG}/x86_64-unknown-linux-gnu.tar.xz"
curl --show-error --connect-timeout '10' --retry '15' --retry-all-errors --fail --silent --location --url "${SIL_URL}" --output "${SIL_TARBALL}"
tar --directory="$(dirname "${SIL_TARBALL}")" --extract --file="${SIL_TARBALL}"
export SIL_HOME='/tmp/sil'
export PATH="${SIL_HOME}/bin:${PATH}"
source "${SIL_HOME}/build/autotools/${{ matrix.target }}.sh"
elif [[ '${{ matrix.target }}' = *'-android'* ]]; then
declare -r PINO_TAG='gcc-15'
declare -r PINO_TARBALL='/tmp/toolchain.tar.xz'
declare -r PINO_URL="https://github.com/AmanoTeam/Pino/releases/download/${PINO_TAG}/x86_64-unknown-linux-gnu.tar.xz"
curl --show-error --connect-timeout '10' --retry '15' --retry-all-errors --fail --silent --location --url "${PINO_URL}" --output "${PINO_TARBALL}"
tar --directory="$(dirname "${PINO_TARBALL}")" --extract --file="${PINO_TARBALL}"
export PINO_HOME='/tmp/pino'
export PATH="${PINO_HOME}/bin:${PATH}"
source "${PINO_HOME}/build/autotools/${{ matrix.target }}.sh"
elif [[ '${{ matrix.target }}' = *'-darwin' ]]; then
curl \
--silent \
--show-error \
--fail \
--url 'https://raw.githubusercontent.com/AmanoTeam/OSXCross-Builds/refs/heads/master/main.sh' \
| bash -s -- install
export DARWIN_HOME='/tmp/darwin'
export PATH="${DARWIN_HOME}/bin:${PATH}"
source "${DARWIN_HOME}/build/autotools/${{ matrix.target }}.sh"
fi
bash './build.sh' '${{ matrix.target }}'
- name: Create logs
if: always()
run: |
declare logs=''
while read file; do
logs+="${file} "
done <<< $(find "/tmp/"*"/build" -wholename '*/config.log')
tar --create --file=- ${logs} | xz --threads='0' --compress -9 > '/tmp/logs.tar.xz'
- name: Upload logs
if: always()
uses: actions/upload-artifact@main
with:
name: ${{ matrix.target }}-logs
if-no-files-found: error
path: |
/tmp/logs.tar.xz
- name: Generate tarball
run: |
declare tarball_filename='/tmp/${{ matrix.target }}.tar.xz'
tar --directory='/tmp' --create --file=- 'venti' | xz --threads='0' --compress -9 > "${tarball_filename}"
sha256sum "${tarball_filename}" | sed 's|/tmp/||' > "${tarball_filename}.sha256"
- name: Upload artifact
uses: actions/upload-artifact@main
with:
name: ${{ matrix.target }}
if-no-files-found: error
path: |
/tmp/${{ matrix.target }}.tar.xz
/tmp/${{ matrix.target }}.tar.xz.sha256
release:
needs: cross-build
runs-on: ubuntu-latest
name: Create release
steps:
- name: Download all artifacts
uses: actions/download-artifact@main
- name: Create release
uses: softprops/action-gh-release@master
with:
tag_name: gcc-15
name: GCC 15
files: ./*/*-unknown-*.tar.xz*
draft: false
prerelease: false
fail_on_unmatched_files: true
body: "* Update to GCC 15"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}