Update Formula #4
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 Formula" | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version to update to (e.g., v1.2.5)' | |
| required: true | |
| type: string | |
| jobs: | |
| update-formula: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Calculate new hashes | |
| id: hashes | |
| run: | | |
| # Get version from workflow dispatch input | |
| VERSION="${{ github.event.inputs.version }}" | |
| BASE_URL="https://github.com/interline-io/transitland-lib/releases/download/${VERSION}" | |
| # Create temporary directory | |
| TEMP_DIR=$(mktemp -d) | |
| cd "$TEMP_DIR" | |
| # Download and calculate hashes | |
| echo "Downloading files for version ${VERSION}..." | |
| # macOS Intel | |
| curl -L "${BASE_URL}/transitland-macos-intel" -o transitland-macos-intel | |
| MACOS_INTEL_HASH=$(sha256sum transitland-macos-intel | cut -d' ' -f1) | |
| echo "macos_intel_hash=${MACOS_INTEL_HASH}" >> $GITHUB_OUTPUT | |
| # macOS Apple Silicon | |
| curl -L "${BASE_URL}/transitland-macos-apple" -o transitland-macos-apple | |
| MACOS_APPLE_HASH=$(sha256sum transitland-macos-apple | cut -d' ' -f1) | |
| echo "macos_apple_hash=${MACOS_APPLE_HASH}" >> $GITHUB_OUTPUT | |
| # Linux | |
| curl -L "${BASE_URL}/transitland-linux" -o transitland-linux | |
| LINUX_HASH=$(sha256sum transitland-linux | cut -d' ' -f1) | |
| echo "linux_hash=${LINUX_HASH}" >> $GITHUB_OUTPUT | |
| # Store version for later use | |
| echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
| # Clean up | |
| cd - > /dev/null | |
| rm -rf "$TEMP_DIR" | |
| echo "Calculated hashes:" | |
| echo "Version: ${VERSION}" | |
| echo "macOS Intel: ${MACOS_INTEL_HASH}" | |
| echo "macOS Apple: ${MACOS_APPLE_HASH}" | |
| echo "Linux: ${LINUX_HASH}" | |
| - name: Update Homebrew formula | |
| run: | | |
| VERSION="${{ steps.hashes.outputs.version }}" | |
| FORMULA_FILE="transitland-lib.rb" | |
| # Update version | |
| sed -i "s/version \"v[0-9.]*\"/version \"${VERSION}\"/" "$FORMULA_FILE" | |
| # Update hashes | |
| sed -i "s/sha256 \"[a-f0-9]\{64\}\" # macOS Intel/sha256 \"${{ steps.hashes.outputs.macos_intel_hash }}\" # macOS Intel/" "$FORMULA_FILE" | |
| sed -i "s/sha256 \"[a-f0-9]\{64\}\" # macOS Apple/sha256 \"${{ steps.hashes.outputs.macos_apple_hash }}\" # macOS Apple/" "$FORMULA_FILE" | |
| sed -i "s/sha256 \"[a-f0-9]\{64\}\" # Linux/sha256 \"${{ steps.hashes.outputs.linux_hash }}\" # Linux/" "$FORMULA_FILE" | |
| - name: Create Pull Request | |
| id: cpr | |
| uses: peter-evans/create-pull-request@v7 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| path: . | |
| branch: update-formula-${{ steps.hashes.outputs.version }} | |
| title: "Update transitland-lib to ${{ steps.hashes.outputs.version }}" | |
| body: | | |
| This PR updates the Homebrew formula for transitland-lib to version ${{ steps.hashes.outputs.version }}. | |
| ## Changes | |
| - Updated version to ${{ steps.hashes.outputs.version }} | |
| - Updated SHA256 hashes for all platform binaries: | |
| - macOS Intel: `${{ steps.hashes.outputs.macos_intel_hash }}` | |
| - macOS Apple Silicon: `${{ steps.hashes.outputs.macos_apple_hash }}` | |
| - Linux: `${{ steps.hashes.outputs.linux_hash }}` | |
| ## Release | |
| https://github.com/interline-io/transitland-lib/releases/tag/${{ steps.hashes.outputs.version }} | |
| --- | |
| *Auto-generated by GitHub Actions* | |
| commit-message: "Update transitland-lib to ${{ steps.hashes.outputs.version }}" | |
| delete-branch: true | |
| - name: Log PR creation results | |
| if: ${{ steps.cpr.outputs.pull-request-number }} | |
| run: | | |
| echo "✅ Pull Request created successfully!" | |
| echo "PR Number: ${{ steps.cpr.outputs.pull-request-number }}" | |
| echo "PR URL: ${{ steps.cpr.outputs.pull-request-url }}" | |
| echo "Branch: ${{ steps.cpr.outputs.pull-request-branch }}" |