Skip to content

Commit

Permalink
Build and upload examples on push and when bindings are updated
Browse files Browse the repository at this point in the history
  • Loading branch information
pheki committed Jun 18, 2023
1 parent b06da77 commit 9a59ba3
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 25 deletions.
83 changes: 83 additions & 0 deletions .github/workflows/build-example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Build example

on:
push:
workflow_dispatch:

jobs:
install-vitasdk:
uses: ./.github/workflows/setup-vitasdk.yml
with:
path: /opt/vitasdk

build-example:
name: Build example
runs-on: ubuntu-latest
needs: install-vitasdk
steps:
- uses: actions/checkout@v3
with:
submodules: true

- name: Restore vitasdk cache
uses: actions/cache/restore@v3
with:
path: /opt/vitasdk
key: ${{ runner.os }}-vitasdk
fail-on-cache-miss: true

- name: Cache generator depenedencies
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
example/std-hello-world/target/
key: ${{ runner.os }}-cargo-example-${{ hashFiles('example/std-hello-world/Cargo.lock') }}

- name: Install cargo-make
# Installation fails if cargo-make is cached
continue-on-error: true
run: |
cargo install cargo-make
- name: Install rust nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
profile: minimal
components: rust-src

- name: Add Vita SDK tools to path
run: |
echo "/opt/vitasdk/bin" >> $GITHUB_PATH
- name: Build example in debug mode
env:
VITASDK: /opt/vitasdk
run: |
cd examples/std-hello-world
cargo +nightly make vpk
- name: Build example in release mode
env:
VITASDK: /opt/vitasdk
run: |
cd examples/std-hello-world
cargo +nightly make --profile release vpk
- name: Upload debug build
uses: actions/upload-artifact@v3
with:
name: std-hello-world-debug-build
path: examples/std-hello-world/target/armv7-sony-vita-newlibeabihf/debug/std-hello-world.*
if-no-files-found: error

- name: Upload release build
uses: actions/upload-artifact@v3
with:
name: std-hello-world-release-build
path: examples/std-hello-world/target/armv7-sony-vita-newlibeabihf/release/std-hello-world.*
if-no-files-found: error
36 changes: 36 additions & 0 deletions .github/workflows/setup-vitasdk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Setup Vita SDK

on:
workflow_call:
inputs:
path:
required: true
type: string

jobs:
# This job is also on update-bindings.yml. If you
install-vitasdk:
name: Install Vita SDK
runs-on: ubuntu-latest
steps:
- name: Cache vitasdk
id: cache
uses: actions/cache@v3
with:
path: ${{ inputs.path }}
# Don't really know a good key to use here, but the cache will be
# deleted automatically if it's not used for a week.
key: ${{ runner.os }}-vitasdk

- name: Checkout VPDM
uses: actions/checkout@v3
with:
repository: vitasdk/vdpm

- name: Install
if: steps.cache.outputs.cache-hit != 'true'
env:
VITASDK: ${{ inputs.path }}
run: |
./bootstrap-vitasdk.sh
./install-all.sh
33 changes: 8 additions & 25 deletions .github/workflows/update-bindings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,9 @@ on: workflow_dispatch

jobs:
install-vitasdk:
name: Install Vita SDK
runs-on: ubuntu-latest
steps:
- name: Cache vitasdk
id: cache
uses: actions/cache@v3
with:
path: /opt/vitasdk
# Don't really know a good key to use here, but the cache will be
# deleted automatically if it's not used for a week.
key: ${{ runner.os }}-vitasdk

- name: Checkout VPDM
uses: actions/checkout@v3
with:
repository: vitasdk/vdpm

- name: Install
if: steps.cache.outputs.cache-hit != 'true'
env:
VITASDK: /opt/vitasdk
run: |
./bootstrap-vitasdk.sh
./install-all.sh
uses: ./.github/workflows/setup-vitasdk.yml
with:
path: /opt/vitasdk

update-and-regenrate:
name: Update and regenerate
Expand Down Expand Up @@ -69,7 +48,7 @@ jobs:
~/.cargo/registry/cache/
~/.cargo/git/db/
generator/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('generator/Cargo.lock') }}
key: ${{ runner.os }}-cargo-generator-${{ hashFiles('generator/Cargo.lock') }}

- name: Update vita-headers
run: |
Expand All @@ -88,6 +67,9 @@ jobs:
cargo fmt
- name: Commit
env:
# Required by Github CLI (`gh`)
GH_TOKEN: ${{ github.token }}
# Do not fail when there's nothing to commit
continue-on-error: true
run: |
Expand All @@ -97,3 +79,4 @@ jobs:
VITA_HEADERS_HASH=$(git submodule status | grep generator/vita-headers | cut -d ' ' -f 2)
git commit -m "Update vita-headers to $VITA_HEADERS_HASH"
git push
gh workflow run build-example.yml --ref ${GITHUB_REF}

0 comments on commit 9a59ba3

Please sign in to comment.