Skip to content

Commit ee2e61f

Browse files
Provide shaders via artifact repo (#3250)
* raster_nodes_shaders_entrypoint.wgsl upload
1 parent 403ab7b commit ee2e61f

4 files changed

Lines changed: 136 additions & 5 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Provide Shaders
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
workflow_dispatch: {}
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: DeterminateSystems/nix-installer-action@main
17+
- uses: DeterminateSystems/magic-nix-cache-action@main
18+
19+
- name: Build graphene raster nodes shaders
20+
run: nix build .nix#raster-nodes-shaders && cp result raster_nodes_shaders_entrypoint.wgsl
21+
22+
- name: Upload graphene raster nodes shaders to artifacts repository
23+
run: |
24+
bash .github/workflows/scripts/artifact-upload.bash \
25+
${{ vars.ARTIFACTS_REPO_OWNER }} \
26+
${{ vars.ARTIFACTS_REPO_NAME }} \
27+
${{ vars.ARTIFACTS_REPO_BRANCH }} \
28+
rev/${{ github.sha }}/raster_nodes_shaders_entrypoint.wgsl \
29+
raster_nodes_shaders_entrypoint.wgsl \
30+
"${{ github.sha }} raster_nodes_shaders_entrypoint.wgsl" \
31+
${{ secrets.ARTIFACTS_REPO_TOKEN }}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
usage() {
5+
cat <<EOF
6+
Usage: $0 <owner> <repo> <branch> <target-path> <artifact-file> <commit-message> <github-token>
7+
8+
Arguments:
9+
owner : GitHub user or organization of the target repo
10+
repo : Target repo name
11+
branch : Branch name (e.g. main)
12+
target-path : Full path (including folders + filename) in the target repo where to upload
13+
artifact-file : Local file path to upload
14+
commit-message : Commit message for creating/updating the file
15+
github-token : GitHub token (PAT or equivalent) with write access to the target repo
16+
17+
This will perform a GitHub API PUT to /repos/{owner}/{repo}/contents/{target-path}.
18+
If a file already exists at that path, it will auto-detect the SHA and update; otherwise it will create a new one.
19+
EOF
20+
exit 1
21+
}
22+
23+
if [ $# -ne 7 ]; then
24+
usage
25+
fi
26+
27+
OWNER="$1"
28+
REPO="$2"
29+
BRANCH="$3"
30+
TARGET_PATH="$4"
31+
ARTIFACT_PATH="$5"
32+
COMMIT_MSG="$6"
33+
TOKEN="$7"
34+
35+
if [ ! -f "$ARTIFACT_PATH" ]; then
36+
echo "Error: artifact file not found: $ARTIFACT_PATH" >&2
37+
exit 1
38+
fi
39+
40+
LOCAL_SHA=$(git hash-object "$ARTIFACT_PATH")
41+
echo "Local blob SHA: $LOCAL_SHA"
42+
43+
GET_URL="https://api.github.com/repos/${OWNER}/${REPO}/contents/${TARGET_PATH}?ref=${BRANCH}"
44+
GET_RESPONSE=$(curl -s -H "Authorization: token ${TOKEN}" "$GET_URL")
45+
46+
REMOTE_SHA=$(echo "$GET_RESPONSE" | jq -r .sha 2>/dev/null || echo "")
47+
48+
if [ "$REMOTE_SHA" != "null" ] && [ -n "$REMOTE_SHA" ]; then
49+
echo "Remote blob SHA: $REMOTE_SHA"
50+
if [ "$LOCAL_SHA" = "$REMOTE_SHA" ]; then
51+
echo "The remote file is identical. Skipping upload."
52+
exit 0
53+
else
54+
echo "Remote file differs. Preparing to upload."
55+
fi
56+
else
57+
echo "No existing remote file or no SHA found. Creating."
58+
fi
59+
60+
CONTENT_TMP_BASE64=$(mktemp)
61+
if base64 --help 2>&1 | grep -q -- "-w"; then
62+
base64 -w 0 "$ARTIFACT_PATH" > "$CONTENT_TMP_BASE64"
63+
else
64+
base64 "$ARTIFACT_PATH" | tr -d '\n' > "$CONTENT_TMP_BASE64"
65+
fi
66+
67+
PAYLOAD_TMP=$(mktemp)
68+
jq -n \
69+
--arg message "$COMMIT_MSG" \
70+
--arg branch "$BRANCH" \
71+
--arg sha "$REMOTE_SHA" \
72+
--rawfile content "$CONTENT_TMP_BASE64" \
73+
'{
74+
message: $message,
75+
content: $content,
76+
branch: $branch
77+
} + (if ($sha != "" and $sha != "null") then { sha: $sha } else {} end)' \
78+
> "$PAYLOAD_TMP"
79+
80+
UPLOAD_RESPONSE=$(curl -s -X PUT \
81+
-H "Authorization: token ${TOKEN}" \
82+
-H "Content-Type: application/json" \
83+
-d @"$PAYLOAD_TMP" \
84+
"https://api.github.com/repos/${OWNER}/${REPO}/contents/${TARGET_PATH}")
85+
86+
echo "Upload Response:"
87+
echo "$UPLOAD_RESPONSE"
88+
89+
rm -f "$CONTENT_TMP_BASE64" "$PAYLOAD_TMP"

Cargo.lock

Lines changed: 15 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

desktop/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,4 @@ windows = { version = "0.58.0", features = [
6666
objc2 = { version = "0.6.1", default-features = false }
6767
objc2-foundation = { version = "0.3.2", default-features = false }
6868
objc2-app-kit = { version = "0.3.2", default-features = false }
69-
muda = { git = "https://github.com/tauri-apps/muda.git", rev = "3f460b8fbaed59cda6d95ceea6904f000f093f15", default-features = false }
69+
muda = { git = "https://github.com/tauri-apps/muda.git", rev = "dca083660d04209109ae854b9a9436a809daf409", default-features = false }

0 commit comments

Comments
 (0)