Skip to content

Commit

Permalink
Merge branch 'bitwarden:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
artpoli authored Oct 22, 2024
2 parents cd3826a + 8bcb21f commit d4dc46f
Show file tree
Hide file tree
Showing 1,660 changed files with 22,052 additions and 5,737 deletions.
6 changes: 3 additions & 3 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners

# Default file owners.
# * @bitwarden/tech-leads
* @bitwarden/team-ios @matt-livefront @phil-livefront @victor-livefront @brant-livefront

# DevOps for Actions and other workflow changes.
# .github/workflows @bitwarden/dept-devops
# Actions and workflow changes.
.github/ @bitwarden/dept-development-mobile

# Auth
# BitwardenShared/Core/Auth @bitwarden/team-auth-dev
Expand Down
97 changes: 97 additions & 0 deletions .github/actions/dispatch-and-download/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Dispatch Workflow and Download Artifacts
description: 'Dispatches a workflow, waits for completion, and downloads artifacts'
inputs:
token:
description: GitHub Personal Access Token for making API requests.
required: true
workflow:
description: The workflow to dispatch, can be a filename or ID
required: true
ref:
description: The branch or tag to dispatch the workflow on
default: 'main'
repo:
description: Repository of the action to dispatch.
default: ${{ github.repository }}
owner:
description: Owner of the given repository.
default: ${{ github.repository_owner }}
workflow_timeout_seconds:
description: Time until giving up waiting for the start of the workflow run.
default: 120
workflow_inputs:
description: A flat JSON object, only supports strings, numbers, and booleans (as per workflow inputs API).
distinct_id:
description: Specify a static string to use instead of a random distinct ID.
runs:
using: "composite"
steps:
- name: Log inputs to job summary
shell: bash
run: |
echo "<details><summary>Dispatch and Download Action 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
- name: Dispatch an action and get the run ID and URL
uses: codex-/return-dispatch@06d9405c91c1696f12c0bf915ab9c5161c8f06fc # v2.0.1
id: return_dispatch
with:
token: ${{ inputs.token }}
ref: ${{ inputs.ref }}
repo: ${{ inputs.repo }}
owner: ${{ inputs.owner }}
workflow: ${{ inputs.workflow }}
workflow_timeout_seconds: ${{ inputs.workflow_timeout_seconds }}
workflow_inputs: ${{ inputs.workflow_inputs }}
distinct_id: ${{ inputs.distinct_id }}

- name: Use the output run ID and URL
shell: bash
run: |
echo ${{steps.return_dispatch.outputs.run_id}}
echo ${{steps.return_dispatch.outputs.run_url}}
- name: Wait for workflow to finish
shell: bash
run: |
sleep 5
timeout="30" # in seconds
interval="10" # in seconds
counter=0
timeout_counter=0
url="https://api.github.com/repos/${{ inputs.owner }}/${{ inputs.repo }}/actions/runs/${{steps.return_dispatch.outputs.run_id}}"
while true; do
run_data=$(curl -s -H "Accept: application/vnd.github+json" -H "Authorization: token ${{ inputs.token }}" $url)
status=$(echo "$run_data" | jq -r '.status')
echo "Try -> $timeout_counter; status -> $status"
if [ "$status" = "completed" ]; then
conclusion=$(echo "$run_data" | jq -r '.conclusion')
if [ "$conclusion" != "success" ]; then
echo "::error::Dispatched workflow failed."
exit 1
else
echo "::debug::Dispatched workflow completed successfully!"
break
fi
fi
timeout_counter=$((timeout_counter + 1))
if [ $((timeout_counter * interval)) -ge $((timeout * 60)) ]; then
echo "::error::Timeout waiting for the Dispatched workflow to complete."
exit 1
fi
sleep $interval
done
- name: Download all artifacts
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
id: download
with:
run-id: ${{steps.return_dispatch.outputs.run_id}}
github-token: ${{ inputs.token }}
144 changes: 83 additions & 61 deletions .github/workflows/CI-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,91 +7,113 @@ on:
workflow_dispatch:
inputs:
build-version:
description: "Optional. Version string to use, in X.Y.Z format. Overrides default in the project."
required: false
description: "Version Name Override - e.g. '2024.8.1'"
type: string
build-number:
description: "Optional. Build number to use. Overrides default of GitHub run number."
required: false
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 }}
INTERNAL_BETA_PATCH_NUMBER: 999

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 }}
internal_beta_version_name: ${{ steps.internal_versions.outputs.internal_beta_version_name}}
steps:
- name: Check out repo
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
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)
latest_tag_version=$(git tag --sort=committerdate --list | tail -1)
latest_version=${latest_tag_version:1} # remove 'v' from tag version
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_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": "1500", "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@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: version-info
path: version-info/version_info.json
- name: Set patch version for internal builds
id: internal_versions
run: |
version_name=${{ steps.version_info.outputs.version_name }}
internal_beta_version_name="${version_name%.*}.${{ env.INTERNAL_BETA_PATCH_NUMBER }}"
echo "internal_beta_version_name=$internal_beta_version_name" >> $GITHUB_OUTPUT
echo "::warning::Internal version name: $internal_beta_version_name"
build:
name: Build
build-public:
name: Build Public Apps
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 }}
distribute: ${{ fromJSON(needs.resolve-values.outputs.distribute_to_testflight) }}
upload_version_info: false
secrets: inherit

build-internal:
name: Build Internal App
needs: resolve-values
uses: bitwarden/ios/.github/workflows/build.yml@main
with:
build-variant: Beta
build-version: ${{ needs.resolve-values.outputs.internal_beta_version_name }}
build-number: ${{ needs.resolve-values.outputs.version_number }}
xcode-version: ${{ needs.resolve-values.outputs.xcode_version }}
distribute: ${{ fromJSON(needs.resolve-values.outputs.distribute_to_testflight) }}
upload_version_info: false
compiler-flags: "DEBUG_MENU"
secrets: inherit
Loading

0 comments on commit d4dc46f

Please sign in to comment.