Skip to content

Commit 5ca1f39

Browse files
committed
feat: remove Cargo.lock, auto-update on imageflow releases
- Remove native/Cargo.lock from repo (cdylib, not an end binary) - Add rebuild-on-imageflow-release workflow: checks weekly for new imageflow tags, updates Cargo.toml, verifies build, opens a PR - Also triggerable via workflow_dispatch or repository_dispatch - Update CI cache key to hash Cargo.toml instead of Cargo.lock
1 parent 530f850 commit 5ca1f39

File tree

4 files changed

+96
-1605
lines changed

4 files changed

+96
-1605
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
~/.cargo/registry
4343
~/.cargo/git
4444
native/target
45-
key: ${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('native/Cargo.lock') }}
45+
key: ${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('native/Cargo.toml') }}
4646
restore-keys: |
4747
${{ runner.os }}-${{ runner.arch }}-cargo-
4848
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Rebuild on Imageflow Release
2+
3+
on:
4+
# Trigger manually or via repository_dispatch from imageflow repo
5+
repository_dispatch:
6+
types: [imageflow-release]
7+
workflow_dispatch:
8+
inputs:
9+
imageflow_tag:
10+
description: 'Imageflow release tag (e.g. v2.3.0-rc01). Leave blank to use latest.'
11+
required: false
12+
schedule:
13+
# Check weekly for new imageflow releases
14+
- cron: '0 9 * * 1'
15+
16+
jobs:
17+
check-and-rebuild:
18+
runs-on: ubuntu-24.04
19+
permissions:
20+
contents: write
21+
pull-requests: write
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- name: Get current imageflow tag
26+
id: current
27+
run: |
28+
tag=$(grep -oP 'tag = "\K[^"]+' native/Cargo.toml | head -1)
29+
echo "tag=$tag" >> "$GITHUB_OUTPUT"
30+
echo "Current tag: $tag"
31+
32+
- name: Get latest imageflow release tag
33+
id: latest
34+
run: |
35+
if [[ -n "${{ github.event.inputs.imageflow_tag }}" ]]; then
36+
tag="${{ github.event.inputs.imageflow_tag }}"
37+
elif [[ -n "${{ github.event.client_payload.tag }}" ]]; then
38+
tag="${{ github.event.client_payload.tag }}"
39+
else
40+
tag=$(gh api repos/imazen/imageflow/releases/latest --jq '.tag_name' 2>/dev/null || echo "")
41+
fi
42+
echo "tag=$tag" >> "$GITHUB_OUTPUT"
43+
echo "Latest tag: $tag"
44+
env:
45+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46+
47+
- name: Check if update needed
48+
id: check
49+
run: |
50+
if [[ -z "${{ steps.latest.outputs.tag }}" ]]; then
51+
echo "No latest tag found, skipping"
52+
echo "needed=false" >> "$GITHUB_OUTPUT"
53+
elif [[ "${{ steps.current.outputs.tag }}" == "${{ steps.latest.outputs.tag }}" ]]; then
54+
echo "Already on latest (${{ steps.current.outputs.tag }}), skipping"
55+
echo "needed=false" >> "$GITHUB_OUTPUT"
56+
else
57+
echo "Update needed: ${{ steps.current.outputs.tag }} -> ${{ steps.latest.outputs.tag }}"
58+
echo "needed=true" >> "$GITHUB_OUTPUT"
59+
fi
60+
61+
- name: Update Cargo.toml tag
62+
if: steps.check.outputs.needed == 'true'
63+
run: |
64+
sed -i "s/tag = \"${{ steps.current.outputs.tag }}\"/tag = \"${{ steps.latest.outputs.tag }}\"/g" native/Cargo.toml
65+
echo "Updated native/Cargo.toml:"
66+
grep 'tag =' native/Cargo.toml
67+
68+
- name: Setup Rust
69+
if: steps.check.outputs.needed == 'true'
70+
uses: dtolnay/rust-toolchain@stable
71+
72+
- name: Verify it builds
73+
if: steps.check.outputs.needed == 'true'
74+
working-directory: native
75+
run: cargo check
76+
77+
- name: Create PR
78+
if: steps.check.outputs.needed == 'true'
79+
run: |
80+
branch="deps/imageflow-${{ steps.latest.outputs.tag }}"
81+
git checkout -b "$branch"
82+
git add native/Cargo.toml
83+
git config user.name "github-actions[bot]"
84+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
85+
git commit -m "deps: update imageflow to ${{ steps.latest.outputs.tag }}"
86+
git push origin "$branch"
87+
gh pr create \
88+
--title "deps: update imageflow to ${{ steps.latest.outputs.tag }}" \
89+
--body "Automatic update from ${{ steps.current.outputs.tag }} to ${{ steps.latest.outputs.tag }}." \
90+
--label dependencies
91+
env:
92+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
logs
33
*.log
44

5+
# Cargo lockfile — rebuilt from imageflow release tag on each CI run
6+
native/Cargo.lock
7+
58
# Runtime data
69
pids
710
*.pid

0 commit comments

Comments
 (0)