From d4c97e80549d09b962e0656bdba000dffd99b617 Mon Sep 17 00:00:00 2001 From: Maksym Bilan Date: Mon, 15 Sep 2025 13:56:44 +0300 Subject: [PATCH 1/9] ci: fix brew workflow dry_run condition and add debug inputs Use fromJSON to parse boolean input and avoid skipped run due to string truthiness. Add step to echo inputs for easier troubleshooting. --- .github/workflows/brew-release.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/brew-release.yml b/.github/workflows/brew-release.yml index 5ecceb0..021350e 100644 --- a/.github/workflows/brew-release.yml +++ b/.github/workflows/brew-release.yml @@ -36,6 +36,12 @@ jobs: runs-on: macos-latest timeout-minutes: 30 steps: + - name: Show dispatch inputs + run: | + echo "tap=${{ inputs.tap }}" + echo "formula=${{ inputs.formula }}" + echo "dry_run=${{ inputs.dry_run }}" + echo "tag=${{ inputs.tag }}" - name: Checkout uses: actions/checkout@v4 with: @@ -92,7 +98,7 @@ jobs: } >> "$GITHUB_OUTPUT" - name: Show computed values (dry run) - if: ${{ inputs.dry_run == true }} + if: ${{ fromJSON(inputs.dry_run) }} run: | echo "Tap: ${{ inputs.tap }}" echo "Formula: ${{ inputs.formula }}" @@ -102,7 +108,7 @@ jobs: echo "Skipping bump-formula-pr due to dry_run=true" - name: Bump formula in tap - if: ${{ inputs.dry_run != true }} + if: ${{ !fromJSON(inputs.dry_run) }} env: HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }} run: | From 3b58f0a230f341bcbec7178f02155c669a3d6604 Mon Sep 17 00:00:00 2001 From: Maksym Bilan Date: Mon, 15 Sep 2025 15:16:34 +0300 Subject: [PATCH 2/9] clean up --- .github/workflows/brew-release.yml | 134 ----------------------------- 1 file changed, 134 deletions(-) delete mode 100644 .github/workflows/brew-release.yml diff --git a/.github/workflows/brew-release.yml b/.github/workflows/brew-release.yml deleted file mode 100644 index 021350e..0000000 --- a/.github/workflows/brew-release.yml +++ /dev/null @@ -1,134 +0,0 @@ -name: Brew Release - -on: - workflow_dispatch: - inputs: - tap: - description: "Homebrew tap (e.g., owner/homebrew-tap)" - required: true - type: string - formula: - description: "Formula name" - required: true - default: "xcloud" - type: string - tag: - description: "Override tag to release (optional). Uses latest tag if empty." - required: false - type: string - dry_run: - description: "Don't open PR, just print computed values" - required: false - default: false - type: boolean - -permissions: - contents: read - pull-requests: write - -concurrency: - group: ${{ github.workflow }} - cancel-in-progress: false - -jobs: - bump-formula: - name: Bump Homebrew formula to latest tag - runs-on: macos-latest - timeout-minutes: 30 - steps: - - name: Show dispatch inputs - run: | - echo "tap=${{ inputs.tap }}" - echo "formula=${{ inputs.formula }}" - echo "dry_run=${{ inputs.dry_run }}" - echo "tag=${{ inputs.tag }}" - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 # need tags - - - name: Determine tag and artifact info - id: prep - shell: bash - run: | - set -euo pipefail - - if [[ -z "${{ inputs.tap }}" ]]; then - echo "Tap is required (e.g., owner/homebrew-tap)" >&2 - exit 1 - fi - - TAG_INPUT="${{ inputs.tag }}" - if [[ -n "$TAG_INPUT" ]]; then - TAG="$TAG_INPUT" - else - # Prefer semantic version sort; fallback to creation date - TAG="$(git tag --sort=-version:refname | head -n1 || true)" - if [[ -z "$TAG" ]]; then - TAG="$(git tag --sort=-creatordate | head -n1 || true)" - fi - fi - - if [[ -z "$TAG" ]]; then - echo "No tags found and no tag provided." >&2 - exit 1 - fi - - REPO="${{ github.repository }}" - TARBALL_URL="https://github.com/${REPO}/archive/refs/tags/${TAG}.tar.gz" - echo "Latest tag: $TAG" - echo "Tarball URL: $TARBALL_URL" - - echo "Computing SHA256 for tarball..." - # macOS provides shasum - SHA256="$(curl -LfsS "$TARBALL_URL" | shasum -a 256 | awk '{print $1}')" - - if [[ -z "$SHA256" ]]; then - echo "Failed to compute SHA256." >&2 - exit 1 - fi - - echo "sha256: $SHA256" - - # Set outputs - { - echo "tag=$TAG" - echo "tarball_url=$TARBALL_URL" - echo "sha256=$SHA256" - } >> "$GITHUB_OUTPUT" - - - name: Show computed values (dry run) - if: ${{ fromJSON(inputs.dry_run) }} - run: | - echo "Tap: ${{ inputs.tap }}" - echo "Formula: ${{ inputs.formula }}" - echo "Tag: ${{ steps.prep.outputs.tag }}" - echo "Tarball URL: ${{ steps.prep.outputs.tarball_url }}" - echo "SHA256: ${{ steps.prep.outputs.sha256 }}" - echo "Skipping bump-formula-pr due to dry_run=true" - - - name: Bump formula in tap - if: ${{ !fromJSON(inputs.dry_run) }} - env: - HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }} - run: | - set -euo pipefail - - if [[ -z "${HOMEBREW_GITHUB_API_TOKEN:-}" ]]; then - echo "HOMEBREW_GITHUB_API_TOKEN secret is not set. Add it in repo/org secrets." >&2 - exit 1 - fi - - brew --version - brew update-reset - brew tap "${{ inputs.tap }}" || true - - # Open a PR bumping the formula to the latest tag tarball - brew bump-formula-pr \ - --no-browse \ - --force \ - --tap "${{ inputs.tap }}" \ - --url "${{ steps.prep.outputs.tarball_url }}" \ - --sha256 "${{ steps.prep.outputs.sha256 }}" \ - --message "${{ inputs.formula }} ${{ steps.prep.outputs.tag }}" \ - "${{ inputs.formula }}" From e8ef3f156646f1f2d3249422bd5c9a59b2568091 Mon Sep 17 00:00:00 2001 From: Maksym Bilan Date: Mon, 15 Sep 2025 15:19:52 +0300 Subject: [PATCH 3/9] script --- release.sh | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100755 release.sh diff --git a/release.sh b/release.sh new file mode 100755 index 0000000..ed0a4a6 --- /dev/null +++ b/release.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +set -e + +# Configuration +GITHUB_USER="your_github_username" +HOMEBREW_TAP_REPO="homebrew-tap" +PACKAGE_NAME="xcloud" +VERSION=$(grep "^version" Cargo.toml | sed 's/version = "\(.*\)"/\1/') + +# 1. Build the release binary +echo "Building release binary..." +cargo build --release + +# 2. Create a tarball of the binary +echo "Creating tarball..." +mkdir -p "target/release/${PACKAGE_NAME}-${VERSION}" +cp "target/release/${PACKAGE_NAME}" "target/release/${PACKAGE_NAME}-${VERSION}/" +tar -czf "target/release/${PACKAGE_NAME}-${VERSION}.tar.gz" -C "target/release" "${PACKAGE_NAME}-${VERSION}" + +# 3. Create a new GitHub release and upload the tarball +echo "Creating GitHub release..." +gh release create "v${VERSION}" "target/release/${PACKAGE_NAME}-${VERSION}.tar.gz" --title "v${VERSION}" --notes "Release v${VERSION}" + +# 4. Generate a Homebrew formula +echo "Generating Homebrew formula..." +FORMULA_URL="https://github.com/${GITHUB_USER}/${PACKAGE_NAME}/releases/download/v${VERSION}/${PACKAGE_NAME}-${VERSION}.tar.gz" +SHA256=$(shasum -a 256 "target/release/${PACKAGE_NAME}-${VERSION}.tar.gz" | awk '{print $1}') + +cat > "${PACKAGE_NAME}.rb" < Date: Mon, 15 Sep 2025 15:22:22 +0300 Subject: [PATCH 4/9] polishing --- release.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/release.sh b/release.sh index ed0a4a6..1b18893 100755 --- a/release.sh +++ b/release.sh @@ -6,7 +6,14 @@ set -e GITHUB_USER="your_github_username" HOMEBREW_TAP_REPO="homebrew-tap" PACKAGE_NAME="xcloud" -VERSION=$(grep "^version" Cargo.toml | sed 's/version = "\(.*\)"/\1/') +LATEST_TAG=$(git describe --tags --abbrev=0) +if [ -z "$LATEST_TAG" ]; then + echo "Error: No tags found. Please create a tag first." + exit 1 +fi + +# Strip 'v' prefix if it exists +VERSION=${LATEST_TAG#v} # 1. Build the release binary echo "Building release binary..." @@ -18,9 +25,9 @@ mkdir -p "target/release/${PACKAGE_NAME}-${VERSION}" cp "target/release/${PACKAGE_NAME}" "target/release/${PACKAGE_NAME}-${VERSION}/" tar -czf "target/release/${PACKAGE_NAME}-${VERSION}.tar.gz" -C "target/release" "${PACKAGE_NAME}-${VERSION}" -# 3. Create a new GitHub release and upload the tarball -echo "Creating GitHub release..." -gh release create "v${VERSION}" "target/release/${PACKAGE_NAME}-${VERSION}.tar.gz" --title "v${VERSION}" --notes "Release v${VERSION}" +# 3. Upload the tarball to the existing GitHub release +echo "Uploading asset to GitHub release ${LATEST_TAG}..." +gh release upload "${LATEST_TAG}" "target/release/${PACKAGE_NAME}-${VERSION}.tar.gz" --clobber # 4. Generate a Homebrew formula echo "Generating Homebrew formula..." From 3931428f203729d3084fcb29527f9bd16442aa6e Mon Sep 17 00:00:00 2001 From: Maksym Bilan Date: Mon, 15 Sep 2025 15:25:08 +0300 Subject: [PATCH 5/9] Names --- release.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/release.sh b/release.sh index 1b18893..59c1892 100755 --- a/release.sh +++ b/release.sh @@ -3,8 +3,8 @@ set -e # Configuration -GITHUB_USER="your_github_username" -HOMEBREW_TAP_REPO="homebrew-tap" +GITHUB_USER="maximbilan" +HOMEBREW_TAP_REPO="xcloud" PACKAGE_NAME="xcloud" LATEST_TAG=$(git describe --tags --abbrev=0) if [ -z "$LATEST_TAG" ]; then From 2b8ec151171b3c5cde1cd1bd5de3c6727f88db61 Mon Sep 17 00:00:00 2001 From: Maksym Bilan Date: Mon, 15 Sep 2025 15:27:39 +0300 Subject: [PATCH 6/9] Bug fixes --- release.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/release.sh b/release.sh index 59c1892..7f0573a 100755 --- a/release.sh +++ b/release.sh @@ -51,6 +51,7 @@ EOF # 5. Commit the formula to a Homebrew tap echo "Committing formula to Homebrew tap..." git clone "https://github.com/${GITHUB_USER}/${HOMEBREW_TAP_REPO}.git" +mkdir -p "${HOMEBREW_TAP_REPO}/Formula" mv "${PACKAGE_NAME}.rb" "${HOMEBREW_TAP_REPO}/Formula/" cd "${HOMEBREW_TAP_REPO}" git add "Formula/${PACKAGE_NAME}.rb" From d8709d2c8249f830dcf8b25e6fa87297350924af Mon Sep 17 00:00:00 2001 From: Maksym Bilan Date: Mon, 15 Sep 2025 16:08:48 +0300 Subject: [PATCH 7/9] release script --- release.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/release.sh b/release.sh index 7f0573a..5bd8b68 100755 --- a/release.sh +++ b/release.sh @@ -31,7 +31,7 @@ gh release upload "${LATEST_TAG}" "target/release/${PACKAGE_NAME}-${VERSION}.tar # 4. Generate a Homebrew formula echo "Generating Homebrew formula..." -FORMULA_URL="https://github.com/${GITHUB_USER}/${PACKAGE_NAME}/releases/download/v${VERSION}/${PACKAGE_NAME}-${VERSION}.tar.gz" +FORMULA_URL="https://github.com/${GITHUB_USER}/${PACKAGE_NAME}/releases/download/${LATEST_TAG}/${PACKAGE_NAME}-${VERSION}.tar.gz" SHA256=$(shasum -a 256 "target/release/${PACKAGE_NAME}-${VERSION}.tar.gz" | awk '{print $1}') cat > "${PACKAGE_NAME}.rb" < Date: Mon, 15 Sep 2025 16:09:12 +0300 Subject: [PATCH 8/9] ignore update --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 0728338..553887a 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,4 @@ target # Added by cargo /target +/xcloud \ No newline at end of file From 5e263d852470ad6aaa86f7c3d9d6b1b25a738d38 Mon Sep 17 00:00:00 2001 From: Maksym Bilan Date: Mon, 15 Sep 2025 16:10:05 +0300 Subject: [PATCH 9/9] readme --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index b93dff1..c57d40a 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,13 @@ A powerful command-line interface for Apple's Xcode Cloud, built in Rust. Manage ## Installation +### Homebrew + +```bash +brew tap maximbilan/xcloud https://github.com/maximbilan/xcloud +brew install xcloud +``` + ### From Source ```bash