|
| 1 | +name: Update Homebrew Cask |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + version: |
| 9 | + description: "Version to update (e.g., 0.3.0)" |
| 10 | + required: true |
| 11 | + type: string |
| 12 | + |
| 13 | +jobs: |
| 14 | + update-cask: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + permissions: |
| 17 | + contents: read |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: Get version |
| 21 | + id: version |
| 22 | + run: | |
| 23 | + if [ "${{ github.event_name }}" = "release" ]; then |
| 24 | + VERSION="${{ github.event.release.tag_name }}" |
| 25 | + VERSION="${VERSION#v}" |
| 26 | + else |
| 27 | + VERSION="${{ github.event.inputs.version }}" |
| 28 | + fi |
| 29 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 30 | + echo "Version: $VERSION" |
| 31 | +
|
| 32 | + - name: Calculate SHA256 for ARM64 DMG |
| 33 | + id: sha_arm |
| 34 | + run: | |
| 35 | + URL="https://github.com/melandlabs/release/releases/download/v${{ steps.version.outputs.version }}/Lumis_${{ steps.version.outputs.version }}_aarch64.dmg" |
| 36 | + echo "Downloading from: $URL" |
| 37 | + SHA=$(curl -sfL "$URL" | shasum -a 256 | cut -d ' ' -f 1) |
| 38 | + if [ -z "$SHA" ]; then |
| 39 | + echo "Error: Failed to download ARM64 DMG" |
| 40 | + exit 1 |
| 41 | + fi |
| 42 | + echo "sha=$SHA" >> $GITHUB_OUTPUT |
| 43 | + echo "ARM64 SHA256: $SHA" |
| 44 | +
|
| 45 | + - name: Calculate SHA256 for Intel DMG |
| 46 | + id: sha_intel |
| 47 | + run: | |
| 48 | + URL="https://github.com/melandlabs/release/releases/download/v${{ steps.version.outputs.version }}/Lumis_${{ steps.version.outputs.version }}_x64.dmg" |
| 49 | + echo "Downloading from: $URL" |
| 50 | + SHA=$(curl -sfL "$URL" | shasum -a 256 | cut -d ' ' -f 1) |
| 51 | + if [ -z "$SHA" ]; then |
| 52 | + echo "Error: Failed to download Intel DMG" |
| 53 | + exit 1 |
| 54 | + fi |
| 55 | + echo "sha=$SHA" >> $GITHUB_OUTPUT |
| 56 | + echo "Intel SHA256: $SHA" |
| 57 | +
|
| 58 | + - name: Checkout repository |
| 59 | + uses: actions/checkout@v4 |
| 60 | + with: |
| 61 | + ref: main |
| 62 | + path: homebrew-lumis |
| 63 | + |
| 64 | + - name: Update Cask file |
| 65 | + run: | |
| 66 | + cd homebrew-lumis |
| 67 | + CASK_FILE="Casks/lumis.rb" |
| 68 | + VERSION="${{ steps.version.outputs.version }}" |
| 69 | + ARM_SHA="${{ steps.sha_arm.outputs.sha }}" |
| 70 | + INTEL_SHA="${{ steps.sha_intel.outputs.sha }}" |
| 71 | +
|
| 72 | + echo "Updating $CASK_FILE" |
| 73 | + echo " Version: $VERSION" |
| 74 | + echo " ARM64 SHA: $ARM_SHA" |
| 75 | + echo " Intel SHA: $INTEL_SHA" |
| 76 | +
|
| 77 | + sed -i "s/version \"[^\"]*\"/version \"$VERSION\"/" "$CASK_FILE" |
| 78 | + sed -i "s/sha256 arm: \"[^\"]*\"/sha256 arm: \"$ARM_SHA\"/" "$CASK_FILE" |
| 79 | + sed -i "s/intel: \"[^\"]*\"/intel: \"$INTEL_SHA\"/" "$CASK_FILE" |
| 80 | +
|
| 81 | + echo "Updated content:" |
| 82 | + head -15 "$CASK_FILE" |
| 83 | +
|
| 84 | + - name: Commit and push |
| 85 | + run: | |
| 86 | + cd homebrew-lumis |
| 87 | + git config user.name "github-actions[bot]" |
| 88 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 89 | + git add Casks/lumis.rb |
| 90 | + git commit -m "chore: update homebrew cask to v${{ steps.version.outputs.version }}" |
| 91 | + git push |
0 commit comments