Build cross compilers #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build cross compilers | |
'on': | |
workflow_dispatch: | |
inputs: | |
release: | |
description: Release tag and name | |
required: true | |
do_release: | |
description: Create a release and upload files | |
required: true | |
default: false | |
type: boolean | |
update_existing: | |
description: Update existing release | |
required: true | |
default: true | |
type: boolean | |
repo: | |
description: Build repository | |
required: true | |
default: both | |
type: choice | |
options: | |
- both | |
- richfelker/musl-cross-make | |
- userdocs/qbt-musl-cross-make | |
target: | |
description: Target name (leave empty to build all) | |
jobs: | |
prepare: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
outputs: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
matrix_repos: ${{ steps.triples.outputs.matrix_repos }} | |
matrix_targets: ${{ steps.triples.outputs.matrix_targets }} | |
steps: | |
- name: Create release | |
uses: ncipollo/release-action@v1 | |
id: create_release | |
if: '${{ github.event.inputs.do_release }}' | |
with: | |
allowUpdates: '${{ github.event.inputs.update_existing }}' | |
tag: '${{ github.event.inputs.release }}' | |
name: '${{ github.event.inputs.release }}' | |
draft: false | |
prerelease: false | |
env: | |
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' | |
- name: Bootstrap the matrix | |
id: triples | |
run: | | |
if [ "${{ github.event.inputs.repo }}" = "both" ]; then | |
echo "matrix_repos=['richfelker/musl-cross-make', 'userdocs/qbt-musl-cross-make']" >> $GITHUB_OUTPUT | |
else | |
echo "matrix_repos=['${{ github.event.inputs.repo }}']" >> $GITHUB_OUTPUT | |
fi | |
if [ -z "${{ github.event.inputs.target }}" ]; then | |
echo "matrix_targets=$(jq -R -s 'split("\n") | map(select(length > 0))' .github/build/targets.txt)" >> $GITHUB_OUTPUT | |
else | |
echo "matrix_targets=['${{ github.event.inputs.target }}']" >> $GITHUB_OUTPUT | |
fi | |
compile: | |
needs: prepare | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
continue-on-error: true | |
strategy: | |
matrix: | |
target: ${{ fromJson(needs.prepare.outputs.matrix_targets) }} | |
repo: ${{ fromJson(needs.prepare.outputs.matrix_repos) }} | |
exclude: | |
# Exclude unsupported targets | |
- target: loongarch64-linux-musl | |
repo: richfelker/musl-cross-make | |
env: | |
TARGET: ${{ matrix.target }} | |
REPO: ${{ matrix.repo }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: 'Clone ${{ matrix.repo }}' | |
run: 'git clone https://github.com/${{ matrix.repo }} mcm' | |
- name: Set ${{ matrix.target }} musl with configurations | |
if: matrix.repo == 'userdocs/qbt-musl-cross-make' | |
run: | | |
export CONFIGURE=$(jq ".[\"${{ matrix.target }}\"]" .github/build/configures.json) | |
if [ "$CONFIGURE" ]; then | |
echo "Add configuration $CONFIGURE" | |
sed "s|GCC_CONFIG_FOR_TARGET +=|GCC_CONFIG_FOR_TARGET += $CONFIGURE|" -i mcm/config.mak | |
fi | |
- name: Disable binutils gold for loongarch64 | |
if: matrix.target == 'loongarch64-linux-musl' | |
run: sed "s| --enable-gold=yes||" -i config.mak | |
working-directory: mcm | |
- name: Show updated config.mak | |
run: cat config.mak | |
working-directory: mcm | |
- name: 'Build ${{ matrix.target }}' | |
run: |- | |
make -j4 | |
make install | |
ls output | |
working-directory: mcm | |
- name: 'Package ${{ matrix.target }}' | |
id: package | |
run: |- | |
tar -czvf ../output-${{ matrix.target }}.tar.gz output/ | |
echo "source_escaped=${REPO%%/*}_${REPO##*/}" >> $GITHUB_OUTPUT | |
working-directory: mcm | |
- id: upload-artifacts | |
name: Upload artifacts | |
if: '${{ success() }}' | |
uses: cytopia/[email protected] | |
with: | |
path: 'output-${{ matrix.target }}.tar.gz' | |
name: '${{ matrix.target }}-${{ steps.package.outputs.source_escaped }}' | |
- name: Rename artifact | |
run: mv output-${{ matrix.target }}.tar.gz output-${{ matrix.target }}-${{ steps.package.outputs.source_escaped }}.tar.gz | |
- id: upload-releases | |
name: Upload to releases | |
uses: ncipollo/release-action@v1 | |
if: '${{ github.event.inputs.do_release }}' | |
with: | |
allowUpdates: true | |
tag: '${{ github.event.inputs.release }}' | |
artifacts: 'output-${{ matrix.target }}*.tar.gz' | |
artifactContentType: application/gzip | |
env: | |
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' | |