Skip to content
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

Using Shorebird with Codemagic Workflow Editor πŸ› οΈ #76

Open
hadysata opened this issue Jul 10, 2023 · 5 comments
Open

Using Shorebird with Codemagic Workflow Editor πŸ› οΈ #76

hadysata opened this issue Jul 10, 2023 · 5 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@hadysata
Copy link

Hey Shorebird team! 🌟

First of all, let me express my appreciation for your amazing work on Shorebird πŸŽ‰! We're all super excited that code push is finally possible on Flutter! πŸ₯³

I wanted to share a solution I found for using Shorebird with the Codemagic Workflow Editor. As per your documentation, it is mentioned that Codemagic Workflow Editor doesn't support changing the build command, which is required for using Shorebird. I came up with a workaround that allows me to override the default flutter build command with Shorebird's command. I have tested this, and it works successfully on Codemagic.

Here's the setup 🎈:

  1. Create a bash script (let's call it setup_shorebird.sh) with the following content:
#!/bin/bash

# πŸš€ Install Shorebird
curl --proto '=https' --tlsv1.2 https://raw.githubusercontent.com/shorebirdtech/install/main/install.sh -sSf | bash

echo PATH="/Users/builder/.shorebird/bin:$PATH" >> $CM_ENV

export SHOREBIRD_TOKEN="$SHOREBIRD_TOKEN"

# πŸ› οΈ Override the flutter command
cat > flutter_override.sh << 'EOF'
#!/bin/bash

# 🧐 Check if the first argument is "build"
if [ "$1" == "build" ]; then
  # 🎯 Run the modified command
  exec shorebird release android --force -- --dart-define=ENVIRONMENT_TYPE=production
else
  # πŸƒ Run the original command with the original arguments
  exec flutter "$@"
fi
EOF

# πŸ”’ Make the script executable
chmod +x flutter_override.sh

# 🚚 Move the script to /usr/local/bin
sudo mv flutter_override.sh /usr/local/bin/flutter

# 🎊 Print a success message
echo "Flutter override script has been installed successfully."

This script downloads and sets up Shorebird, then overrides the default flutter build command.

  1. In the Codemagic Workflow Editor, add the setup_shorebird.sh script to the "Pre-build script" section.
Screenshot 2023-07-11 at 2 26 21 AM
  1. Add the SHOREBIRD_TOKEN environment variable in the "Environment variables" section of the Codemagic Workflow Editor.
Screenshot 2023-07-11 at 2 27 50 AM

And voilà! 🎩✨ After completing these steps, the Codemagic build process should use Shorebird's command instead of the default flutter build.
Screenshot 2023-07-11 at 2 29 56 AM

Please note that I'm using the shorebird release android --force -- --dart-define=ENVIRONMENT_TYPE=production command to define environment variables. You can customize this as you wish or even make the script super-dynamic to accept any configuration set up in the workflow editor. 😁

I hope this workaround helps others who are looking to use Shorebird with Codemagic Workflow Editor 🌈.

Once again, thank you for your fantastic work on Shorebird πŸ™Œ!

@hadysata hadysata added the bug Something isn't working label Jul 10, 2023
@hadysata
Copy link
Author

Oops, i think this should be on https://github.com/shorebirdtech/docs

@felangel felangel added documentation Improvements or additions to documentation enhancement New feature or request and removed bug Something isn't working labels Jul 11, 2023
@eseidel
Copy link
Contributor

eseidel commented Jul 11, 2023

It's fine they're easy to move around :)

@eseidel eseidel transferred this issue from shorebirdtech/shorebird Jul 11, 2023
@eseidel
Copy link
Contributor

eseidel commented Jul 26, 2023

@nilsreichardt do you have suggestions for what we should do with this? :) Also feel empowered to redirect us to the right codemagic folks.

@nilsreichardt
Copy link
Contributor

Yes, I know how we can integrate this πŸ‘ Cool, script! I'll update the docs in the next few days πŸ‘

@selva-dcx
Copy link

nice hack @hadysata

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants