Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: improve update & publish workflows #289

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions .github/workflows/post.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ on:
workflow_dispatch:
inputs:
message:
description: "Just message to post."
description: "Message to post. Can be ordinar string or json-value \"Multiline\nstring.\"."
required: false
workflow_call:
inputs:
message:
type: string
description: "Just message to post."
description: "Message to post. Can be ordinar string or json-value \"Multiline\nstring.\"."
required: false

jobs:
Expand All @@ -33,20 +33,18 @@ jobs:

- name: Toot
id: mastodon
uses: cbrgm/mastodon-github-action@v2.0.4
uses: cbrgm/mastodon-github-action@v2.0.6
with:
message: |
🦀 Rusty Playdate Updated!

${{ inputs.message || (github.event_name == 'release' && format('New {0} published: {1}', steps.words.outputs.release, github.event.release.name) || '') }}
${{ ((inputs.message && startsWith(inputs.message, '"') && endsWith(inputs.message, '"')) && fromJson(inputs.message) || inputs.message) || (github.event_name == 'release' && format('New {0} published: {1}', steps.words.outputs.release, github.event.release.name) || '') }}

${{ steps.url.outputs.value }}

#RustLang #playdate

# TODO: Write good-look link like [github.event.repository.name](url)

language: "en"
visibility: public # use `unlisted` for tests
visibility: public # use `private` for tests
url: ${{ secrets.MASTODON_URL }}
access-token: ${{ secrets.MASTODON_ACCESS_TOKEN }}
9 changes: 7 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,15 @@ jobs:
CRATES: ${{ steps.publisher.outputs.published }}
run: |
MESSAGE=$(echo $CRATES | jq -r 'if length == 1 then "Crate updated: \(.[0].name) v\(.[0].version)" else ("Crates updated:"), (to_entries[] | "\(.key + 1). \(.value.name): v\(.value.version)") end')
echo "$MESSAGE"

# Replace \n->\n is really nessessary! This encodes string to json string.
MESSAGE="\"${MESSAGE//$'\n'/'\n'}\""
echo "encoded: $MESSAGE"

echo "value<<EOF" >> $GITHUB_OUTPUT
echo $MESSAGE >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "$MESSAGE"

outputs:
published: ${{ steps.publisher.outputs.published }}
Expand All @@ -100,4 +105,4 @@ jobs:
uses: ./.github/workflows/post.yml
secrets: inherit
with:
message: "${{ needs.crates-io.outputs.message }}"
message: ${{ needs.crates-io.outputs.message }}
66 changes: 5 additions & 61 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,63 +90,6 @@ jobs:
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:
Expand Down Expand Up @@ -256,14 +199,15 @@ jobs:
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 }}"

bump:
name: Bump
needs: [new-branch, pre-gen, pre-gen-arm]
needs: [new-branch, pre-gen]
runs-on: ubuntu-latest
continue-on-error: true # Workspaces are not supported yet
defaults:
Expand Down Expand Up @@ -304,8 +248,8 @@ jobs:
echo "SHA: ${{ steps.commit.outputs.commit_sha }}"

pr:
name: Make PR
needs: [new-branch, pre-gen, pre-gen-arm, bump, tests]
name: PR
needs: [new-branch, pre-gen, bump, tests]
runs-on: ubuntu-latest
defaults:
run:
Expand Down Expand Up @@ -344,7 +288,7 @@ jobs:

tests:
name: Tests
needs: [new-branch, pre-gen, pre-gen-arm]
needs: [new-branch, pre-gen]
uses: ./.github/workflows/tests.yml
secrets: inherit
permissions:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fs = { version = "0.2", path = "api/fs", package = "playdate-fs", default-featur
gfx = { version = "0.3", path = "api/gfx", package = "playdate-graphics", default-features = false }
menu = { version = "0.2", path = "api/menu", package = "playdate-menu", default-features = false }
scoreboards = { version = "0.1", path = "api/scoreboards", package = "playdate-scoreboards", default-features = false }
sound = { version = "0.3.0", path = "api/sound", package = "playdate-sound", default-features = false }
sound = { version = "0.3", path = "api/sound", package = "playdate-sound", default-features = false }
sprite = { version = "0.2", path = "api/sprite", package = "playdate-sprite", default-features = false }
system = { version = "0.3", path = "api/system", package = "playdate-system", default-features = false }
sys = { version = "0.3", path = "api/sys", package = "playdate-sys", default-features = false }
Expand Down