shorebirdtech / docs

The shorebird docs site
https://docs.shorebird.dev
MIT License
9 stars 23 forks source link

docs: Codemagic advanced script doesn't work with patches #107

Open mtwichel opened 1 year ago

mtwichel commented 1 year ago

Description

The current codemagic "advanced example" is this:

workflows:
  advanced-example:
    name: Advanced Example
    environment:
      vars:
        TYPE: 'patch' # Can be 'patch' or 'release'
      groups:
        # Exports the SHOREBIRD_TOKEN environment variable
        - shorebird
      flutter: stable
    scripts:
      - name: 🐦 Setup Shorebird
        script: |
          # Install Shorebird
          curl --proto '=https' --tlsv1.2 https://raw.githubusercontent.com/shorebirdtech/install/main/install.sh -sSf | bash

          # Add Shorebird to PATH
          echo PATH="$HOME/.shorebird/bin:$PATH" >> $CM_ENV
      - name: 🙌 Shorebird Build
        script: |
          echo "➡️ Using type: $TYPE"

          # If type is neither "patch" nor "release", exit with error
          if [ "$TYPE" != "patch" ] && [ "$TYPE" != "release" ]; then
            echo "TYPE must be either 'patch' or 'release'"
            exit 1
          fi

          # Check type and run corresponding command
          if [ "$TYPE" == "patch" ]; then
            echo "🩹 Running patch command"
            shorebird patch android --force
          elif [ "$TYPE" == "release" ]; then
            echo "🚀 Running release command"
            shorebird release android --force
          fi

However, you will probably add a publishing section to your file so that you can get your apps on the stores. The problem is that when you do this, it will try to submit to the App Store you configured, even if you run a patch. Since no file is produced from the patch command, this makes the workflow fail.

I would suggest changing this example to have two workflows, one with the patch command and the other with the release command.

We've actually implemented this in our codemagic.yaml, as well as including a separate iOS and Android workflows, but it keeps it clean by reusing steps where possible. If you'd like, I'd be happy to clean off our domain-specific stuff and put up a PR on this page.

Thanks!

eseidel commented 1 year ago

Thanks! FYI @nilsreichardt

nilsreichardt commented 1 year ago

Yes, that makes sense, @mtwichel :+1: Thanks for filling this ticket ❤️ You can either just send me the codemagic.yaml and I update the docs, or you fill a PR - just as you like ✌️