Skip to content

feat(x): manual mobileproxy release action #449

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

daniellacosse
Copy link
Contributor

@daniellacosse daniellacosse commented May 7, 2025

Screenshot 2025-05-07 at 12 27 23 PM

This pull request introduces a new script and workflow for automating the build and release process of the mobileproxy for iOS and Android. The script handles building artifacts, while the workflow integrates it into GitHub Actions for streamlined execution.

New script for building and releasing mobileproxy:

  • Added .github/scripts/release-mobileproxy.sh, a Bash script that builds the mobileproxy for iOS and Android, zips the iOS framework, and optionally uploads the artifacts to a GitHub release. It supports environment variables and CLI arguments for configuration.

GitHub Actions workflow for mobileproxy release:

  • Added .github/workflows/release-mobileproxy.yml, a workflow that triggers the release script via a workflow_dispatch event. It includes steps to set up Go, install the GitHub CLI, and execute the release script with the provided release_tag.

For a preview of how this will be used in the web wrapper: #446

@daniellacosse daniellacosse requested a review from Copilot May 7, 2025 14:26
Copilot

This comment was marked as resolved.

@daniellacosse daniellacosse force-pushed the daniellacosse/mobileproxy-release-action branch from fab7a6d to a822d14 Compare May 7, 2025 14:29
@daniellacosse daniellacosse requested a review from fortuna May 7, 2025 14:39
@daniellacosse daniellacosse marked this pull request as draft May 7, 2025 16:09
@daniellacosse daniellacosse marked this pull request as ready for review May 7, 2025 16:28
Copy link
Contributor

@fortuna fortuna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for getting this done so quickly.

There are a number of open questions on the release format:

  • Do we want to use releases for Android, or push to the Maven repo?
  • For Switch, I think the package has to be in the root and use the root version tag, which conflicts with the Go main module versioning. We might need a new repo, we need to discuss.

Given these open questions, can you turn the PR into a taskfile to build Mobileproxy for now?

fi

CLONE_DIR=$(mktemp -d)
trap "echo 'Cleaning up temporary clone directory: ${CLONE_DIR}'; rm -rf '${CLONE_DIR}'" EXIT
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this EXIT?

echo "Cloning repository at tag ${RELEASE_TAG} into ${CLONE_DIR}..."
CLONE_URL_BASE="github.com/Jigsaw-Code/outline-sdk.git"
if [[ -n "${GH_TOKEN:-}" ]]; then
CLONE_URL="https://x-access-token:${GH_TOKEN}@${CLONE_URL_BASE}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need the token to clone a public repository. Please remove.

else
CLONE_URL="https://%s@${CLONE_URL_BASE}"
fi
git clone --depth 1 --branch "${RELEASE_TAG}" "${CLONE_URL}" "${CLONE_DIR}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to clone? That adds complexity.

We are already in the repository. Let's just git switch to the tag, and call:

    if ! (output="$(git status --porcelain)" && [[ -z "$output" ]]); then
      fail "Cloned repository is not clean. Reset changes and try again."
    fi

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also if we need to use GitHub actions, we don't need to clone, GitHub will clone the repository for us.

echo "Building Mobileproxy for iOS..."
(
cd "${X_DIR_IN_CLONE}"
gomobile bind -ldflags='-s -w' -target=ios -iosversion=11.0 -o "${IOS_FRAMEWORK_PATH}" \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm concerned about the duplication with the mobileproxy instructions.

Let's create a build script for the mobile proxy.

But bash is not that great. Can you migrate this to Taskfile? That was we can build things incrementally.

We can have "release" as one of the tasks, like we have in outline-ss-server:
https://github.com/Jigsaw-Code/outline-ss-server/blob/master/Taskfile.yml

Our tun2socks build illustrates how to use Tasks with Go Mobile:
https://github.com/Jigsaw-Code/outline-apps/blob/master/client/go/Taskfile.yml

The MobileProxy tasks should live in its directory, but called from the root, like we do in outline-apps:
https://github.com/Jigsaw-Code/outline-apps/blob/master/Taskfile.yml

We can then update the instructions to call the task instead.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to bash -> taskfile.


if [[ -n "${GH_TOKEN:-}" ]]; then
echo "GH_TOKEN is set. Uploading artifacts to release tag ${RELEASE_TAG}..."
gh release upload "${RELEASE_TAG}" "${IOS_ZIP_PATH}" "${ANDROID_AAR_PATH}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may want to release Android to Maven instead, so users don't need jitpack: https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-gradle-registry

In that case, perhaps we don't want to use this release mode and support two different ways.

echo "Zipping Mobileproxy.xcframework for iOS..."
(
cd "${MOBILEPROXY_ARTIFACT_DIR}"
zip -qr "$(basename "${IOS_ZIP_PATH}")" "$(basename "${IOS_FRAMEWORK_PATH}")"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will need to add the Swift package too.

@fortuna fortuna requested a review from jyyi1 May 7, 2025 21:37
echo "Building Mobileproxy for iOS..."
(
cd "${X_DIR_IN_CLONE}"
gomobile bind -ldflags='-s -w' -target=ios -iosversion=11.0 -o "${IOS_FRAMEWORK_PATH}" \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to bash -> taskfile.

else
CLONE_URL="https://%s@${CLONE_URL_BASE}"
fi
git clone --depth 1 --branch "${RELEASE_TAG}" "${CLONE_URL}" "${CLONE_DIR}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also if we need to use GitHub actions, we don't need to clone, GitHub will clone the repository for us.

echo "Building gomobile and gobind from cloned tag ${RELEASE_TAG}..."
(
cd "${X_DIR_IN_CLONE}"
go build -o "${MOBILEPROXY_BUILD_TOOLS_DIR}/gomobile" golang.org/x/mobile/cmd/gomobile
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recently I was thinking whether we should always build the latest gomobile, because it might introduce breaking changes. Shall we use a specific tag instead so prevent it from breaking our builds?


if [[ -n "${GH_TOKEN:-}" ]]; then
echo "GH_TOKEN is set. Uploading artifacts to release tag ${RELEASE_TAG}..."
gh release upload "${RELEASE_TAG}" "${IOS_ZIP_PATH}" "${ANDROID_AAR_PATH}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Google doesn't allow us to put GitHub tokens in actions? So does that mean we will never be able to use it in actions?


jobs:
release_mobileproxy:
runs-on: ubuntu-latest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we build xcframework on Ubuntu?

- name: Checkout
uses: actions/checkout@v4

- name: Set up Go
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any JDK or XCode required?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants