Update SDK version #65
This file contains 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: | |
upgrade_type: | |
type: choice | |
description: Upgrade Type | |
options: | |
- patch | |
- minor | |
# - major | |
required: true | |
default: patch | |
env: | |
UPGRADE_TYPE: ${{ github.event.inputs.upgrade_type || 'patch' }} | |
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 }}" | |
# shellcheck disable=SC1090 | |
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: | | |
PASSPORT_FILE=./src/Packages/Passport/package.json | |
MARKETPLACE_FILE=./src/Packages/Marketplace/package.json | |
CURRENT_VERSION=$(jq -r '.version' $PASSPORT_FILE) | |
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION" | |
# Increment version based on UPGRADE_TYPE | |
case "$UPGRADE_TYPE" in | |
major) | |
MAJOR=$((MAJOR + 1)) | |
MINOR=0 | |
PATCH=0 | |
;; | |
minor) | |
MINOR=$((MINOR + 1)) | |
PATCH=0 | |
;; | |
patch) | |
PATCH=$((PATCH + 1)) | |
;; | |
*) | |
echo "Invalid upgrade type: $UPGRADE_TYPE" | |
exit 1 | |
;; | |
esac | |
NEW_VERSION="$MAJOR.$MINOR.$PATCH" | |
# Update Passport package.json | |
jq --arg version "$NEW_VERSION" '.version = $version' $PASSPORT_FILE > tmp.$$.json && mv tmp.$$.json $PASSPORT_FILE | |
echo "Updated version in Passport package.json from $CURRENT_VERSION to $NEW_VERSION" | |
# Update Marketplace package.json | |
jq --arg version "$NEW_VERSION" '.version = $version' $MARKETPLACE_FILE > tmp.$$.json && mv tmp.$$.json $MARKETPLACE_FILE | |
echo "Updated version in Marketplace package.json from $CURRENT_VERSION to $NEW_VERSION" | |
echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT" | |
- name: Update SDK Version in SdkVersionInfoHelpers.cs | |
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 Passport Samples~ directory exists and clear contents | |
run: | | |
mkdir -p /src/Packages/Passport/Samples~ | |
rm -rf /src/Packages/Passport/Samples~/* | |
- name: Install rsync | |
run: sudo apt-get install -y rsync | |
- name: Copy sample scenes and scripts to Passport package Samples~ | |
id: copy_sample_scenes_and_scripts | |
run: | | |
rsync -av --exclude='*.meta' ./sample/Assets/Scenes/ /src/Packages/Passport/Samples~/Scenes/ | |
rsync -av --exclude='*.meta' ./sample/Assets/Scripts/ /src/Packages/Passport/Samples~/Scripts/ | |
- uses: gr2m/create-or-update-pull-request-action@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
title: "chore: update version" | |
body: "Update version in package.json" | |
branch: "chore/update-version-${{ steps.replace_version.outputs.version }}" | |
commit-message: "chore: update version" | |
labels: release |