Update SDK version #127
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: "Update SDK version" | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| package: | |
| type: choice | |
| description: Package to release | |
| options: | |
| - passport | |
| - audience | |
| required: true | |
| default: passport | |
| upgrade_type: | |
| type: choice | |
| description: Upgrade Type | |
| options: | |
| - patch | |
| - minor | |
| required: true | |
| default: patch | |
| mark_as_alpha: | |
| type: boolean | |
| description: Mark as alpha release (Passport only) | |
| required: false | |
| default: false | |
| env: | |
| PACKAGE: ${{ github.event.inputs.package || 'passport' }} | |
| UPGRADE_TYPE: ${{ github.event.inputs.upgrade_type || 'patch' }} | |
| MARK_AS_ALPHA: ${{ github.event.inputs.mark_as_alpha || false }} | |
| jobs: | |
| update: | |
| runs-on: ubuntu-latest | |
| env: | |
| GH_TOKEN: ${{ secrets.UNITY_IMMUTABLE_SDK_GITHUB_TOKEN }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Check team membership | |
| id: check_team | |
| run: | | |
| ./.github/scripts/check_team_membership.sh "${{ github.actor }}" "${{ secrets.UNITY_IMMUTABLE_SDK_GITHUB_TOKEN }}" | |
| source "$GITHUB_ENV" | |
| echo "${{ github.actor }} is a member of the SDK team: $IS_MEMBER" | |
| if [[ "$IS_MEMBER" != "true" ]]; then | |
| echo "Not a member of the SDK team, skipping update" | |
| exit 1 | |
| fi | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.x' | |
| - name: Install jq | |
| run: sudo apt-get install -y jq | |
| - name: Update Version in package.json | |
| id: replace_version | |
| run: | | |
| if [[ "$PACKAGE" == "audience" ]]; then | |
| FILE=./src/Packages/Audience/package.json | |
| else | |
| FILE=./src/Packages/Passport/package.json | |
| fi | |
| CURRENT_VERSION=$(jq -r '.version' $FILE) | |
| echo "CURRENT_VERSION: $CURRENT_VERSION" | |
| IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION" | |
| NEW_VERSION="" | |
| if [[ "$PACKAGE" == "passport" ]]; then | |
| HAS_ALPHA=$(echo "$CURRENT_VERSION" | grep -q "\.alpha" && echo "true" || echo "false") | |
| echo "HAS_ALPHA: $HAS_ALPHA" | |
| if [[ "$HAS_ALPHA" == "true" ]]; then | |
| if [ "$UPGRADE_TYPE" == "patch" ]; then | |
| NEW_VERSION="$MAJOR.$MINOR.$PATCH" | |
| elif [ "$UPGRADE_TYPE" == "minor" ]; then | |
| MINOR=$((MINOR + 1)) | |
| PATCH=0 | |
| NEW_VERSION="$MAJOR.$MINOR.$PATCH" | |
| fi | |
| else | |
| if [ "$UPGRADE_TYPE" == "patch" ]; then | |
| PATCH=$((PATCH + 1)) | |
| elif [ "$UPGRADE_TYPE" == "minor" ]; then | |
| MINOR=$((MINOR + 1)) | |
| PATCH=0 | |
| fi | |
| NEW_VERSION="$MAJOR.$MINOR.$PATCH" | |
| fi | |
| if [[ "$MARK_AS_ALPHA" == "true" && "$HAS_ALPHA" == "false" ]]; then | |
| NEW_VERSION="$NEW_VERSION.alpha" | |
| fi | |
| else | |
| if [ "$UPGRADE_TYPE" == "patch" ]; then | |
| PATCH=$((PATCH + 1)) | |
| elif [ "$UPGRADE_TYPE" == "minor" ]; then | |
| MINOR=$((MINOR + 1)) | |
| PATCH=0 | |
| fi | |
| NEW_VERSION="$MAJOR.$MINOR.$PATCH" | |
| fi | |
| jq --arg version "$NEW_VERSION" '.version = $version' $FILE > tmp.$$.json && mv tmp.$$.json $FILE | |
| echo "Updated version in $FILE from $CURRENT_VERSION to $NEW_VERSION" | |
| echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT" | |
| - name: Update SDK Version in SdkVersionInfoHelpers.cs | |
| if: env.PACKAGE == 'passport' | |
| id: replace_engine_sdk_version | |
| run: | | |
| FILE=./src/Packages/Passport/Runtime/Scripts/Private/Helpers/SdkVersionInfoHelpers.cs | |
| NEW_VERSION="${{ steps.replace_version.outputs.version }}" | |
| sed -i -E "s/[0-9]+\.[0-9]+\.[0-9]+/$NEW_VERSION/g" $FILE | |
| echo "Updated SDK version in SdkVersionInfoHelpers.cs to $NEW_VERSION" | |
| - name: Ensure Samples~/SamplesScenesScripts directory exists and clear contents | |
| if: env.PACKAGE == 'passport' | |
| run: | | |
| mkdir -p ./src/Packages/Passport/Samples~/SamplesScenesScripts | |
| rm -rf ./src/Packages/Passport/Samples~/SamplesScenesScripts/* | |
| - name: Install rsync | |
| if: env.PACKAGE == 'passport' | |
| run: sudo apt-get install -y rsync | |
| - name: Copy sample scenes and scripts to Passport package Samples~ | |
| if: env.PACKAGE == 'passport' | |
| id: copy_sample_scenes_and_scripts | |
| run: | | |
| rsync -av --exclude='*.meta' ./examples/passport/Assets/Scenes/Passport ./src/Packages/Passport/Samples~/SamplesScenesScripts/Scenes/ | |
| rsync -av --exclude='*.meta' --exclude='features.json' --exclude='_prompts~/' --exclude='_tutorials~/' ./examples/passport/Assets/Scripts/Passport ./src/Packages/Passport/Samples~/SamplesScenesScripts/Scripts/ | |
| - name: Set release label | |
| id: set_label | |
| run: | | |
| if [[ "$PACKAGE" == "audience" ]]; then | |
| echo "label=audience-release" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "label=release" >> "$GITHUB_OUTPUT" | |
| fi | |
| - uses: gr2m/create-or-update-pull-request-action@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| title: "chore: bump ${{ github.event.inputs.package }} to ${{ steps.replace_version.outputs.version }}" | |
| body: "Bump ${{ github.event.inputs.package }} package version to ${{ steps.replace_version.outputs.version }}." | |
| branch: "chore/bump-${{ github.event.inputs.package }}-${{ steps.replace_version.outputs.version }}" | |
| commit-message: "chore: bump ${{ github.event.inputs.package }} to ${{ steps.replace_version.outputs.version }}" | |
| labels: ${{ steps.set_label.outputs.label }} |