Skip to content

Update

Update #322

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 15 * * 1,3,5"
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/action-create-branch@v3.0.0
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/resync-branch@1.5.0
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:
name: Gen ${{ matrix.features.name }} (${{ matrix.os }})
defaults:
run:
shell: bash
needs: new-branch
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os:
- macos-14
- 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 }}"
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ needs.new-branch.outputs.working }}
- name: Cache
uses: actions/cache@v4
with:
path: |
target/
~/.cargo
key: ${{ runner.os }}-update-${{ hashFiles('Cargo.lock') }}
- name: Install Deps
uses: ./.github/actions/tools-deps
- 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
- name: Install targets (mac)
if: runner.os == 'macOS'
run: |
rustup target add aarch64-apple-darwin
rustup target add x86_64-apple-darwin
- name: Install targets (win)
if: runner.os == 'Windows'
run: |
rustup target add x86_64-pc-windows-msvc
rustup target add aarch64-pc-windows-msvc
- name: Git Pull
run: git pull
- name: Host
run: >-
cargo build -p=playdate-sys --features="${{ matrix.features.v }}"
${{ runner.os == 'macOS' && '--target=aarch64-apple-darwin --target=x86_64-apple-darwin' || '' }}
${{ runner.os == 'Windows' && '--target=x86_64-pc-windows-msvc --target=aarch64-pc-windows-msvc' || '' }}
- 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
continue-on-error: true
id: commit
uses: EndBug/add-and-commit@v9
with:
add: ./api/sys/gen/*.rs
author_name: Update Bot
author_email: boozook@users.noreply.github.com
committer_name: Update Bot
message: >-
Automated build pre-built bindings for ${{ steps.sdk.outputs.version }}
on ${{ runner.os }}-${{ runner.arch }}
with features: ${{ matrix.features.name }}
pull: "--rebase --autostash"
push: true
- name: Committed
if: ${{ steps.commit.outcome =='success' }}
run: |
echo "Committed: ${{ steps.commit.outputs.committed }}"
echo "Pushed: ${{ steps.commit.outputs.pushed }}"
echo "SHA: ${{ steps.commit.outputs.commit_sha }}"
changes:
name: Changes
needs: [new-branch, pre-gen]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ needs.new-branch.outputs.working }}
fetch-depth: 10
# Maybe better just checkout and then
# git rev-list --ancestry-path ${{ needs.new-branch.outputs.base || github.event.repository.default_branch }}..${{ needs.new-branch.outputs.working }}
# It's faster, simplier and less deps.
- name: Changes
id: changes
continue-on-error: true
uses: tj-actions/changed-files@v44
with:
skip_initial_fetch: "false"
sha: ${{ needs.new-branch.outputs.working }}
base_sha: ${{ needs.new-branch.outputs.base || github.event.repository.default_branch }}
- name: List changed files
if: steps.changes.outcome == 'success'
env:
ALL_CHANGED_FILES: ${{ steps.changes.outputs.all_changed_files }}
run: |
for file in ${ALL_CHANGED_FILES}; do
echo "$file was changed"
done
outputs:
changes: ${{ steps.changes.outputs.all_changed_files }}
changed: ${{ steps.changes.outputs.all_changed_files && 'true' || ' ' }}
bump:
name: Bump
needs: [new-branch, pre-gen, changes]
runs-on: ubuntu-latest
continue-on-error: true # Workspaces are not supported yet
if: needs.changes.outputs.changed == 'true'
defaults:
run:
shell: bash
permissions:
pull-requests: write
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.new-branch.outputs.working }}
- name: Install cargo semver tool
uses: baptiste0928/cargo-install@v3
with:
crate: cargo-semver-tool
- name: Bump Version
run: cd ./api/sys && cargo semver bump
- name: Commit
id: commit
uses: EndBug/add-and-commit@v9.1.4
with:
add: ./api/sys/Cargo.toml
author_name: Bump Bot
author_email: boozook@users.noreply.github.com
committer_name: Bump Bot
message: Automated bump sys crate version
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: PR
needs: [new-branch, pre-gen, bump, tests]
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
id: pr
uses: TreTuna/sync-branches@1.4.0
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: |
- [x] Pre-built bindings just updated.
- [${{ needs.bump.result == 'success' && 'x' || ' ' }}] Bump sys crate
- [${{ needs.tests.result == 'success' && 'x' || ' ' }}] Tests passed
PULL_REQUEST_IS_DRAFT: false
CONTENT_COMPARISON: true
REVIEWERS: '["boozook"]'
outputs:
number: ${{ steps.pr.outputs.PULL_REQUEST_NUMBER }}
url: ${{ steps.pr.outputs.PULL_REQUEST_URL }}
tests:
name: Tests
needs: [new-branch, pre-gen, changes]
if: needs.changes.outputs.changed == 'true'
uses: ./.github/workflows/tests.yml
secrets: inherit
permissions:
actions: read
contents: read
pull-requests: write
checks: write
issues: write
with:
ref: ${{ needs.new-branch.outputs.working }}