-
Notifications
You must be signed in to change notification settings - Fork 81
[PM-10877] Use new version calculation in CI-main workflow #970
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d57f23d
0eebb3f
c6c2288
b2eee33
8969895
c6cc731
578dd8e
3ac6e45
d9fabb5
cea06bb
72b302d
c00992d
31620ef
08b996e
f93c2b6
3a13fe7
e5f6406
a4a3a0e
f8da9db
ea4191d
d94ea1f
1e18762
ba3622e
d3e79bb
ccb4b8c
dd8513b
073411c
5eea7a1
f18cd1a
55ebfef
ef4ba26
ca07309
bf760bc
7198cca
9e80635
05bb447
0988a2b
cbd5b80
219de30
9aebadb
dcb9afa
504caee
1f5be84
abba86e
1fa0328
f94de31
cee6f4a
c178d2f
a48819d
900a769
808b6b8
b67c219
6f8e1a9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 }} | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for some reason |
||
| distribute: ${{ fromJSON(needs.resolve-values.outputs.distribute_to_testflight) }} | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ๐ก outputs are always strings, |
||
| upload_version_info: false | ||
| secrets: inherit | ||
Uh oh!
There was an error while loading. Please reload this page.