gbe_fork/.github/workflows/build-linux.yml

188 lines
5.8 KiB
YAML
Raw Normal View History

2023-12-16 17:50:30 +02:00
name: Emu build (Linux)
on:
push:
branches: [
"ci-build-emu-linux*",
"ci-build-all"
]
tags:
- release*
pull_request:
branches: [ "dev" ]
workflow_dispatch:
# allows manual trigger
permissions:
contents: write
env:
DEPS_CACHE_KEY: emu-deps-linux
DEPS_CACHE_DIR: build/deps/linux
PACKAGE_BASE_DIR: "build/package/linux"
THIRD_PARTY_BASE_DIR: 'third-party'
jobs:
# this helps in manual runs, if build fails, then deps are saved
dependencies:
runs-on: ubuntu-22.04
# cache but not for tags or PRs
# !tag && !pull_request
# also you could use this: github.event_name != 'pull_request'
if: |
!startsWith(github.ref, 'refs/tags/') &&
!startsWith(github.ref, 'refs/pull/')
steps:
# we need branch because it has build scripts
- name: Checkout branch
uses: actions/checkout@v4
### fix folder permissions! not sure why this fails
# nested subdirs "build/linux/release" cause permission problems
- name: Give all permissions for repo folder
shell: bash
working-directory: ${{ github.workspace }}
run: sudo chmod -R 777 "${{ github.workspace }}"
- name: Lookup cache for deps
id: emu-deps-cache-step
uses: actions/cache@v3
with:
key: ${{ env.DEPS_CACHE_KEY }}
path: ${{ env.DEPS_CACHE_DIR }}
lookup-only: true # don't restore cache if found
- name: Clone third-party deps (deps/linux)
if: steps.emu-deps-cache-step.outputs.cache-hit != 'true'
uses: actions/checkout@v4
with:
ref: 'third-party/deps/linux'
path: "${{env.THIRD_PARTY_BASE_DIR}}/deps/linux"
- name: Clone third-party deps (deps/common)
if: steps.emu-deps-cache-step.outputs.cache-hit != 'true'
uses: actions/checkout@v4
with:
ref: 'third-party/deps/common'
path: "${{env.THIRD_PARTY_BASE_DIR}}/deps/common"
- name: Build deps
if: steps.emu-deps-cache-step.outputs.cache-hit != 'true'
shell: bash
run: sudo chmod 777 build_linux_deps.sh && sudo ./build_linux_deps.sh
build:
runs-on: ubuntu-22.04
needs: [ dependencies ]
steps:
- name: Checkout branch
uses: actions/checkout@v4
### fix folder permissions! not sure why this fails
# nested subdirs "build/linux/release" cause permission problems
- name: Give all permissions for repo folder
shell: bash
working-directory: ${{ github.workspace }}
run: sudo chmod -R 777 "${{ github.workspace }}"
### deps
- name: Lookup cache for deps
id: emu-deps-cache-step
# !tag && !pull_request
# also you could use this: github.event_name != 'pull_request'
if: |
!startsWith(github.ref, 'refs/tags/') &&
!startsWith(github.ref, 'refs/pull/')
uses: actions/cache@v3
with:
key: ${{ env.DEPS_CACHE_KEY }}
path: ${{ env.DEPS_CACHE_DIR }}
# attempt to download again because in tags/PRs no cache is created
- name: Clone third-party deps (deps/linux)
if: steps.emu-deps-cache-step.outputs.cache-hit != 'true'
uses: actions/checkout@v4
with:
ref: 'third-party/deps/linux'
path: "${{env.THIRD_PARTY_BASE_DIR}}/deps/linux"
- name: Clone third-party deps (deps/common)
if: steps.emu-deps-cache-step.outputs.cache-hit != 'true'
uses: actions/checkout@v4
with:
ref: 'third-party/deps/common'
path: "${{env.THIRD_PARTY_BASE_DIR}}/deps/common"
- name: Build deps
if: steps.emu-deps-cache-step.outputs.cache-hit != 'true'
shell: bash
run: sudo chmod 777 build_linux_deps.sh && sudo ./build_linux_deps.sh
## mandatory Linux packages, installed via sudo apt install ...
- name: Install required packages
shell: bash
run: sudo chmod 777 build_linux_deps.sh && sudo ./build_linux_deps.sh -packages_only
## extra helpers/tools, these are not built inside the deps build dir
- name: Clone third-party build helpers (build/linux)
uses: actions/checkout@v4
with:
ref: 'third-party/build/linux'
path: "${{env.THIRD_PARTY_BASE_DIR}}/build/linux"
### build (release mode)
- name: Build release mode
shell: bash
working-directory: ${{ github.workspace }}
run: "sudo chmod 777 build_linux.sh && ./build_linux.sh release"
### package (release mode)
- name: Package build (release)
shell: bash
working-directory: ${{ github.workspace }}
run: sudo chmod 77 package_linux.sh && sudo ./package_linux.sh release
### upload artifact/package to github Actions (release mode)
- name: Upload build pacakge (release)
uses: actions/upload-artifact@v4
with:
name: "build-linux-release-${{ github.sha }}"
path: "${{ env.PACKAGE_BASE_DIR }}/release/"
if-no-files-found: 'error'
compression-level: 9
retention-days: 1
### build (debug mode)
- name: Build debug mode
shell: bash
working-directory: ${{ github.workspace }}
run: "sudo chmod 777 build_linux.sh && ./build_linux.sh debug"
### package (debug mode)
- name: Package build (debug)
shell: bash
working-directory: ${{ github.workspace }}
run: sudo chmod 77 package_linux.sh && sudo ./package_linux.sh debug
### upload artifact/package to github Actions (debug mode)
- name: Upload build pacakge (debug)
uses: actions/upload-artifact@v4
with:
name: "build-linux-debug-${{ github.sha }}"
path: "${{ env.PACKAGE_BASE_DIR }}/debug/"
if-no-files-found: 'error'
compression-level: 9
retention-days: 1
### release (debug + release modes) if this is a tag push
- name: Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
with:
files: "${{ env.PACKAGE_BASE_DIR }}/**/*"