diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index 567b3e88..895e0197 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -1,10 +1,8 @@ name: Update on: - workflow_call: - # schedule: - # - cron: "0 0 * * 1" - # push: - # branches: [main, master] + workflow_dispatch: + schedule: + - cron: "0 0 * * 1" env: CARGO_INCREMENTAL: 1 @@ -17,31 +15,87 @@ env: # allow modify source for bindings generator: PD_BUILD_PREBUILT: 1 +permissions: + contents: write + jobs: - pre-gen: - if: false # not ready yet + new-branch: + runs-on: ubuntu-latest defaults: run: shell: bash + steps: + - name: Checkout Master + uses: actions/checkout@v4 + with: + ref: ${{ github.event.repository.default_branch }} + + - name: Create Branch + id: branch + uses: peterjgrainger/action-create-branch@v2.3.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + branch: refs/heads/api/sys/pre-build + # ${{ github.event.pull_request.head.sha }} + - name: Created + run: 'echo "Created: ${{ steps.branch.outputs.created }}"' + + # TODO: do not reset, just rebase to master + # just try `git pull origin ${{github.event.repository.default_branch}}` + # and if failed => run ReSync + # 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: api/sys/pre-build + DEFAULT_BRANCH: ${{github.event.repository.default_branch}} + + pre-gen: + name: Gen (${{ matrix.os }}, ${{ matrix.features.v }}) + defaults: + run: + shell: bash + needs: new-branch runs-on: ${{ matrix.os }} strategy: - fail-fast: false + fail-fast: true matrix: os: - macos-latest - ubuntu-latest - - windows-latest + # - windows-latest sdk: - latest features: - - --features=bindings-documentation,bindings-derive-debug - - --features=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 + - { + v: --features=bindings-documentation, + bindings-derive-debug, + name: default, + } + - { + v: --features=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: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + with: + ref: api/sys/pre-build + - name: Cache - uses: Swatinem/rust-cache@v1 + uses: Swatinem/rust-cache@v2.6.2 - name: Install Playdate SDK ${{ matrix.sdk }} id: sdk @@ -56,27 +110,76 @@ jobs: - name: Host run: | - cargo build -p=playdate-sys ${{ matrix.features }} -vv - cargo build -p=playdate-sys ${{ matrix.features }} --release + cargo build -p=playdate-sys ${{ matrix.features.v }} -vv + cargo build -p=playdate-sys ${{ matrix.features.v }} --release - name: Device - if: ${{ matrix.os }} == "ubuntu-latest" + if: ${{ matrix.os == 'ubuntu-latest' }} run: | - cargo build -p=playdate-sys ${{ matrix.features }} --target=thumbv7em-none-eabihf - cargo build -p=playdate-sys ${{ matrix.features }} --target=thumbv7em-none-eabihf --release + cargo build -p=playdate-sys ${{ matrix.features.v }} --target=thumbv7em-none-eabihf + cargo build -p=playdate-sys ${{ matrix.features.v }} --target=thumbv7em-none-eabihf --release - name: Format - run: rustfmt ./api/sys/gen/*.rs + run: rustfmt api/sys/gen/*.rs - - name: Test (dev) + - name: Test (host) + # env: # uncomment when all bindings for min-supported-SDK will be there + # IGNORE_EXISTING_PLAYDATE_SDK: 1 run: | - cargo test -p=playdate-sys ${{ matrix.features }} --all-targets - cargo build -p=playdate-sys ${{ matrix.features }} --target=thumbv7em-none-eabihf -Zbuild-std=core,alloc + cargo test -p=playdate-sys ${{ matrix.features.v }} + cargo test -p=playdate-sys ${{ matrix.features.v }} --release - - name: Test (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 run: | - cargo test -p=playdate-sys ${{ matrix.features }} --all-targets --release - cargo build -p=playdate-sys ${{ matrix.features }} --target=thumbv7em-none-eabihf -Zbuild-std=core,alloc --release - # TODO: build tests for --target=thumbv7em-none-eabihf with -Zbuild-std=core,alloc and mb. restricted-std + cargo build -p=playdate-sys ${{ matrix.features.v }} --target=thumbv7em-none-eabihf -Zbuild-std=core,alloc + cargo build -p=playdate-sys ${{ 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: boozook@users.noreply.github.com + committer_name: Update Workflow + message: Automated build pre-built bindings + pull: "--rebase --autostash" + push: true - # TODO: compare, create PR + - 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: pre-gen + runs-on: ubuntu-latest + defaults: + run: + shell: bash + permissions: + pull-requests: write + contents: write + steps: + - uses: actions/checkout@v4 + with: + ref: api/sys/pre-build + + - name: Create PR + uses: TreTuna/sync-branches@1.4.0 + with: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + FROM_BRANCH: refs/heads/api/sys/pre-build + TO_BRANCH: ${{ 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"]'