Skip to content

Commit 17b0c6b

Browse files
committed
init
0 parents  commit 17b0c6b

File tree

7 files changed

+885
-0
lines changed

7 files changed

+885
-0
lines changed
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: Build Changed Packages
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'binaries/**/*.yaml'
9+
- 'packages/**/*.yaml'
10+
pull_request:
11+
types: [closed]
12+
branches:
13+
- main
14+
workflow_dispatch:
15+
inputs:
16+
recipe_path:
17+
description: 'Specific recipe path to build (e.g., binaries/hello/static.yaml)'
18+
type: string
19+
default: ''
20+
force_rebuild:
21+
description: 'Force rebuild even if hash unchanged'
22+
type: boolean
23+
default: true
24+
25+
concurrency:
26+
group: build-${{ github.ref }}
27+
cancel-in-progress: false
28+
29+
jobs:
30+
detect-changes:
31+
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true)
32+
runs-on: ubuntu-latest
33+
outputs:
34+
changed_recipes: ${{ steps.detect.outputs.changed_recipes }}
35+
has_changes: ${{ steps.detect.outputs.has_changes }}
36+
steps:
37+
- name: Checkout repository
38+
uses: actions/checkout@v4
39+
with:
40+
fetch-depth: 2
41+
42+
- name: Detect changed recipes
43+
id: detect
44+
run: |
45+
mkdir -p /tmp/changes
46+
CHANGED_RECIPES="[]"
47+
48+
if [ -n "${{ inputs.recipe_path }}" ]; then
49+
# Manual trigger with specific recipe
50+
if [ -f "${{ inputs.recipe_path }}" ]; then
51+
RECIPE="${{ inputs.recipe_path }}"
52+
CHANGED_RECIPES=$(jq -n --arg path "$RECIPE" '[{"path": $path}]')
53+
else
54+
echo "::error::Recipe not found: ${{ inputs.recipe_path }}"
55+
exit 1
56+
fi
57+
else
58+
# Detect changes from git diff
59+
if [ "${{ github.event_name }}" == "push" ]; then
60+
CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD -- 'binaries/**/*.yaml' 'packages/**/*.yaml' 2>/dev/null || true)
61+
elif [ "${{ github.event_name }}" == "pull_request" ]; then
62+
CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} -- 'binaries/**/*.yaml' 'packages/**/*.yaml' 2>/dev/null || true)
63+
else
64+
CHANGED_FILES=""
65+
fi
66+
67+
echo "Changed files:"
68+
echo "$CHANGED_FILES"
69+
70+
# Build JSON array of changed recipes
71+
for file in $CHANGED_FILES; do
72+
if [ -f "$file" ]; then
73+
CHANGED_RECIPES=$(echo "$CHANGED_RECIPES" | jq --arg path "$file" '. + [{"path": $path}]')
74+
fi
75+
done
76+
fi
77+
78+
# Output results
79+
RECIPE_COUNT=$(echo "$CHANGED_RECIPES" | jq 'length')
80+
echo "Found $RECIPE_COUNT recipes to build"
81+
echo "$CHANGED_RECIPES" | jq .
82+
83+
# Save to outputs
84+
echo "changed_recipes=$(echo "$CHANGED_RECIPES" | jq -c .)" >> $GITHUB_OUTPUT
85+
86+
if [ "$RECIPE_COUNT" -gt 0 ]; then
87+
echo "has_changes=true" >> $GITHUB_OUTPUT
88+
else
89+
echo "has_changes=false" >> $GITHUB_OUTPUT
90+
fi
91+
92+
build:
93+
needs: detect-changes
94+
if: needs.detect-changes.outputs.has_changes == 'true'
95+
strategy:
96+
fail-fast: false
97+
max-parallel: 4
98+
matrix:
99+
recipe: ${{ fromJson(needs.detect-changes.outputs.changed_recipes) }}
100+
uses: ./.github/workflows/matrix_builds.yaml
101+
with:
102+
sbuild-url: "https://raw.githubusercontent.com/${{ github.repository }}/refs/heads/main/${{ matrix.recipe.path }}"
103+
ghcr-url: ${{ contains(matrix.recipe.path, 'packages/') && 'ghcr.io/pkgforge/pkgcache-test' || 'ghcr.io/pkgforge/bincache-test' }}
104+
pkg-family: ${{ github.event.repository.name }}
105+
rebuild: true
106+
logs: true
107+
secrets: inherit
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Manual Build Test
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
recipe:
7+
description: 'Recipe path (e.g., binaries/hello/static.yaml)'
8+
type: choice
9+
options:
10+
- binaries/hello/static.yaml
11+
- binaries/jq/static.yaml
12+
- packages/hello-appimage/appimage.yaml
13+
default: 'binaries/hello/static.yaml'
14+
host:
15+
description: 'Target host'
16+
type: choice
17+
options:
18+
- ALL
19+
- x86_64-Linux
20+
- aarch64-Linux
21+
default: 'x86_64-Linux'
22+
cache_type:
23+
description: 'Cache type (auto-detected from path if not specified)'
24+
type: choice
25+
options:
26+
- auto
27+
- bincache
28+
- pkgcache
29+
default: 'auto'
30+
31+
jobs:
32+
build:
33+
uses: ./.github/workflows/matrix_builds.yaml
34+
with:
35+
host: ${{ inputs.host }}
36+
sbuild-url: "https://raw.githubusercontent.com/${{ github.repository }}/refs/heads/main/${{ inputs.recipe }}"
37+
ghcr-url: ${{ inputs.cache_type == 'auto' && (contains(inputs.recipe, 'packages/') && 'ghcr.io/pkgforge/pkgcache-test' || 'ghcr.io/pkgforge/bincache-test') || (inputs.cache_type == 'pkgcache' && 'ghcr.io/pkgforge/pkgcache-test' || 'ghcr.io/pkgforge/bincache-test') }}
38+
pkg-family: ${{ github.event.repository.name }}
39+
rebuild: true
40+
logs: true
41+
debug: true
42+
secrets: inherit

0 commit comments

Comments
 (0)