Skip to content

Commit 8187da2

Browse files
authored
Merge pull request #28 from wravery/dev
feat: create signed commits and PRs
2 parents a9eed32 + 555e98a commit 8187da2

File tree

4 files changed

+101
-16
lines changed

4 files changed

+101
-16
lines changed
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
mutation (
2+
$githubRepository: String!
3+
$branchName: String!
4+
$expectedHeadOid: GitObjectID!
5+
$commitMessage: String!
6+
$files: [FileAddition!]!
7+
) {
8+
createCommitOnBranch(
9+
input: {
10+
branch: {
11+
repositoryNameWithOwner: $githubRepository
12+
branchName: $branchName
13+
}
14+
message: { headline: $commitMessage }
15+
fileChanges: { additions: $files }
16+
expectedHeadOid: $expectedHeadOid
17+
}
18+
) {
19+
commit {
20+
url
21+
}
22+
}
23+
}

.github/workflows/update-linux.yml

+25-5
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,35 @@ jobs:
2626
cargo run -p update-bindings -- -b -d arm-unknown-linux-gnueabi
2727
2828
- name: Push Changes
29-
shell: bash {0}
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3031
run: |
3132
git config user.name "tauri"
3233
git config user.email "[email protected]"
3334
git add .
34-
git commit -m 'chore: update linux bindings'
35-
if [ $? -eq 0 ]; then
35+
36+
CHANGED=($(git diff --name-only --staged | xargs))
37+
FILES=""
38+
for value in ${CHANGED[@]}; do
39+
base64 -w0 "${value}" > "${value}.base64"
40+
FILES="${FILES} -F \"files[][path]=${value}\" -F \"files[][contents]=@${value}.base64\""
41+
done
42+
43+
if [ "${FILES}" != "" ]; then
3644
git switch -c update-linux
3745
git push --force -u origin update-linux
38-
else
39-
echo "::debug::No changes to commit."
46+
gh api graphql \
47+
-F "githubRepository=${GIT_REPOSITORY}" \
48+
-F "branchName=update-linux" \
49+
-F "expectedHeadOid=$(git rev-parse HEAD)" \
50+
-F "commitMessage=chore: update linux bindings" \
51+
-F "[email protected]/api/createCommitOnBranch.graphql" \
52+
${FILES}
53+
54+
git restore --staged .
55+
git restore .
56+
git clean -f
57+
git pull
58+
59+
gh pr create -f
4060
fi

.github/workflows/update-macos.yml

+25-5
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,35 @@ jobs:
2020
cargo run -p update-bindings -- -b -d x86_64-apple-darwin
2121
2222
- name: Push Changes
23-
shell: bash {0}
23+
env:
24+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2425
run: |
2526
git config user.name "tauri"
2627
git config user.email "[email protected]"
2728
git add .
28-
git commit -m 'chore: update macos bindings'
29-
if [ $? -eq 0 ]; then
29+
30+
CHANGED=($(git diff --name-only --staged | xargs))
31+
FILES=""
32+
for value in ${CHANGED[@]}; do
33+
base64 "${value}" > "${value}.base64"
34+
FILES="${FILES} -F \"files[][path]=${value}\" -F \"files[][contents]=@${value}.base64\""
35+
done
36+
37+
if [ "${FILES}" != "" ]; then
3038
git switch -c update-macos
3139
git push --force -u origin update-macos
32-
else
33-
echo "::debug::No changes to commit."
40+
gh api graphql \
41+
-F "githubRepository=${GIT_REPOSITORY}" \
42+
-F "branchName=update-macos" \
43+
-F "expectedHeadOid=$(git rev-parse HEAD)" \
44+
-F "commitMessage=chore: update macos bindings" \
45+
-F "[email protected]/api/createCommitOnBranch.graphql" \
46+
${FILES}
47+
48+
git restore --staged .
49+
git restore .
50+
git clean -f
51+
git pull
52+
53+
gh pr create -f
3454
fi

.github/workflows/update-windows.yml

+28-6
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,38 @@ jobs:
2121
cargo run -p update-bindings -- -b -d i686-pc-windows-msvc
2222
2323
- name: Push Changes
24-
shell: pwsh -File {0}
24+
env:
25+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2526
run: |
2627
git config user.name "tauri"
2728
git config user.email "[email protected]"
2829
git add .
29-
git commit -m 'chore: update windows bindings'
30-
if ($?) {
30+
31+
$changed = @(git diff --name-only --staged)
32+
$files = ""
33+
$changed | %{
34+
$contents = [System.IO.File]::ReadAllBytes($_)
35+
$base64Contents = [System.Convert]::ToBase64String($contents)
36+
Set-Content -Path "$_.base64" -Value $base64Contents
37+
$files += " -F `"files[][path]=$_`" -F `"files[][contents]=@$_.base64`""
38+
}
39+
40+
if ($files -ne "") {
3141
git switch -c update-windows
3242
git push --force -u origin update-windows
33-
} else {
34-
echo "::debug::No changes to commit."
35-
$LASTEXITCODE = 0
43+
44+
gh api graphql `
45+
-F "githubRepository=${env:GIT_REPOSITORY}" `
46+
-F "branchName=update-windows" `
47+
-F "expectedHeadOid=$(git rev-parse HEAD)" `
48+
-F "commitMessage=chore: update windows bindings" `
49+
-F "[email protected]/api/createCommitOnBranch.graphql" `
50+
$files
51+
52+
git restore --staged .
53+
git restore .
54+
git clean -f
55+
git pull
56+
57+
gh pr create -f
3658
}

0 commit comments

Comments
 (0)