Fix toolchain build script #87
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
# The GCC toolchain is stored in the GitHub Actions cache after being built. To | |
# minimize build times, all the toolchain build steps are skipped if there is a | |
# cached copy of the toolchain that has not expired. The cache is shared across | |
# all actions in a repo. | |
name: Build PSn00bSDK | |
on: [ push, pull_request ] | |
jobs: | |
build-toolchain: | |
name: Build GCC toolchain | |
runs-on: ubuntu-latest | |
steps: | |
- name: Initialize toolchain cache | |
id: cache | |
uses: actions/[email protected] | |
with: | |
enableCrossOsArchive: true | |
key: gcc | |
path: gcc | |
- name: Install prerequisites | |
if: ${{ steps.cache.outputs.cache-hit != 'true' }} | |
run: | | |
sudo apt-get update -y | |
sudo apt-get install -y --no-install-recommends make g++-mingw-w64-x86-64 | |
- name: Fetch repo contents | |
if: ${{ steps.cache.outputs.cache-hit != 'true' }} | |
uses: actions/checkout@v4 | |
with: | |
path: psn00bsdk | |
- name: Build toolchain for Linux | |
if: ${{ steps.cache.outputs.cache-hit != 'true' }} | |
run: | | |
cd gcc | |
../psn00bsdk/.github/scripts/build_toolchain.sh gcc-mipsel-none-elf-linux mipsel-none-elf | |
echo "${{ github.workspace }}/gcc/gcc-mipsel-none-elf-linux/bin" >>$GITHUB_PATH | |
- name: Build toolchain for Windows | |
if: ${{ steps.cache.outputs.cache-hit != 'true' }} | |
run: | | |
cd gcc | |
../psn00bsdk/.github/scripts/build_toolchain.sh gcc-mipsel-none-elf-windows mipsel-none-elf x86_64-w64-mingw32 | |
build-psn00bsdk-windows: | |
name: Build PSn00bSDK on Windows | |
runs-on: windows-2022 | |
needs: build-toolchain | |
steps: | |
- name: Add MSys2 to PATH | |
run: | | |
echo "C:\msys64\mingw64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append | |
echo "C:\msys64\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append | |
- name: Initialize toolchain cache | |
uses: actions/[email protected] | |
with: | |
enableCrossOsArchive: true | |
key: gcc | |
path: gcc | |
- name: Install prerequisites | |
run: | | |
pacman -S --noconfirm mingw-w64-x86_64-ninja | |
- name: Fetch repo contents | |
uses: actions/checkout@v4 | |
with: | |
path: psn00bsdk | |
submodules: recursive | |
- name: Build and package PSn00bSDK | |
run: | | |
cmake --preset ci -S psn00bsdk -G "Visual Studio 17 2022" -DPSN00BSDK_TC=${{ github.workspace }}\gcc\gcc-mipsel-none-elf-windows | |
cmake --build build | |
cmake --install build | |
cd dist | |
zip -9 -r ../psn00bsdk-windows-${{ github.ref_name }}.zip . | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: psn00bsdk-windows | |
path: psn00bsdk-windows-${{ github.ref_name }}.zip | |
build-psn00bsdk-linux: | |
name: Build PSn00bSDK on Linux | |
runs-on: ubuntu-latest | |
needs: build-toolchain | |
steps: | |
- name: Initialize toolchain cache | |
uses: actions/[email protected] | |
with: | |
enableCrossOsArchive: true | |
key: gcc | |
path: gcc | |
- name: Install prerequisites | |
run: | | |
sudo apt-get update -y | |
sudo apt-get install -y --no-install-recommends ninja-build | |
- name: Fetch repo contents | |
uses: actions/checkout@v4 | |
with: | |
path: psn00bsdk | |
submodules: recursive | |
- name: Build and package PSn00bSDK | |
run: | | |
cmake --preset ci -S psn00bsdk -G "Ninja" -DPSN00BSDK_TC=${{ github.workspace }}/gcc/gcc-mipsel-none-elf-linux | |
cmake --build build | |
cmake --install build | |
cd dist | |
zip -9 -r ../psn00bsdk-linux-${{ github.ref_name }}.zip . | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: psn00bsdk-linux | |
path: psn00bsdk-linux-${{ github.ref_name }}.zip | |
# This job takes care of creating a new release and upload the build | |
# artifacts if the last commit is associated to a tag. | |
create-release: | |
name: Create release | |
runs-on: ubuntu-latest | |
needs: [ build-psn00bsdk-windows, build-psn00bsdk-linux ] | |
steps: | |
- name: Initialize toolchain cache | |
if: ${{ github.ref_type == 'tag' }} | |
uses: actions/[email protected] | |
with: | |
enableCrossOsArchive: true | |
key: gcc | |
path: gcc | |
- name: Fetch repo contents | |
if: ${{ github.ref_type == 'tag' }} | |
uses: actions/checkout@v4 | |
with: | |
path: psn00bsdk | |
- name: Generate release notes | |
if: ${{ github.ref_type == 'tag' }} | |
run: | | |
python3 psn00bsdk/.github/scripts/generate_release_notes.py -v ${{ github.ref_name }} -o release.md psn00bsdk/CHANGELOG.md | |
- name: Fetch build artifacts | |
if: ${{ github.ref_type == 'tag' }} | |
uses: actions/download-artifact@v4 | |
with: | |
path: . | |
- name: Publish release | |
if: ${{ github.ref_type == 'tag' }} | |
uses: softprops/action-gh-release@v1 | |
with: | |
#fail_on_unmatched_files: true | |
body_path: release.md | |
files: | | |
gcc/*.zip | |
psn00bsdk-windows/*.zip | |
psn00bsdk-linux/*.zip |