Update Homebrew Formula #8
This file contains 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 Homebrew Formula | |
on: | |
release: | |
types: [published] | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: "Release tag to update the formula (e.g., 'v2.0.12')" | |
required: false | |
default: "2.0.11" | |
jobs: | |
update-formula: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Extract version from input or release | |
id: extract_version | |
run: | | |
# Use the provided tag if triggered manually, otherwise use the release tag | |
if [ "${{ github.event.inputs.tag }}" != "" ]; then | |
VERSION="${{ github.event.inputs.tag }}" | |
else | |
VERSION="${GITHUB_REF#refs/tags/}" | |
fi | |
# Normalize by removing a leading 'v' if present | |
VERSION="${VERSION#v}" | |
echo "version=$VERSION" >> $GITHUB_OUTPUT | |
- name: Find jar asset download URL | |
id: find_asset | |
run: | | |
# Get release data from GitHub API | |
release_data=$(curl -sL -H "Accept: application/vnd.github+json" \ | |
"https://api.github.com/repos/skidfuscatordev/skidfuscator-java-obfuscator/releases/tags/${{ steps.extract_version.outputs.version }}") | |
# Find the asset named 'skidfuscator.jar' (adjust if needed) | |
asset_url=$(echo "$release_data" | jq -r '.assets[] | select(.name == "skidfuscator.jar") | .browser_download_url') | |
if [ -z "$asset_url" ]; then | |
echo "Could not find skidfuscator.jar in the release." | |
exit 1 | |
fi | |
echo "asset_url=$asset_url" >> $GITHUB_OUTPUT | |
- name: Download jar | |
run: | | |
curl -L ${{ steps.find_asset.outputs.asset_url }} -o skidfuscator.jar | |
- name: Compute SHA256 | |
id: sha256 | |
run: | | |
SHA256=$(shasum -a 256 skidfuscator.jar | awk '{print $1}') | |
echo "sha256=$SHA256" >> $GITHUB_OUTPUT | |
- name: Checkout tap repository | |
uses: actions/checkout@v3 | |
with: | |
repository: skidfuscatordev/homebrew-skidfuscator | |
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
ref: master | |
- name: List Files | |
run: ls -R | |
- name: Cleanup and Prepare Formula | |
run: | | |
# Remove any existing formula files | |
rm -f ./Formula/skidfuscator*.rb | |
# Create the new formula file | |
FORMULA_PATH="Formula/skidfuscator.rb" | |
cat <<EOF > "$FORMULA_PATH" | |
class Skidfuscator < Formula | |
desc "A JVM-based obfuscation suite designed for Java and Android bytecode" | |
homepage "https://github.com/skidfuscatordev/skidfuscator-java-obfuscator" | |
url "${{ steps.find_asset.outputs.asset_url }}" | |
sha256 "${{ steps.sha256.outputs.sha256 }}" | |
version "${{ steps.extract_version.outputs.version }}" | |
license "MIT" | |
def install | |
libexec.install Dir["*.jar"] | |
jar_name = Dir["#{libexec}/*.jar"].first | |
(bin/"skidfuscator").write <<~EOS | |
#!/usr/bin/env bash | |
exec java -jar "#{jar_name}" "\$@" | |
EOS | |
(bin/"skidfuscator").chmod 0755 | |
end | |
test do | |
output = shell_output("#{bin}/skidfuscator --help", 0) | |
assert_match "Usage", output | |
end | |
end | |
EOF | |
- name: Debug Formula Content | |
run: | | |
echo "Formula content:" | |
cat "$FORMULA_PATH" | |
echo "Git status:" | |
git status | |
- name: Commit and push changes | |
run: | | |
git config user.name "github-actions" | |
git config user.email "[email protected]" | |
git add ./Formula/skidfuscator.rb | |
git commit -m "Update Skidfuscator formula to version ${{ steps.extract_version.outputs.version }}" | |
git push origin HEAD:master | |
env: | |
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |