forked from sbwml/luci-app-openlist2
-
Notifications
You must be signed in to change notification settings - Fork 10
160 lines (132 loc) · 6.39 KB
/
update-hashes.yml
File metadata and controls
160 lines (132 loc) · 6.39 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
name: Update Makefile Hashes
on:
workflow_dispatch:
repository_dispatch:
types: [update-hashes]
permissions:
contents: write
jobs:
update-hashes:
name: Update Makefile Hashes
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Get latest versions
id: vars
run: |
# Use tag from external trigger if available, otherwise get latest from API
if [ "${{ github.event.client_payload.release_tag }}" != "" ]; then
OPENLIST_VERSION=$(echo "${{ github.event.client_payload.release_tag }}" | sed 's/^v//')
echo "Using version from external trigger: $OPENLIST_VERSION"
else
OPENLIST_VERSION=$(curl -s https://api.github.com/repos/OpenListTeam/OpenList/releases/latest | jq -r '.tag_name' | sed 's/^v//')
echo "Latest OpenList version from API: $OPENLIST_VERSION"
fi
FRONTEND_VERSION=$(curl -s https://api.github.com/repos/OpenListTeam/OpenList-Frontend/releases/latest | jq -r '.tag_name' | sed 's/^v//')
echo "Latest Frontend version: $FRONTEND_VERSION"
echo "openlist_version=$OPENLIST_VERSION" >> $GITHUB_OUTPUT
echo "frontend_version=$FRONTEND_VERSION" >> $GITHUB_OUTPUT
- name: Download and calculate OpenList hash
id: openlist_hash
run: |
VERSION="${{ steps.vars.outputs.openlist_version }}"
URL="https://codeload.github.com/OpenListTeam/OpenList/tar.gz/v${VERSION}"
echo "Downloading OpenList v${VERSION}..."
wget -O "openlist-${VERSION}.tar.gz" "$URL"
HASH=$(sha256sum "openlist-${VERSION}.tar.gz" | cut -d' ' -f1)
echo "OpenList hash: $HASH"
echo "hash=$HASH" >> $GITHUB_OUTPUT
rm "openlist-${VERSION}.tar.gz"
- name: Download and calculate Frontend hash
id: frontend_hash
run: |
VERSION="${{ steps.vars.outputs.frontend_version }}"
URL="https://github.com/OpenListTeam/OpenList-Frontend/releases/download/v${VERSION}/openlist-frontend-dist-v${VERSION}.tar.gz"
echo "Downloading Frontend v${VERSION}..."
wget -O "openlist-frontend-dist-v${VERSION}.tar.gz" "$URL"
HASH=$(sha256sum "openlist-frontend-dist-v${VERSION}.tar.gz" | cut -d' ' -f1)
echo "Frontend hash: $HASH"
echo "hash=$HASH" >> $GITHUB_OUTPUT
rm "openlist-frontend-dist-v${VERSION}.tar.gz"
- name: Update Makefile
run: |
OPENLIST_VERSION="${{ steps.vars.outputs.openlist_version }}"
FRONTEND_VERSION="${{ steps.vars.outputs.frontend_version }}"
OPENLIST_HASH="${{ steps.openlist_hash.outputs.hash }}"
FRONTEND_HASH="${{ steps.frontend_hash.outputs.hash }}"
echo "Updating Makefile with:"
echo " OpenList version: $OPENLIST_VERSION"
echo " OpenList hash: $OPENLIST_HASH"
echo " Frontend version: $FRONTEND_VERSION"
echo " Frontend hash: $FRONTEND_HASH"
# Update PKG_VERSION and PKG_WEB_VERSION to match OpenList main repo
sed -i "s/^PKG_VERSION:=.*/PKG_VERSION:=$OPENLIST_VERSION/" openlist/Makefile
sed -i "s/^PKG_WEB_VERSION:=.*/PKG_WEB_VERSION:=$FRONTEND_VERSION/" openlist/Makefile
# Update PKG_HASH
sed -i "s/^PKG_HASH:=.*/PKG_HASH:=$OPENLIST_HASH/" openlist/Makefile
# Update Frontend HASH
sed -i "/define Download\/openlist-frontend/,/endef/ s/^ HASH:=.*/ HASH:=$FRONTEND_HASH/" openlist/Makefile
- name: Check for changes
id: changes
run: |
if git diff --quiet openlist/Makefile; then
echo "No changes detected in Makefile"
echo "has_changes=false" >> $GITHUB_OUTPUT
else
echo "Changes detected in Makefile"
echo "has_changes=true" >> $GITHUB_OUTPUT
git diff openlist/Makefile
fi
- name: Import GPG key
if: steps.changes.outputs.has_changes == 'true'
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.BOT_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.BOT_GPG_PASSPHRASE }}
git_config_global: true
git_user_signingkey: true
git_commit_gpgsign: true
git_tag_gpgsign: true
- name: Setup CI Bot
if: steps.changes.outputs.has_changes == 'true'
run: |
git config --global user.name "The OpenList Bot"
git config --global user.email "bot@openlist.team"
- name: Commit and Push Changes
if: steps.changes.outputs.has_changes == 'true'
run: |
git add openlist/Makefile
git commit -m "Update v${{ steps.vars.outputs.openlist_version }}"
git push origin HEAD:${{ github.ref_name }}
- name: Trigger release build
if: steps.changes.outputs.has_changes == 'true'
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
event-type: release-build
client-payload: |
{
"release_tag": "v${{ steps.vars.outputs.openlist_version }}",
"release_name": "Release v${{ steps.vars.outputs.openlist_version }}",
"source_repository": "${{ github.event.client_payload.source_repository || github.repository }}",
"triggered_by": "${{ github.event.client_payload.triggered_by || github.actor }}",
"trigger_reason": "update-hashes"
}
- name: Summary
run: |
if [ "${{ steps.changes.outputs.has_changes }}" = "true" ]; then
echo "✅ Makefile updated to latest versions!"
echo "🚀 Changes committed and pushed to main branch"
echo "🚀 Release build triggered for v${{ steps.vars.outputs.openlist_version }}"
else
echo "ℹ️ No updates needed - Makefile is already using latest versions"
fi
echo ""
echo "📊 Latest versions detected:"
echo " OpenList: v${{ steps.vars.outputs.openlist_version }}"
echo " Frontend: v${{ steps.vars.outputs.frontend_version }}"