-
Notifications
You must be signed in to change notification settings - Fork 11
135 lines (114 loc) · 4.78 KB
/
Copy pathpatch_update_release.yml
File metadata and controls
135 lines (114 loc) · 4.78 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: Update Runner Patches (Release-to-Release)
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
push:
paths:
- 'patches/runner-sdk8-*.patch'
- 'patches/last_processed_tag.txt'
jobs:
update-patches:
runs-on: ubuntu-latest
steps:
- name: Checkout your repository
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Set up Git identity
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
- name: Clone upstream runner repository
run: git clone --tags https://github.com/actions/runner.git upstream-runner
- name: Get release tags
id: get-tags
run: |
cd upstream-runner
# Get latest release tag
LATEST_TAG=$(git tag --sort=-v:refname | grep '^v[0-9]' | head -n1)
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_OUTPUT
echo "LATEST_COMMIT=$(git rev-parse $LATEST_TAG)" >> $GITHUB_OUTPUT
# Get previous processed tag
if [ -f ../patches/last_processed_tag.txt ]; then
PREVIOUS_TAG=$(cat ../patches/last_processed_tag.txt)
echo "PREVIOUS_TAG=$PREVIOUS_TAG" >> $GITHUB_OUTPUT
else
echo "PREVIOUS_TAG=" >> $GITHUB_OUTPUT
fi
- name: Check for new release
if: steps.get-tags.outputs.PREVIOUS_TAG == steps.get-tags.outputs.LATEST_TAG
run: |
echo "No new releases - skipping"
exit 0
- name: Verify previous release exists
if: steps.get-tags.outputs.PREVIOUS_TAG != '' && steps.get-tags.outputs.PREVIOUS_TAG != steps.get-tags.outputs.LATEST_TAG
run: |
cd upstream-runner
if ! git rev-parse ${{ steps.get-tags.outputs.PREVIOUS_TAG }} >/dev/null 2>&1; then
echo "Previous tag ${{ steps.get-tags.outputs.PREVIOUS_TAG }} not found"
exit 1
fi
- name: Process architectures
if: steps.get-tags.outputs.PREVIOUS_TAG != '' && steps.get-tags.outputs.PREVIOUS_TAG != steps.get-tags.outputs.LATEST_TAG
id: process-arches
run: |
mkdir -p patches
touch successful_arches.txt
for arch in ppc64le s390x x86_64; do
echo "Processing $arch..."
cd upstream-runner
# Reset to clean state
git reset --hard
git clean -fd
# Check if previous patch exists
if [ ! -f "../patches/runner-sdk8-$arch.patch" ] || \
! grep -q "${{ steps.get-tags.outputs.PREVIOUS_TAG }}" "../patches/runner-sdk8-$arch.patch"; then
echo "No valid previous patch for $arch"
cd ..
continue
fi
# Apply previous patch to previous release
git checkout ${{ steps.get-tags.outputs.PREVIOUS_TAG }}
if ! git apply --check --whitespace=nowarn "../patches/runner-sdk8-$arch.patch"; then
echo "::warning::Previous patch application failed for $arch"
cd ..
continue
fi
git apply --whitespace=nowarn "../patches/runner-sdk8-$arch.patch"
# Stash changes
git stash push -m "patch-$arch"
# Apply to latest release
git checkout ${{ steps.get-tags.outputs.LATEST_TAG }}
if ! git stash apply stash^{/patch-$arch}; then
echo "::warning::Stash application failed for $arch on ${{ steps.get-tags.outputs.LATEST_TAG }}"
git reset --hard
git stash drop || true
cd ..
continue
fi
# Create new patch
git diff --patch --ignore-space-at-eol > "../patches/runner-sdk8-$arch.patch"
echo "# From upstream release: ${{ steps.get-tags.outputs.LATEST_TAG }}" >> "../patches/runner-sdk8-$arch.patch"
# Cleanup
git reset --hard
git stash drop || true
cd ..
echo "$arch" >> successful_arches.txt
done
# Set output for successful architectures
if [ -s successful_arches.txt ]; then
echo "successful_arches=$(paste -sd, successful_arches.txt)" >> $GITHUB_OUTPUT
fi
- name: Update tag reference
if: steps.process-arches.outputs.successful_arches != ''
run: |
echo "${{ steps.get-tags.outputs.LATEST_TAG }}" > patches/last_processed_tag.txt
- name: Commit and push changes
if: steps.process-arches.outputs.successful_arches != ''
run: |
git add patches/runner-sdk8-*.patch
git add patches/last_processed_tag.txt
git commit -m "Update patches: ${{ steps.get-tags.outputs.PREVIOUS_TAG }} → ${{ steps.get-tags.outputs.LATEST_TAG }} [${{ steps.process-arches.outputs.successful_arches }}]"
git pull --rebase origin $(git branch --show-current)
git push