|
12 | 12 | build-number:
|
13 | 13 | description: "Version Number Override - e.g. '1021'"
|
14 | 14 | type: number
|
15 |
| - |
| 15 | + patch_version: |
| 16 | + description: "Patch Version Override - e.g. '999'" |
| 17 | + type: string |
| 18 | + distribute: |
| 19 | + description: "Distribute to TestFlight" |
| 20 | + type: boolean |
16 | 21 | env:
|
17 | 22 | XCODE_VERSION: '15.4'
|
18 |
| - |
| 23 | + DISTRIBUTE_TO_TESTFLIGHT: ${{ github.event_name == 'push' || inputs.distribute }} |
19 | 24 | jobs:
|
20 | 25 | resolve-values:
|
21 | 26 | name: "Resolve values"
|
22 |
| - runs-on: macos-14 |
| 27 | + runs-on: ubuntu-latest |
23 | 28 | outputs:
|
24 |
| - build_variant: ${{ steps.calculate.outputs.variant }} |
25 |
| - build_version: ${{ steps.calculate.outputs.version }} |
26 |
| - build_number: ${{ steps.calculate.outputs.build_number }} |
27 |
| - xcode_version: ${{ steps.calculate.outputs.xcode_version }} |
28 |
| - |
| 29 | + version_name: ${{ steps.version_info.outputs.version_name }} |
| 30 | + version_number: ${{ steps.version_info.outputs.version_number }} |
| 31 | + xcode_version: ${{ env.XCODE_VERSION }} |
| 32 | + distribute_to_testflight: ${{ env.DISTRIBUTE_TO_TESTFLIGHT }} |
29 | 33 | steps:
|
30 |
| - - name: Check out repo |
31 |
| - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 |
32 |
| - with: |
33 |
| - fetch-depth: 0 |
34 |
| - filter: tree:0 |
35 |
| - |
36 |
| - - name: Calculate build version and number |
37 |
| - id: calculate |
| 34 | + - name: Log inputs to job summary |
38 | 35 | run: |
|
39 |
| - if [[ ! -z "${{ inputs.build-version }}" ]]; then |
40 |
| - echo -e "\nApplying build version override" |
41 |
| - next_version=${{ inputs.build-version }} |
42 |
| - else |
43 |
| - echo -e "\nCalculating next version..." |
44 |
| - current_year=$(date +%Y) |
45 |
| - current_month=$(date +%-m) |
| 36 | + echo "<details><summary>CI-main Workflow Inputs</summary>" >> $GITHUB_STEP_SUMMARY |
| 37 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 38 | + echo '```json' >> $GITHUB_STEP_SUMMARY |
| 39 | + echo '${{ toJson(inputs) }}' >> $GITHUB_STEP_SUMMARY |
| 40 | + echo '```' >> $GITHUB_STEP_SUMMARY |
| 41 | + echo "</details>" >> $GITHUB_STEP_SUMMARY |
46 | 42 |
|
47 |
| - latest_tag_version=$(git tag --sort=committerdate --list | tail -1) |
48 |
| - latest_version=${latest_tag_version:1} # remove 'v' from tag version |
49 |
| -
|
50 |
| - latest_major_version=$(echo $latest_version | cut -d "." -f 1) |
51 |
| - latest_minor_version=$(echo $latest_version | cut -d "." -f 2) |
52 |
| - latest_patch_version=$(echo $latest_version | cut -d "." -f 3) |
53 |
| -
|
54 |
| - echo " Current Year: $current_year" |
55 |
| - echo " Current Month: $current_month" |
56 |
| - echo " Latest Version: $latest_version" |
57 |
| - echo " Latest Major Version: $latest_major_version" |
58 |
| - echo " Latest Minor Version: $latest_minor_version" |
59 |
| - echo " Latest Patch Version: $latest_patch_version" |
| 43 | + - name: Calculate version |
| 44 | + if: ${{ inputs.build-number == '' || inputs.build-version == '' }} |
| 45 | + uses: bitwarden/ios/.github/actions/dispatch-and-download@main |
| 46 | + id: dispatch-version |
| 47 | + with: |
| 48 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 49 | + repo: ios |
| 50 | + owner: bitwarden |
| 51 | + workflow: _version.yml |
| 52 | + workflow_inputs: '{"base_version_number": "1000", "version_name": "${{ inputs.build-version }}", "version_number": "${{ inputs.build-number }}", "patch_version": "${{ inputs.patch_version }}"}' |
60 | 53 |
|
61 |
| - if [[ "$current_year" == "$latest_major_version" && "$current_month" == "$latest_minor_version" ]]; then |
62 |
| - next_version="${latest_major_version}.${latest_minor_version}.$(($latest_patch_version + 1))" |
63 |
| - else |
64 |
| - next_version="${current_year}.${current_month}.0" |
65 |
| - fi |
66 |
| - fi |
| 54 | + - name: Read version info |
| 55 | + id: version_info |
| 56 | + run: | |
| 57 | + # test if dispatch-version was skipped. In that case, creates the same .json file expected by the Upload artifact step |
| 58 | + if [ ! -f version-info/version_info.json ]; then |
| 59 | + echo "::warning::version-version.json not found, was the previous step skipped? Creating a new file" |
| 60 | + json='{ |
| 61 | + "version_number": "${{ inputs.build-number }}", |
| 62 | + "version_name": "${{ inputs.build-version }}" |
| 63 | + }' |
67 | 64 |
|
68 |
| - if [[ ! -z "${{ inputs.build-number }}" ]]; then |
69 |
| - echo -e "\nApplying build number override" |
70 |
| - next_number=${{ inputs.build-number }} |
| 65 | + # file will be used by the upload step |
| 66 | + mkdir version-info |
| 67 | + echo "$json" > version-info/version_info.json |
71 | 68 | else
|
72 |
| - echo -e "\nCalculating build number..." |
73 |
| - next_number=$(($GITHUB_RUN_NUMBER + 1000)) |
| 69 | + echo "::notice::version-version.json found!" |
74 | 70 | fi
|
75 | 71 |
|
76 |
| - echo -e "\n" |
77 |
| - echo "**Version**: $next_version" | tee -a $GITHUB_STEP_SUMMARY |
78 |
| - echo "**Build Number**: $next_number" | tee -a $GITHUB_STEP_SUMMARY |
79 |
| - echo "version=$next_version" >> $GITHUB_OUTPUT |
80 |
| - echo "build_number=$next_number" >> $GITHUB_OUTPUT |
81 |
| - echo "xcode_version=$XCODE_VERSION" >> $GITHUB_OUTPUT |
| 72 | + content=$(cat version-info/version_info.json) |
| 73 | + echo "version_name=$(echo $content | jq -r .version_name)" >> $GITHUB_OUTPUT |
| 74 | + echo "version_number=$(echo $content | jq -r .version_number)" >> $GITHUB_OUTPUT |
| 75 | + - name: Upload version info artifact |
| 76 | + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 |
| 77 | + with: |
| 78 | + name: version-info |
| 79 | + path: version-info/version_info.json |
82 | 80 |
|
83 | 81 | build:
|
84 | 82 | name: Build
|
85 | 83 | needs: resolve-values
|
86 |
| - uses: ./.github/workflows/build.yml |
| 84 | + uses: bitwarden/ios/.github/workflows/build.yml@main |
87 | 85 | strategy:
|
88 | 86 | matrix:
|
89 | 87 | variant: [Beta, Production]
|
90 | 88 | with:
|
91 | 89 | build-variant: ${{ matrix.variant }}
|
92 |
| - build-version: ${{ needs.resolve-values.outputs.build_version }} |
93 |
| - build-number: ${{ needs.resolve-values.outputs.build_number }} |
| 90 | + build-version: ${{ needs.resolve-values.outputs.version_name }} |
| 91 | + build-number: ${{ needs.resolve-values.outputs.version_number }} |
94 | 92 | xcode-version: ${{ needs.resolve-values.outputs.xcode_version }}
|
| 93 | + distribute: ${{ fromJSON(needs.resolve-values.outputs.distribute_to_testflight) }} |
| 94 | + upload_version_info: false |
95 | 95 | secrets: inherit
|
0 commit comments