forked from sqlite/sqlite-wasm
-
Notifications
You must be signed in to change notification settings - Fork 0
109 lines (96 loc) · 3.87 KB
/
build-wasm.yml
File metadata and controls
109 lines (96 loc) · 3.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
name: Build SQLite Wasm
on:
workflow_dispatch:
inputs:
sqlite_ref:
description: 'Full commit SHA from SQLite repository'
required: true
permissions: {}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
persist-credentials: false
- name: Resolve SQLite reference
id: resolve-ref
run: |
SQLITE_REF="${{ github.event.inputs.sqlite_ref }}"
if ! [[ "$SQLITE_REF" =~ ^[0-9a-fA-F]{40}$ ]]; then
echo "Expected a full 40-character commit SHA, got: '$SQLITE_REF'"
exit 1
fi
SQLITE_SHA=$(git ls-remote https://github.com/sqlite/sqlite.git "$SQLITE_REF" | head -n 1 | cut -f 1)
if [ -z "$SQLITE_SHA" ] || [ "$SQLITE_SHA" != "$SQLITE_REF" ]; then
echo "Commit SHA '$SQLITE_REF' was not found in https://github.com/sqlite/sqlite.git"
exit 1
fi
echo "sqlite_ref=$SQLITE_REF" >> $GITHUB_OUTPUT
echo "sqlite_sha=$SQLITE_SHA" >> $GITHUB_OUTPUT
echo "branch_name=update-sqlite-wasm-${SQLITE_SHA}" >> $GITHUB_OUTPUT
- name: Check if branch exists
id: check-branch
run: |
BRANCH_NAME="${{ steps.resolve-ref.outputs.branch_name }}"
if git ls-remote --exit-code --heads origin "$BRANCH_NAME"; then
echo "Branch $BRANCH_NAME already exists. Skipping build."
echo "skip=true" >> $GITHUB_OUTPUT
else
echo "skip=false" >> $GITHUB_OUTPUT
fi
- name: Set up Buildx Docker CLI plugin
if: steps.check-branch.outputs.skip != 'true'
uses: docker/setup-buildx-action@v3
- name: Build Docker image
if: steps.check-branch.outputs.skip != 'true'
uses: docker/build-push-action@v6
with:
context: .
load: true
tags: sqlite-wasm-builder:env
- name: Run build
if: steps.check-branch.outputs.skip != 'true'
run: |
mkdir -p out src/bin
docker run --rm \
-e SQLITE_REF="${{ steps.resolve-ref.outputs.sqlite_ref }}" \
-e HOST_UID="$(id -u)" \
-e HOST_GID="$(id -g)" \
-v "$(pwd)/out":/out \
-v "$(pwd)/src/bin":/src/bin \
sqlite-wasm-builder:env build
# Fallback fix for permissions if chown inside docker failed or was incomplete
sudo chown -R $(id -u):$(id -g) out src/bin
- name: Check for changes
if: steps.check-branch.outputs.skip != 'true'
id: git-check
run: |
# Add files that might be newly created or modified
git add src/bin
git status --porcelain
if [ -n "$(git status --porcelain)" ]; then
echo "changes=true" >> $GITHUB_OUTPUT
else
echo "changes=false" >> $GITHUB_OUTPUT
fi
- name: Create Pull Request
if: steps.check-branch.outputs.skip != 'true' && steps.git-check.outputs.changes == 'true'
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message:
'chore: update SQLite Wasm binaries from ${{ steps.resolve-ref.outputs.sqlite_ref }}
(${{ steps.resolve-ref.outputs.sqlite_sha }})'
title:
'chore: update SQLite Wasm binaries from ${{ steps.resolve-ref.outputs.sqlite_ref }}'
body: |
This PR updates the SQLite Wasm binaries in `src/bin` by building them from SQLite reference `${{ steps.resolve-ref.outputs.sqlite_ref }}` (commit `${{ steps.resolve-ref.outputs.sqlite_sha }}`).
Triggered by manual workflow dispatch.
branch: ${{ steps.resolve-ref.outputs.branch_name }}
base: main
delete-branch: true