Skip to content

Commit

Permalink
refactoring workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
mariotaku committed Mar 4, 2024
1 parent efa4242 commit 4548c01
Show file tree
Hide file tree
Showing 3 changed files with 146 additions and 80 deletions.
65 changes: 65 additions & 0 deletions .github/actions/build-toolchain/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Build Toolchain
inputs:
machine:
required: true
type: string
os:
required: true
type: string
arch:
required: true
type: string
build-type:
default: Release
required: true
type: string

outputs:
install-prefix:
description: 'Installation prefix for the toolchain'
value: ${{steps.set-output.outputs.install-prefix}}

runs:
using: 'composite'
steps:
- name: Install GCC 12 (Linux)
if: inputs.os == 'linux'
shell: bash
run: |
sudo apt-get update -y
sudo apt-get install -y gcc-12 g++-12
- name: Set Parallel Level (macOS)
if: inputs.os == 'darwin'
shell: bash
run: echo "CMAKE_BUILD_PARALLEL_LEVEL=$(sysctl -n hw.logicalcpu)" >> $GITHUB_ENV

- name: Set Parallel Level
if: inputs.os == 'linux'
shell: bash
run: echo "CMAKE_BUILD_PARALLEL_LEVEL=$(nproc)" >> $GITHUB_ENV

- name: Configure CMake
shell: bash
run: |
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{inputs.build-type}} \
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/build/dist/arm-webos-linux-gnueabi_sdk-buildroot
env:
CC: 'gcc-12'
CXX: 'g++-12'
LANG: 'en_US.UTF-8'

- name: Build
shell: bash
run: cmake --build ${{github.workspace}}/build --config ${{inputs.build-type}}
env:
LANG: 'en_US.UTF-8'

- name: Install
shell: bash
run: cmake --install ${{github.workspace}}/build

- name: Set Output
id: set-output
shell: bash
run: echo "install-prefix=${{github.workspace}}/build/dist/arm-webos-linux-gnueabi_sdk-buildroot" >> $GITHUB_OUTPUT
50 changes: 50 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Build

on:
workflow_dispatch:
inputs:
machine:
description: 'Host to build for'
required: true
type: choice
options:
- 'macos-12'
- 'macos-14'
- 'debian-arm64-latest'

jobs:
filter:
name: Select Build Host
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.result }}
steps:
- name: Set Output
id: set-matrix
uses: actions/github-script@v7
with:
script: |
const machines = [
{machine: 'macos-12', os: 'darwin', arch: 'x86_64', name: 'macOS x86_64'},
{machine: 'macos-14', os: 'darwin', arch: 'arm64', name: 'macOS ARM64'},
{machine: 'debian-arm64-latest', os: 'linux', arch: 'aarch64', name: 'Linux ARM64'}
];
return machines.filter(machine => machine.machine === '${{ github.event.inputs.machine }}');
build:
name: Build for ${{ matrix.name }}
needs: filter
strategy:
matrix:
include: ${{ fromJson(needs.filter.outputs.matrix) }}
runs-on: ${{ matrix.machine }}

steps:
- uses: actions/checkout@v4

- name: Build Toolchain
uses: './.github/actions/build-toolchain'
with:
machine: ${{ matrix.machine }}
os: ${{ matrix.os }}
arch: ${{ matrix.arch }}
111 changes: 31 additions & 80 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,101 +9,52 @@ permissions:

env:
BUILD_TYPE: Release
LANG: 'en_US.UTF-8'

jobs:
macos-x86_64:
name: macOS x86_64
runs-on: macos-12

steps:
- uses: actions/checkout@v4

- name: Download MacPorts
uses: robinraju/[email protected]
with:
repository: "macports/macports-base"
latest: true
fileName: "*-12-Monterey.pkg"
out-file-path: "/tmp"

- name: Install MacPorts
run: sudo installer -pkg /tmp/MacPorts-*.pkg -target /

- name: Add MacPorts to PATH
run: echo "/opt/local/bin:/opt/local/sbin" >> $GITHUB_PATH

- name: Install CMake and GCC
run: sudo port install cmake gcc12 gcc_select

- name: Configure GCC
run: sudo port select --set gcc mp-gcc12

- name: Set Parallel Level
run: echo "CMAKE_BUILD_PARALLEL_LEVEL=$(sysctl -n hw.logicalcpu)" >> $GITHUB_ENV

- name: Configure CMake
run: |
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/build/dist/arm-webos-linux-gnueabi_sdk-buildroot
env:
CC: '/opt/local/bin/gcc'
CXX: '/opt/local/bin/g++'

- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

- name: Install
run: cmake --install ${{github.workspace}}/build

- name: Make Tarball
run: |
cmake -E tar cjvf arm-webos-linux-gnueabi_sdk-buildroot_darwin-x86_64.tar.bz2 \
arm-webos-linux-gnueabi_sdk-buildroot
working-directory: ${{github.workspace}}/build/dist

- name: Create Release
uses: ncipollo/release-action@v1
with:
name: Release ${{ steps.tagName.outputs.tag }}
allowUpdates: true
omitNameDuringUpdate: true
omitBodyDuringUpdate: true
omitPrereleaseDuringUpdate: true
artifacts: ${{github.workspace}}/build/dist/arm-webos-linux-gnueabi_sdk-buildroot_darwin-x86_64.tar.bz2

linux-arm64:
name: Linux ARM64
runs-on: debian-arm64-latest

release:
name: Release for ${{ matrix.display-name }}
strategy:
matrix:
include:
- machine: 'macos-12'
os: 'darwin'
arch: 'x86_64'
display-name: macOS x86_64
- machine: 'macos-14'
os: 'darwin'
arch: 'arm64'
display-name: macOS ARM64
- machine: 'debian-arm64-latest'
os: 'linux'
arch: 'aarch64'
display-name: Linux ARM64
runs-on: ${{ matrix.machine }}
env:
LANG: 'en_US.UTF-8'
ARTIFACT_NAME: arm-webos-linux-gnueabi_sdk-buildroot_${{matrix.os}}-${{matrix.arch}}.tar.bz2

steps:
- uses: actions/checkout@v4

- name: Configure CMake
run: |
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/build/dist/arm-webos-linux-gnueabi_sdk-buildroot
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

- name: Install
run: cmake --install ${{github.workspace}}/build
- id: build-toolchain
name: Build Toolchain
uses: './.github/actions/build-toolchain'
with:
machine: ${{ matrix.machine }}
os: ${{ matrix.os }}
arch: ${{ matrix.arch }}

- name: Make Tarball
run: |
cmake -E tar cjvf arm-webos-linux-gnueabi_sdk-buildroot_linux-aarch64.tar.bz2 \
arm-webos-linux-gnueabi_sdk-buildroot
working-directory: ${{github.workspace}}/build/dist
cmake -E tar cjvf ${{env.ARTIFACT_NAME}} arm-webos-linux-gnueabi_sdk-buildroot
working-directory: ${{steps.build-toolchain.outputs.install-prefix}}

- name: Create Release
uses: ncipollo/release-action@v1
with:
name: Release ${{ steps.tagName.outputs.tag }}
name: Release ${{ github.event.release.tag_name }}
allowUpdates: true
omitNameDuringUpdate: true
omitBodyDuringUpdate: true
omitPrereleaseDuringUpdate: true
artifacts: ${{github.workspace}}/build/dist/arm-webos-linux-gnueabi_sdk-buildroot_linux-aarch64.tar.bz2
artifacts: ${{github.workspace}}/build/dist/${{env.ARTIFACT_NAME}}

0 comments on commit 4548c01

Please sign in to comment.