mirror of
https://github.com/bitwarden/android.git
synced 2025-12-10 00:06:22 -06:00
[PM-22157] independent version names in build workflows (#6074)
This commit is contained in:
parent
e3b111c383
commit
064a98f86b
159
.github/workflows/_version.yml
vendored
Normal file
159
.github/workflows/_version.yml
vendored
Normal file
@ -0,0 +1,159 @@
|
||||
name: Calculate Version Name and Number
|
||||
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
app_codename:
|
||||
description: "App Name - e.g. 'bwpm' or 'bwa'"
|
||||
base_version_number:
|
||||
description: "Base Version Number - Will be added to the calculated version number"
|
||||
type: number
|
||||
default: 0
|
||||
version_name:
|
||||
description: "Version Name Override - e.g. '2024.8.1'"
|
||||
version_number:
|
||||
description: "Version Number Override - e.g. '1021'"
|
||||
patch_version:
|
||||
description: "Patch Version Override - e.g. '999'"
|
||||
distinct_id:
|
||||
description: "Unique ID for this dispatch, used by dispatch-and-download.yml"
|
||||
skip_checkout:
|
||||
description: "Skip checking out the repository"
|
||||
type: boolean
|
||||
workflow_call:
|
||||
inputs:
|
||||
app_codename:
|
||||
description: "App Name - e.g. 'bwpm' or 'bwa'"
|
||||
type: string
|
||||
base_version_number:
|
||||
description: "Base Version Number - Will be added to the calculated version number"
|
||||
type: number
|
||||
default: 0
|
||||
version_name:
|
||||
description: "Version Name Override - e.g. '2024.8.1'"
|
||||
type: string
|
||||
version_number:
|
||||
description: "Version Number Override - e.g. '1021'"
|
||||
type: string
|
||||
patch_version:
|
||||
description: "Patch Version Override - e.g. '999'"
|
||||
type: string
|
||||
distinct_id:
|
||||
description: "Unique ID for this dispatch, used by dispatch-and-download.yml"
|
||||
type: string
|
||||
skip_checkout:
|
||||
description: "Skip checking out the repository"
|
||||
type: boolean
|
||||
outputs:
|
||||
version_name:
|
||||
description: "Version Name"
|
||||
value: ${{ jobs.calculate-version.outputs.version_name }}
|
||||
version_number:
|
||||
description: "Version Number"
|
||||
value: ${{ jobs.calculate-version.outputs.version_number }}
|
||||
|
||||
env:
|
||||
APP_CODENAME: ${{ inputs.app_codename }}
|
||||
BASE_VERSION_NUMBER: ${{ inputs.base_version_number || 0 }}
|
||||
|
||||
jobs:
|
||||
calculate-version:
|
||||
name: Calculate Version Name and Number
|
||||
runs-on: ubuntu-22.04
|
||||
permissions:
|
||||
contents: read
|
||||
outputs:
|
||||
version_name: ${{ steps.calc-version-name.outputs.version_name }}
|
||||
version_number: ${{ steps.calc-version-number.outputs.version_number }}
|
||||
steps:
|
||||
- name: Log inputs to job summary
|
||||
uses: bitwarden/android/.github/actions/log-inputs@main
|
||||
with:
|
||||
inputs: "${{ toJson(inputs) }}"
|
||||
|
||||
- name: Echo distinct ID ${{ github.event.inputs.distinct_id }}
|
||||
run: echo ${{ github.event.inputs.distinct_id }}
|
||||
|
||||
- name: Check out repository
|
||||
if: ${{ !inputs.skip_checkout || false }}
|
||||
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Calculate version name
|
||||
id: calc-version-name
|
||||
run: |
|
||||
output() {
|
||||
local version_name=$1
|
||||
echo "version_name=$version_name" >> $GITHUB_OUTPUT
|
||||
}
|
||||
|
||||
# override version name if provided
|
||||
if [[ ! -z "${{ inputs.version_name }}" ]]; then
|
||||
version_name=${{ inputs.version_name }}
|
||||
echo "::warning::Override applied: $version_name"
|
||||
output "$version_name"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
current_year=$(date +%Y)
|
||||
current_month=$(date +%-m)
|
||||
|
||||
latest_tag_version=$(git tag -l --sort=-creatordate | grep "$APP_CODENAME" | head -n 1)
|
||||
if [[ -z "$latest_tag_version" ]]; then
|
||||
version_name="${current_year}.${current_month}.${{ inputs.patch_version || 0 }}"
|
||||
echo "::warning::No tags found, did you checkout? Calculating version from current date: $version_name"
|
||||
output "$version_name"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Git tag was found, calculate version from latest tag
|
||||
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)
|
||||
patch_version=0
|
||||
if [[ ! -z "${{ inputs.patch_version }}" ]]; then
|
||||
patch_version=${{ inputs.patch_version }}
|
||||
echo "::warning::Patch Version Override applied: $patch_version"
|
||||
elif [[ "$current_year" == "$latest_major_version" && "$current_month" == "$latest_minor_version" ]]; then
|
||||
latest_patch_version=$(echo $latest_version | cut -d "." -f 3)
|
||||
patch_version=$(($latest_patch_version + 1))
|
||||
fi
|
||||
|
||||
version_name="${current_year}.${current_month}.${patch_version}"
|
||||
output "$version_name"
|
||||
|
||||
- name: Calculate version number
|
||||
id: calc-version-number
|
||||
run: |
|
||||
# override version number if provided
|
||||
if [[ ! -z "${{ inputs.version_number }}" ]]; then
|
||||
version_number=${{ inputs.version_number }}
|
||||
echo "::warning::Override applied: $version_number"
|
||||
echo "version_number=$version_number" >> $GITHUB_OUTPUT
|
||||
exit 0
|
||||
fi
|
||||
|
||||
version_number=$(($GITHUB_RUN_NUMBER + ${{ env.BASE_VERSION_NUMBER }}))
|
||||
echo "version_number=$version_number" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Create version info JSON
|
||||
run: |
|
||||
json='{
|
||||
"version_number": "${{ steps.calc-version-number.outputs.version_number }}",
|
||||
"version_name": "${{ steps.calc-version-name.outputs.version_name }}"
|
||||
}'
|
||||
echo "$json" > version_info.json
|
||||
|
||||
echo "## version-info.json" >> $GITHUB_STEP_SUMMARY
|
||||
echo '```json' >> $GITHUB_STEP_SUMMARY
|
||||
echo "$json" >> $GITHUB_STEP_SUMMARY
|
||||
echo '```' >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
- name: Upload version info artifact
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: version-info
|
||||
path: version_info.json
|
||||
19
.github/workflows/build-authenticator.yml
vendored
19
.github/workflows/build-authenticator.yml
vendored
@ -15,6 +15,9 @@ on:
|
||||
description: "Optional. Build number to use. Overrides default of GitHub run number."
|
||||
required: false
|
||||
type: number
|
||||
patch_version:
|
||||
description: "Order 999 - Overrides Patch version"
|
||||
type: boolean
|
||||
distribute-to-firebase:
|
||||
description: "Optional. Distribute artifacts to Firebase."
|
||||
required: false
|
||||
@ -36,6 +39,17 @@ permissions:
|
||||
id-token: write
|
||||
|
||||
jobs:
|
||||
version:
|
||||
name: Calculate Version Name and Number
|
||||
uses: bitwarden/android/.github/workflows/_version.yml@main
|
||||
with:
|
||||
app_codename: "bwa"
|
||||
base_version_number: 0
|
||||
version_name: ${{ inputs.version-name }}
|
||||
version_number: ${{ inputs.version-code }}
|
||||
patch_version: ${{ inputs.patch_version && '999' || '' }}
|
||||
secrets: inherit
|
||||
|
||||
build:
|
||||
name: Build Authenticator
|
||||
runs-on: ubuntu-24.04
|
||||
@ -107,6 +121,7 @@ jobs:
|
||||
publish_playstore:
|
||||
name: Publish Authenticator Play Store artifacts
|
||||
needs:
|
||||
- version
|
||||
- build
|
||||
runs-on: ubuntu-24.04
|
||||
strategy:
|
||||
@ -236,8 +251,8 @@ jobs:
|
||||
- name: Increment version
|
||||
env:
|
||||
DEFAULT_VERSION_CODE: ${{ github.run_number }}
|
||||
INPUT_VERSION_CODE: "${{ inputs.version-code }}"
|
||||
INPUT_VERSION_NAME: ${{ inputs.version-name }}
|
||||
INPUT_VERSION_CODE: "${{ needs.version.outputs.version_number }}"
|
||||
INPUT_VERSION_NAME: ${{ needs.version.outputs.version_name }}
|
||||
run: |
|
||||
VERSION_CODE="${INPUT_VERSION_CODE:-$DEFAULT_VERSION_CODE}"
|
||||
VERSION_NAME_INPUT="${INPUT_VERSION_NAME:-}"
|
||||
|
||||
30
.github/workflows/build.yml
vendored
30
.github/workflows/build.yml
vendored
@ -15,6 +15,9 @@ on:
|
||||
description: "Optional. Build number to use. Overrides default of GitHub run number."
|
||||
required: false
|
||||
type: number
|
||||
patch_version:
|
||||
description: "Order 999 - Overrides Patch version"
|
||||
type: boolean
|
||||
distribute-to-firebase:
|
||||
description: "Optional. Distribute artifacts to Firebase."
|
||||
required: false
|
||||
@ -37,6 +40,18 @@ permissions:
|
||||
id-token: write
|
||||
|
||||
jobs:
|
||||
version:
|
||||
name: Calculate Version Name and Number
|
||||
uses: bitwarden/android/.github/workflows/_version.yml@main
|
||||
with:
|
||||
app_codename: "bwpm"
|
||||
# Start from 11000 to prevent collisions with mobile build version codes
|
||||
base_version_number: 11000
|
||||
version_name: ${{ inputs.version-name }}
|
||||
version_number: ${{ inputs.version-code }}
|
||||
patch_version: ${{ inputs.patch_version && '999' || '' }}
|
||||
secrets: inherit
|
||||
|
||||
build:
|
||||
name: Build
|
||||
runs-on: ubuntu-24.04
|
||||
@ -115,6 +130,7 @@ jobs:
|
||||
publish_playstore:
|
||||
name: Publish Play Store artifacts
|
||||
needs:
|
||||
- version
|
||||
- build
|
||||
runs-on: ubuntu-24.04
|
||||
strategy:
|
||||
@ -230,10 +246,10 @@ jobs:
|
||||
|
||||
- name: Increment version
|
||||
env:
|
||||
VERSION_CODE: ${{ inputs.version-code }}
|
||||
VERSION_NAME: ${{ inputs.version-name }}
|
||||
VERSION_CODE: ${{ needs.version.outputs.version_number }}
|
||||
VERSION_NAME: ${{ needs.version.outputs.version_name }}
|
||||
run: |
|
||||
VERSION_CODE="${VERSION_CODE:-$((11000 + GITHUB_RUN_NUMBER))}"
|
||||
VERSION_CODE="${VERSION_CODE:-$GITHUB_RUN_NUMBER}"
|
||||
bundle exec fastlane setBuildVersionInfo \
|
||||
versionCode:$VERSION_CODE \
|
||||
versionName:$VERSION_NAME
|
||||
@ -436,6 +452,7 @@ jobs:
|
||||
publish_fdroid:
|
||||
name: Publish F-Droid artifacts
|
||||
needs:
|
||||
- version
|
||||
- build
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
@ -530,13 +547,12 @@ jobs:
|
||||
"$GITHUB_RUN_ID" \
|
||||
"$GITHUB_RUN_ATTEMPT"
|
||||
|
||||
# Start from 11000 to prevent collisions with mobile build version codes
|
||||
- name: Increment version
|
||||
env:
|
||||
VERSION_CODE: ${{ inputs.version-code }}
|
||||
VERSION_NAME: ${{ inputs.version-name }}
|
||||
VERSION_CODE: ${{ needs.version.outputs.version_number }}
|
||||
VERSION_NAME: ${{ needs.version.outputs.version_name }}
|
||||
run: |
|
||||
VERSION_CODE="${VERSION_CODE:-$((11000 + GITHUB_RUN_NUMBER))}"
|
||||
VERSION_CODE="${VERSION_CODE:-$GITHUB_RUN_NUMBER}"
|
||||
bundle exec fastlane setBuildVersionInfo \
|
||||
versionCode:$VERSION_CODE \
|
||||
versionName:$VERSION_NAME
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user