Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
d57f23d
Adds a version calculation workflow
vvolkgang Sep 10, 2024
0eebb3f
New workflow to dispatch, wait and download artifacts from another woโ€ฆ
vvolkgang Sep 10, 2024
c6c2288
PR feedback: Removes unnecessary newline and capitalises step name
vvolkgang Sep 11, 2024
b2eee33
Merge branch 'main' into new-version-calc-2
vvolkgang Sep 17, 2024
8969895
Merge branch 'main' into new-version-calc-2
vvolkgang Sep 17, 2024
c6cc731
Aligned workflow input descriptions
vvolkgang Sep 24, 2024
578dd8e
Merge branch 'main' into new-version-calc-2
vvolkgang Sep 24, 2024
3ac6e45
Add version number override
vvolkgang Sep 24, 2024
d9fabb5
Add patch version override
vvolkgang Sep 24, 2024
cea06bb
Merge branch 'main' into new-version-calc-2
vvolkgang Sep 24, 2024
72b302d
Use version-name in build.yml
vvolkgang Sep 24, 2024
c00992d
Output inputs
vvolkgang Sep 24, 2024
31620ef
Transitions CI-main to the new version-name
vvolkgang Sep 24, 2024
08b996e
Create the version-info.json file if the version calculation step wasโ€ฆ
vvolkgang Sep 24, 2024
f93c2b6
Merge branch 'use-version-name' into ci-version-name
vvolkgang Sep 24, 2024
3a13fe7
Updated comment
vvolkgang Sep 24, 2024
e5f6406
Remove the need to checkout the repo
vvolkgang Sep 24, 2024
a4a3a0e
Merge branch 'main' into new-version-calc-2
vvolkgang Sep 24, 2024
f8da9db
Merge branch 'new-version-calc-2' into use-version-name
vvolkgang Sep 24, 2024
ea4191d
Merge branch 'use-version-name' into ci-version-name
vvolkgang Sep 24, 2024
d94ea1f
Merge branch 'main' into use-version-name
vvolkgang Oct 1, 2024
1e18762
Dispatch action is in the wrong path, workaround it for now
vvolkgang Oct 1, 2024
ba3622e
Revert "Dispatch action is in the wrong path, workaround it for now"
vvolkgang Oct 1, 2024
d3e79bb
Merge branch 'main' into use-version-name
vvolkgang Oct 1, 2024
ccb4b8c
temp: using branch dispatch instead of main
vvolkgang Oct 1, 2024
dd8513b
Add shell to dispatch
vvolkgang Oct 1, 2024
073411c
Update workflow inputs default values
vvolkgang Oct 1, 2024
5eea7a1
Fix patch input name
vvolkgang Oct 1, 2024
f18cd1a
Add debug logs
vvolkgang Oct 1, 2024
55ebfef
Improve Inputs GitHub summary
vvolkgang Oct 1, 2024
ef4ba26
Fix patch version input
vvolkgang Oct 1, 2024
ca07309
Directory needs to be created first
vvolkgang Oct 1, 2024
bf760bc
use branch version
vvolkgang Oct 1, 2024
7198cca
Change Version Number type to string
vvolkgang Oct 1, 2024
9e80635
Waiting for workflow to finish
vvolkgang Oct 1, 2024
05bb447
fix patch version
vvolkgang Oct 1, 2024
0988a2b
Removing step skip for now
vvolkgang Oct 1, 2024
cbd5b80
Updated other steps to use the new version info
vvolkgang Oct 1, 2024
219de30
Reverted testing changes and improved comments
vvolkgang Oct 2, 2024
9aebadb
Merge branch 'main' into use-version-name
vvolkgang Oct 2, 2024
dcb9afa
Merge branch 'use-version-name' into ci-version-name
vvolkgang Oct 2, 2024
504caee
Merge branch 'main' into ci-version-name
vvolkgang Oct 2, 2024
1f5be84
Fix inputs
vvolkgang Oct 2, 2024
abba86e
Fix Read version info
vvolkgang Oct 2, 2024
1fa0328
Testing input checks
vvolkgang Oct 2, 2024
f94de31
Fix job output
vvolkgang Oct 2, 2024
cee6f4a
fix ""
vvolkgang Oct 2, 2024
c178d2f
fix environment var use
vvolkgang Oct 2, 2024
a48819d
Add tests
vvolkgang Oct 2, 2024
900a769
Fixed step check
vvolkgang Oct 2, 2024
808b6b8
Add the ability to skip distributing builds
vvolkgang Oct 2, 2024
b67c219
Adds Upload Version Info input to build and fixes input related issues
vvolkgang Oct 2, 2024
6f8e1a9
Merge branch 'main' into ci-version-name
vvolkgang Oct 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 56 additions & 56 deletions .github/workflows/CI-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,84 +12,84 @@ on:
build-number:
description: "Version Number Override - e.g. '1021'"
type: number

patch_version:
description: "Patch Version Override - e.g. '999'"
type: string
distribute:
description: "Distribute to TestFlight"
type: boolean
env:
XCODE_VERSION: '15.4'

DISTRIBUTE_TO_TESTFLIGHT: ${{ github.event_name == 'push' || inputs.distribute }}
jobs:
resolve-values:
name: "Resolve values"
runs-on: macos-14
runs-on: ubuntu-latest
outputs:
build_variant: ${{ steps.calculate.outputs.variant }}
build_version: ${{ steps.calculate.outputs.version }}
build_number: ${{ steps.calculate.outputs.build_number }}
xcode_version: ${{ steps.calculate.outputs.xcode_version }}

version_name: ${{ steps.version_info.outputs.version_name }}
version_number: ${{ steps.version_info.outputs.version_number }}
xcode_version: ${{ env.XCODE_VERSION }}
distribute_to_testflight: ${{ env.DISTRIBUTE_TO_TESTFLIGHT }}
steps:
- name: Check out repo
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
with:
fetch-depth: 0
filter: tree:0

- name: Calculate build version and number
id: calculate
- name: Log inputs to job summary
run: |
if [[ ! -z "${{ inputs.build-version }}" ]]; then
echo -e "\nApplying build version override"
next_version=${{ inputs.build-version }}
else
echo -e "\nCalculating next version..."
current_year=$(date +%Y)
current_month=$(date +%-m)
echo "<details><summary>CI-main Workflow Inputs</summary>" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo '```json' >> $GITHUB_STEP_SUMMARY
echo '${{ toJson(inputs) }}' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "</details>" >> $GITHUB_STEP_SUMMARY

latest_tag_version=$(git tag --sort=committerdate --list | tail -1)
latest_version=${latest_tag_version:1} # remove 'v' from tag version

latest_major_version=$(echo $latest_version | cut -d "." -f 1)
latest_minor_version=$(echo $latest_version | cut -d "." -f 2)
latest_patch_version=$(echo $latest_version | cut -d "." -f 3)

echo " Current Year: $current_year"
echo " Current Month: $current_month"
echo " Latest Version: $latest_version"
echo " Latest Major Version: $latest_major_version"
echo " Latest Minor Version: $latest_minor_version"
echo " Latest Patch Version: $latest_patch_version"
- name: Calculate version
if: ${{ inputs.build-number == '' || inputs.build-version == '' }}
uses: bitwarden/ios/.github/actions/dispatch-and-download@main
id: dispatch-version
with:
token: ${{ secrets.GITHUB_TOKEN }}
repo: ios
owner: bitwarden
workflow: _version.yml
workflow_inputs: '{"base_version_number": "1000", "version_name": "${{ inputs.build-version }}", "version_number": "${{ inputs.build-number }}", "patch_version": "${{ inputs.patch_version }}"}'

if [[ "$current_year" == "$latest_major_version" && "$current_month" == "$latest_minor_version" ]]; then
next_version="${latest_major_version}.${latest_minor_version}.$(($latest_patch_version + 1))"
else
next_version="${current_year}.${current_month}.0"
fi
fi
- name: Read version info
id: version_info
run: |
# test if dispatch-version was skipped. In that case, creates the same .json file expected by the Upload artifact step
if [ ! -f version-info/version_info.json ]; then
echo "::warning::version-version.json not found, was the previous step skipped? Creating a new file"
json='{
"version_number": "${{ inputs.build-number }}",
"version_name": "${{ inputs.build-version }}"
}'

if [[ ! -z "${{ inputs.build-number }}" ]]; then
echo -e "\nApplying build number override"
next_number=${{ inputs.build-number }}
# file will be used by the upload step
mkdir version-info
echo "$json" > version-info/version_info.json
else
echo -e "\nCalculating build number..."
next_number=$(($GITHUB_RUN_NUMBER + 1000))
echo "::notice::version-version.json found!"
fi

echo -e "\n"
echo "**Version**: $next_version" | tee -a $GITHUB_STEP_SUMMARY
echo "**Build Number**: $next_number" | tee -a $GITHUB_STEP_SUMMARY
echo "version=$next_version" >> $GITHUB_OUTPUT
echo "build_number=$next_number" >> $GITHUB_OUTPUT
echo "xcode_version=$XCODE_VERSION" >> $GITHUB_OUTPUT
content=$(cat version-info/version_info.json)
echo "version_name=$(echo $content | jq -r .version_name)" >> $GITHUB_OUTPUT
echo "version_number=$(echo $content | jq -r .version_number)" >> $GITHUB_OUTPUT
- name: Upload version info artifact
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
with:
name: version-info
path: version-info/version_info.json

build:
name: Build
needs: resolve-values
uses: ./.github/workflows/build.yml
uses: bitwarden/ios/.github/workflows/build.yml@main
strategy:
matrix:
variant: [Beta, Production]
with:
build-variant: ${{ matrix.variant }}
build-version: ${{ needs.resolve-values.outputs.build_version }}
build-number: ${{ needs.resolve-values.outputs.build_number }}
build-version: ${{ needs.resolve-values.outputs.version_name }}
build-number: ${{ needs.resolve-values.outputs.version_number }}
xcode-version: ${{ needs.resolve-values.outputs.xcode_version }}
Copy link
Member Author

Choose a reason for hiding this comment

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

for some reason ${{ env.*** }} isn't available here, we can access a bunch of other contexts, just not env. Seems like an oversight. We'll need to keep routing these through another job for the time being.

distribute: ${{ fromJSON(needs.resolve-values.outputs.distribute_to_testflight) }}
Copy link
Member Author

Choose a reason for hiding this comment

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

๐Ÿ’ก outputs are always strings, fromJSON is converting it to a boolean

upload_version_info: false
secrets: inherit
13 changes: 13 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ on:
patch_version:
description: "Patch Version Override - e.g. '999'"
type: string
distribute:
description: "Distribute to TestFlight"
type: boolean
default: true
workflow_call:
inputs:
build-variant:
Expand All @@ -55,6 +59,12 @@ on:
patch_version:
description: "Patch Version Override - e.g. '999'"
type: string
distribute:
description: "Distribute to TestFlight"
type: boolean
upload_version_info:
description: "Upload version-info file - When false, caller may be handling it already"
type: boolean
env:
BUILD_VARIANT: ${{ inputs.build-variant || 'Beta' }}
XCODE_VERSION: ${{ inputs.xcode-version || '15.4' }}
Expand Down Expand Up @@ -84,6 +94,7 @@ jobs:
filter: tree:0

- name: Calculate version
if: ${{ inputs.build-number == '' || inputs.build-version == '' }}
uses: bitwarden/ios/.github/actions/dispatch-and-download@main
id: dispatch-version
with:
Expand Down Expand Up @@ -116,6 +127,7 @@ jobs:
echo "version_name=$(echo $content | jq -r .version_name)" >> $GITHUB_OUTPUT
echo "version_number=$(echo $content | jq -r .version_number)" >> $GITHUB_OUTPUT
- name: Upload version info artifact
if: ${{ inputs.upload_version_info }}
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
with:
name: version-info
Expand Down Expand Up @@ -349,6 +361,7 @@ jobs:
--apiIssuer "${{ secrets.APP_STORE_CONNECT_TEAM_ISSUER }}"

- name: Upload app to TestFlight with Fastlane
if: ${{ inputs.distribute }}
run: |
CHANGELOG="$(git show -s --format=%s)
$GITHUB_REPOSITORY/$GITHUB_REF_NAME @ $GITHUB_SHA
Expand Down
Loading