Skip to content

Update

Update #170

Workflow file for this run

name: Update
on:
workflow_dispatch:
inputs:
sdk:
description: "Version of Playdate SDK"
default: latest
type: string
required: true
source:
description: "Source ref used to build bindings. Uses `github.ref`` by default."
required: false
sha:
description: "Source SHA used to build bindings. Uses `github.sha`` by default."
required: false
# push:
# branches: [main, master]
schedule:
- cron: "0 0 * * 1"
env:
CARGO_INCREMENTAL: 1
CARGO_NET_RETRY: 10
RUSTUP_MAX_RETRIES: 10
CARGO_TERM_COLOR: always
CARGO_TERM_PROGRESS_WHEN: never
# logging:
CARGO_PLAYDATE_LOG: trace
# allow modify source for bindings generator:
PD_BUILD_PREBUILT: 1
permissions:
contents: write
jobs:
new-branch:
name: Branch
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Input
run: |
echo "ref: ${{ github.ref }}, ${{ github.ref_name }}"
echo "inputs: ${{ github.event.inputs.source }}, ${{ github.event.inputs.sha }}"
echo "default branch: ${{ github.event.repository.default_branch }}"
echo "Will checkout ${{ github.event.inputs.source || github.ref }}"
- name: Checkout Master
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.source || github.ref || github.event.repository.default_branch }}
- name: Base branch name
id: base
if: ${{ github.ref_type == 'branch' }}
run: echo "value=${{ github.ref_name }}" >> "$GITHUB_OUTPUT"
- name: Work branch name
id: work_branch
run: |
NAME_SUFFIX="${{ (github.ref_type == 'branch' && github.ref_name) || (github.event.inputs.sha || github.sha) }}"
echo "value=api/sys/pre-build/$NAME_SUFFIX" >> "$GITHUB_OUTPUT"
echo "suffix: '$NAME_SUFFIX'"
- name: Create Branch
id: branch
uses: peterjgrainger/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
branch: refs/heads/${{ steps.work_branch.outputs.value }}
sha: ${{ github.event.inputs.sha || github.sha }}
- name: Created
run: 'echo "Created: ${{ steps.branch.outputs.created }}"'
# if not created => rebase to master
- name: ReSync Branch
if: ${{ steps.branch.outputs.created == 'false' }}
uses: Joao208/[email protected]
with:
PERSONAL_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH_NAME: ${{ steps.work_branch.outputs.value }}
DEFAULT_BRANCH: ${{ github.event.inputs.source || steps.base.outputs.value || github.event.repository.default_branch }}
outputs:
working: ${{ steps.work_branch.outputs.value }}
base: ${{ github.event.inputs.source || steps.base.outputs.value || github.event.repository.default_branch }}
pre-gen-arm:
name: Gen (macos-arm64, all)
defaults:
run:
shell: bash
needs: new-branch
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Inputs
run: |
echo "I: SDK version: ${{ github.event.inputs.sdk }}"
echo "M: SDK version: ${{ github.event.inputs.sdk || 'latest' }}"
echo "Base branch: ${{ needs.new-branch.outputs.base }}"
echo "Working branch: ${{ needs.new-branch.outputs.working }}"
- name: Trigger
id: build
run: >-
RESPONSE_JSON=$(
echo '{
"appId": "650d74df35face92bc95f717",
"workflowId": "pre-gen",
"branch": "${{ needs.new-branch.outputs.working }}",
"labels": [ "gha" ],
"environment": {"variables": {"SDK_VERSION": "${{ github.event.inputs.sdk || 'latest' }}"}}
}' |
curl -s
-H "Content-Type: application/json"
-H "x-auth-token: ${{ secrets.CODEMAGIC_API_TOKEN }}"
-X POST https://api.codemagic.io/builds
-d @- |
jq -Rr 'fromjson | .buildId'
) &&
echo "build-id=$RESPONSE_JSON" >> "$GITHUB_OUTPUT" &&
echo "::notice title=Job URL::https://codemagic.io/app/650d74df35face92bc95f717/build/$RESPONSE_JSON"
- name: Build ID
run: |
echo "ID: ${{ steps.build.outputs.build-id }}"
echo "URL: https://codemagic.io/app/650d74df35face92bc95f717/build/${{ steps.build.outputs.build-id }}"
- name: Wait
uses: TSRBerry/unstable-commands@v1
with:
timeout-minutes: 6
max-retries: 20
retry-codes: "1"
commands: |
sleep 30 && \
RESPONSE=$(curl -s --fail -H "Content-Type: application/json" -H "x-auth-token: ${{ secrets.CODEMAGIC_API_TOKEN }}" --request GET "https://api.codemagic.io/builds/${{ steps.build.outputs.build-id }}")
JOB_STATUS=$(echo "$RESPONSE" | jq -Rr 'fromjson | .build.status' -)
echo "status: $JOB_STATUS"
JOB_STATUS_MD="External job status: [$JOB_STATUS](https://codemagic.io/app/650d74df35face92bc95f717/build/${{ steps.build.outputs.build-id }})"
echo "$JOB_STATUS_MD" > $GITHUB_STEP_SUMMARY
echo "$RESPONSE" | jq -R 'fromjson | .build.status == "finished"' --exit-status -
pre-gen:
name: Gen (${{ matrix.os }}, ${{ matrix.features.name }})
defaults:
run:
shell: bash
needs: new-branch
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os:
- macos-latest
- ubuntu-latest
- windows-latest
sdk:
- ${{ github.event.inputs.sdk || 'latest' }}
features:
- v: >-
bindings-documentation
bindings-derive-debug
name: default
- v: >-
bindings-documentation
bindings-derive-default
bindings-derive-eq
bindings-derive-copy
bindings-derive-debug
bindings-derive-hash
bindings-derive-ord
bindings-derive-partialeq
bindings-derive-partialord
name: full
steps:
- name: Inputs
run: |
echo "I: SDK version: ${{ github.event.inputs.sdk }}"
echo "M: SDK version: ${{ matrix.sdk }}"
echo "Base branch: ${{ needs.new-branch.outputs.base }}"
echo "Working branch: ${{ needs.new-branch.outputs.working }}"
- uses: actions/checkout@v4
with:
ref: ${{ needs.new-branch.outputs.working }}
- name: Cache
uses: actions/cache@v3
with:
path: |
target/
~/.cargo
key: ${{ runner.os }}-update-${{ hashFiles('Cargo.lock') }}
- name: Cache LLVM
id: cache-llvm
if: runner.os == 'Windows'
uses: actions/cache@v3
with:
path: ${{ runner.temp }}/llvm
key: llvm-14.0
# See:
# https://github.com/rust-lang/rust-bindgen/issues/1797
# https://rust-lang.github.io/rust-bindgen/requirements.html#windows
- name: Install LLVM
if: runner.os == 'Windows'
uses: KyleMayes/[email protected]
with:
version: "14.0"
directory: ${{ runner.temp }}/llvm
cached: ${{ steps.cache-llvm.outputs.cache-hit }}
env: true
- name: Install Playdate SDK ${{ matrix.sdk }}
id: sdk
uses: pd-rs/get-playdate-sdk@main
with:
version: ${{ matrix.sdk }}
custom-url: ${{ matrix.sdk == 'beta' && ((runner.os == 'macOS' && secrets.SDK_BETA_MACOS) || (runner.os == 'Linux' && secrets.SDK_BETA_LINUX) || (runner.os == 'Windows' && secrets.SDK_BETA_WINDOWS)) || '' }}
- name: SDK ${{ steps.sdk.outputs.version }} installed
run: which pdc && pdc --version
# TODO: check & stop if there's no changes or mb. save SDK version cached
- name: Host
run: cargo build -p=playdate-sys --features="${{ matrix.features.v }}" -vv
- name: Device
if: ${{ matrix.os == 'ubuntu-latest' }}
run: cargo build -p=playdate-sys --features="${{ matrix.features.v }}" --target=thumbv7em-none-eabihf
- name: Format
run: rustfmt api/sys/gen/*.rs
- name: Test (host)
# env: # uncomment when all bindings for min-supported-SDK will be there
# IGNORE_EXISTING_PLAYDATE_SDK: 1
# PLAYDATE_USE_PREBUILT_VERSION: ${{ steps.sdk.outputs.version }}
run: |
cargo test -p=playdate-sys --features="lang-items ${{ matrix.features.v }}"
cargo test -p=playdate-sys --features="lang-items ${{ matrix.features.v }}" --release
- name: Test (device)
if: ${{ matrix.os == 'ubuntu-latest' }}
# env: # uncomment when all bindings for min-supported-SDK will be there
# IGNORE_EXISTING_PLAYDATE_SDK: 1
# PLAYDATE_USE_PREBUILT_VERSION: ${{ steps.sdk.outputs.version }}
run: |
cargo build -p=playdate-sys --features="lang-items ${{ matrix.features.v }}" --target=thumbv7em-none-eabihf -Zbuild-std=core,alloc
cargo build -p=playdate-sys --features="lang-items ${{ matrix.features.v }}" --target=thumbv7em-none-eabihf -Zbuild-std=core,alloc --release
- name: Commit
id: commit
uses: EndBug/add-and-commit@v9
with:
add: ./api/sys/gen/*.rs
author_name: Alex Koz
author_email: [email protected]
committer_name: Update Workflow
message: Automated build pre-built bindings
pull: "--rebase --autostash"
push: true
- name: Committed
run: |
echo "Committed: ${{ steps.commit.outputs.committed }}"
echo "Pushed: ${{ steps.commit.outputs.pushed }}"
echo "SHA: ${{ steps.commit.outputs.commit_sha }}"
pr:
name: Make PR
needs: [new-branch, pre-gen, pre-gen-arm]
runs-on: ubuntu-latest
defaults:
run:
shell: bash
permissions:
pull-requests: write
contents: write
steps:
- name: Inputs
run: |
echo "Base branch: ${{ needs.new-branch.outputs.base }}"
echo "Working branch: ${{ needs.new-branch.outputs.working }}"
- uses: actions/checkout@v4
with:
ref: ${{ needs.new-branch.outputs.working }}
- name: Create PR
uses: TreTuna/[email protected]
with:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
FROM_BRANCH: refs/heads/${{ needs.new-branch.outputs.working }}
TO_BRANCH: ${{ needs.new-branch.outputs.base || github.event.repository.default_branch }}
PULL_REQUEST_TITLE: Update pre-built bindings
PULL_REQUEST_BODY: |
Pre-built bindings just updated.
Don't forget to bump version and make release.
PULL_REQUEST_IS_DRAFT: false
CONTENT_COMPARISON: true
REVIEWERS: '["boozook"]'