@@ -393,7 +393,88 @@ jobs:
393393 name : ${{ github.ref_name }}
394394 # body: | # Optional: Add release notes here
395395 # Automated release for version ${{ github.ref_name }}
396- draft : true # Set to true if you want to manually review before publishing
396+ draft : false # Set to true if you want to manually review before publishing
397397 prerelease : false # Set to true if this is a pre-release
398398 files : |
399399 final_release_assets/*
400+
401+ update_homebrew_tap :
402+ name : Update Homebrew Tap
403+ runs-on : ubuntu-latest
404+ needs : publish_release
405+ if : startsWith(github.ref, 'refs/tags/v')
406+ steps :
407+ - name : Extract version from tag
408+ id : version
409+ run : |
410+ VERSION="${GITHUB_REF_NAME#v}"
411+ echo "version=$VERSION" >> $GITHUB_OUTPUT
412+ echo "Extracted version: $VERSION"
413+
414+ - name : Download macOS DMG files and calculate SHA256
415+ id : sha256
416+ run : |
417+ VERSION="${{ steps.version.outputs.version }}"
418+
419+ # Download ARM64 DMG
420+ echo "Downloading ARM64 DMG..."
421+ curl -L -o "SmartSub_Mac_${VERSION}_arm64.dmg" \
422+ "https://github.com/buxuku/SmartSub/releases/download/v${VERSION}/SmartSub_Mac_${VERSION}_arm64.dmg"
423+
424+ # Download x64 DMG
425+ echo "Downloading x64 DMG..."
426+ curl -L -o "SmartSub_Mac_${VERSION}_x64.dmg" \
427+ "https://github.com/buxuku/SmartSub/releases/download/v${VERSION}/SmartSub_Mac_${VERSION}_x64.dmg"
428+
429+ # Calculate SHA256
430+ SHA256_ARM64=$(shasum -a 256 "SmartSub_Mac_${VERSION}_arm64.dmg" | awk '{print $1}')
431+ SHA256_X64=$(shasum -a 256 "SmartSub_Mac_${VERSION}_x64.dmg" | awk '{print $1}')
432+
433+ echo "SHA256 ARM64: $SHA256_ARM64"
434+ echo "SHA256 x64: $SHA256_X64"
435+
436+ echo "sha256_arm64=$SHA256_ARM64" >> $GITHUB_OUTPUT
437+ echo "sha256_x64=$SHA256_X64" >> $GITHUB_OUTPUT
438+
439+ - name : Checkout Homebrew Tap
440+ uses : actions/checkout@v4
441+ with :
442+ repository : buxuku/homebrew-tap
443+ token : ${{ secrets.HOMEBREW_TAP_TOKEN }}
444+ path : homebrew-tap
445+
446+ - name : Update Cask file
447+ run : |
448+ VERSION="${{ steps.version.outputs.version }}"
449+ SHA256_ARM64="${{ steps.sha256.outputs.sha256_arm64 }}"
450+ SHA256_X64="${{ steps.sha256.outputs.sha256_x64 }}"
451+
452+ CASK_FILE="homebrew-tap/Casks/smartsub.rb"
453+
454+ # Update version
455+ sed -i "s/version \".*\"/version \"${VERSION}\"/" "$CASK_FILE"
456+
457+ # Update SHA256 for Intel (x64) - appears first in on_intel block
458+ sed -i "/on_intel do/,/end/ s/sha256 \"[a-f0-9]*\"/sha256 \"${SHA256_X64}\"/" "$CASK_FILE"
459+
460+ # Update SHA256 for ARM - appears in on_arm block
461+ sed -i "/on_arm do/,/end/ s/sha256 \"[a-f0-9]*\"/sha256 \"${SHA256_ARM64}\"/" "$CASK_FILE"
462+
463+ echo "Updated Cask file:"
464+ cat "$CASK_FILE"
465+
466+ - name : Commit and Push changes
467+ run : |
468+ cd homebrew-tap
469+ git config user.name "github-actions[bot]"
470+ git config user.email "github-actions[bot]@users.noreply.github.com"
471+
472+ git add Casks/smartsub.rb
473+
474+ if git diff --staged --quiet; then
475+ echo "No changes to commit"
476+ else
477+ git commit -m "Update smartsub to ${{ steps.version.outputs.version }}"
478+ git push
479+ echo "Successfully updated homebrew-tap"
480+ fi
0 commit comments