In one of my repos,
we have an interesting setup where we have 3 different apps from just the master branch.
So in our dev environment, we have a simple trigger -> workflow where we just build the 3 apps consecutively and deploy to hockey for testing as soon as dev has been pushed.
But for ituneconnect case, since we don’t necessarily need to push all 3 apps to itunes connect all the time. Is there a way for bitrise to check the version of the app that has been released in itunes connect. And if it is lower than the next one we are building. build and upload. If not, skip build.
I guess i could just build and upload and mark the steps as continue even with error.
But is there a more efficient way?
1 Like
Hi @liuzhen2008,
I think the more efficient way would be to not to build the version you don’t want to upload.
One possible solution is to clone the workflow, then change the workflows so that you have:
- one workflow which auto builds & pushes to hockey
- and another one which builds & pushes to iTunes
Run the first one every time, and run the second workflow manually, when you want to.
If that wouldn’t be enough and you’d rather have it in one wf with auto skip you could utilize the Build Cache (http://devcenter.bitrise.io/caching/about-caching/) and write some custom scripts, something like:
- After a successful deploy to itunes write the version into
$BITRISE_CACHE_DIR/last-deployed-version
, which will be stored in the cache
- The next time before you’d build the itunes / appstore version read back from
$BITRISE_CACHE_DIR/last-deployed-version
and if it’s the same version expose an env var (with envman: http://devcenter.bitrise.io/tips-and-tricks/expose-environment-variable/) and mark the related steps to be skipped via run_if
(http://devcenter.bitrise.io/tips-and-tricks/disable-a-step-by-condition/#run-a-step-only-if-the-build-failed & https://github.com/bitrise-io/bitrise/blob/master/_examples/experimentals/templates/bitrise.yml).
A very simple example for this, using Bash scripts and a hardcoded “current version” for the sake of the example:
format_version: "5"
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
project_type: other
trigger_map:
- push_branch: '*'
workflow: primary
- pull_request_source_branch: '*'
workflow: primary
workflows:
primary:
steps:
- activate-ssh-key@3.1.1:
run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
- git-clone@4.0.8: {}
- cache-pull@2.0.1: {}
- script@1.1.5:
title: compare version, expose SAME_VERSION if true
inputs:
- content: |-
#!/usr/bin/env bash
set -ex
if [ ! -f "$BITRISE_CACHE_DIR/last-deployed-version" ] ; then
# file does not exist - simply exit with success
exit 0
fi
# file exists - compare version
# NOTE: version is hardcoded here - read it from your project!
current_version='1.2.3'
# compare
version_from_file="$(cat "$BITRISE_CACHE_DIR/last-deployed-version")"
if [[ "$version_from_file" == "$current_version" ]] ; then
# same version - SKIP!
envman add --key SAME_VERSION --value "true"
fi
# not the same version - don't skip
- deploy-to-bitrise-io@1.3.10:
title: this step will be skipped if version is same
run_if: not (enveq "SAME_VERSION" "true")
- script@1.1.5:
title: write current version into cache file
inputs:
- content: |-
#!/usr/bin/env bash
set -ex
# file exists - compare version
# NOTE: version is hardcoded here - read it from your project!
current_version='1.2.3'
# compare
echo -n "$current_version" > "$BITRISE_CACHE_DIR/last-deployed-version"
- cache-push@2.0.5: {}
If you’d have any questions just let us know! 