Brand new to Bitrise and CI. My goal is to trigger build and release to App Store Connect when I tag a build in my repo. I have the triggering working as expected. What I want to know is if it’s possible to extract a version and build number from the BITRISE_GIT_TAG env var. I want to tag a commit on GH with DEV v1.0.3-22 and then run a workflow with Set Xcode Project Build Number step where I set the Build Number to 22 and Version Number to 1.0.3. This mirrors our CI/CD processes on our backend.
How could I go about doing this?
The way I ended up handling this was to add a custom script step with the code below. It seems a bit hacky but has been working reliably.
#!/usr/bin/env bash
# fail if any commands fails
set -e
# make pipelines' return status equal the last command to exit with a non-zero status, or zero if all commands exit successfully
set -o pipefail
# debug log
set -x
# write your script here
tag="$BITRISE_GIT_TAG"
app_version="0.0.0"
build_number="1"
if [ ! -z "$tag" ] ; then
echo $tag
pattern='[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'
if [[ $tag =~ $pattern ]]; then
app_version=${BASH_REMATCH[0]}
else echo 'App Version not found';
fi
build_number=${tag##*-}
envman add --key app_build_number --value "$build_number"
envman add --key app_version --value "$app_version"
fi