update-hashes #13
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: Configure Git | |
if: steps.changes.outputs.has_changes == 'true' | |
run: | | |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
- 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 }}" |