|
| 1 | +name: 01 - create release branch |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + release-type: |
| 7 | + description: "release type" |
| 8 | + required: true |
| 9 | + default: "patch" |
| 10 | + type: choice |
| 11 | + options: |
| 12 | + - patch |
| 13 | + - minor |
| 14 | + - major |
| 15 | + |
| 16 | +jobs: |
| 17 | + bump-version: |
| 18 | + name: Bump version and create PR |
| 19 | + runs-on: ubuntu-latest |
| 20 | + outputs: |
| 21 | + new_version: ${{ steps.bump_versions.outputs.NEW_VERSION }} |
| 22 | + versions_match: ${{ steps.bump_versions.outputs.VERSIONS_MATCH }} |
| 23 | + pr_number: ${{ steps.create-pr.outputs.pull-request-number }} |
| 24 | + |
| 25 | + steps: |
| 26 | + - name: Checkout repository |
| 27 | + uses: actions/checkout@v4 |
| 28 | + with: |
| 29 | + ref: ${{ github.ref }} |
| 30 | + |
| 31 | + - name: Install pnpm |
| 32 | + uses: pnpm/action-setup@v4 |
| 33 | + with: |
| 34 | + version: 10 |
| 35 | + |
| 36 | + - name: Set up Node.js |
| 37 | + uses: actions/setup-node@v4 |
| 38 | + with: |
| 39 | + node-version: 20 |
| 40 | + |
| 41 | + - name: Set up Python |
| 42 | + uses: actions/setup-python@v5 |
| 43 | + with: |
| 44 | + python-version: 3.11 |
| 45 | + |
| 46 | + - name: Install Poetry |
| 47 | + run: | |
| 48 | + curl -sSL https://install.python-poetry.org | python3 - |
| 49 | +
|
| 50 | + - name: Bump versions and compare |
| 51 | + id: bump_versions |
| 52 | + run: | |
| 53 | + BUMP_TYPE=${{ inputs.bump-type }} |
| 54 | + echo "Bumping versions to $BUMP_TYPE" |
| 55 | +
|
| 56 | + npm install semver -g |
| 57 | +
|
| 58 | + cd web |
| 59 | + pnpm version $BUMP_TYPE |
| 60 | + WEB_VERSION=$(pnpm pkg get version | tr -d '"') |
| 61 | + |
| 62 | + cd ee |
| 63 | + current_version=$(pnpm pkg get version | awk -F': ' '/[0-9]+\.[0-9]+\.[0-9]+/ {print $2}' | tr -d '"') |
| 64 | + new_version=$(npx semver "$current_version" -i $BUMP_TYPE) |
| 65 | + pnpm pkg set version="$new_version" |
| 66 | + EE_VERSION=$new_version |
| 67 | + cd .. |
| 68 | + |
| 69 | + cd oss/ |
| 70 | + current_version=$(pnpm pkg get version | awk -F': ' '/[0-9]+\.[0-9]+\.[0-9]+/ {print $2}' | tr -d '"') |
| 71 | + new_version=$(npx semver "$current_version" -i $BUMP_TYPE) |
| 72 | + pnpm pkg set version="$new_version" |
| 73 | + OSS_VERSION=$new_version |
| 74 | + cd ../.. |
| 75 | +
|
| 76 | + cd sdk |
| 77 | + poetry version $BUMP_TYPE |
| 78 | + SDK_VERSION=$(poetry version -s) |
| 79 | + cd .. |
| 80 | +
|
| 81 | + cd api |
| 82 | + poetry version $BUMP_TYPE |
| 83 | + API_VERSION=$(poetry version -s) |
| 84 | + cd .. |
| 85 | +
|
| 86 | + WEB_VERSION=$(echo "$WEB_VERSION" | tr -d '[:space:]') |
| 87 | + EE_VERSION=$(echo "$EE_VERSION" | tr -d '[:space:]') |
| 88 | + OSS_VERSION=$(echo "$OSS_VERSION" | tr -d '[:space:]') |
| 89 | + SDK_VERSION=$(echo "$SDK_VERSION" | tr -d '[:space:]') |
| 90 | + API_VERSION=$(echo "$API_VERSION" | tr -d '[:space:]') |
| 91 | +
|
| 92 | + echo "WEB_VERSION='$WEB_VERSION'" |
| 93 | + echo "EE_VERSION='$EE_VERSION'" |
| 94 | + echo "OSS_VERSION='$OSS_VERSION'" |
| 95 | + echo "SDK_VERSION='$SDK_VERSION'" |
| 96 | + echo "API_VERSION='$API_VERSION'" |
| 97 | +
|
| 98 | + if [ "$EE_VERSION" = "$OSS_VERSION" ] && [ "$OSS_VERSION" = "$WEB_VERSION" ] && [ "$WEB_VERSION" = "$SDK_VERSION" ] && [ "$SDK_VERSION" = "$API_VERSION" ]; then |
| 99 | + echo "VERSIONS_MATCH=true" >> $GITHUB_OUTPUT |
| 100 | + echo "NEW_VERSION=$WEB_VERSION" >> $GITHUB_OUTPUT |
| 101 | + else |
| 102 | + echo "VERSIONS_MATCH=false" >> $GITHUB_OUTPUT |
| 103 | + fi |
| 104 | +
|
| 105 | + - name: Create Pull Request |
| 106 | + if: steps.bump_versions.outputs.VERSIONS_MATCH == 'true' |
| 107 | + uses: peter-evans/create-pull-request@v6 |
| 108 | + with: |
| 109 | + commit-message: v${{ steps.bump_versions.outputs.NEW_VERSION }} |
| 110 | + author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com> |
| 111 | + branch: release/v${{ steps.bump_versions.outputs.NEW_VERSION }} |
| 112 | + delete-branch: true |
| 113 | + title: "v${{ steps.bump_versions.outputs.NEW_VERSION }}" |
| 114 | + body: | |
| 115 | + New version v${{ steps.bump_versions.outputs.NEW_VERSION }} in |
| 116 | + - (web) |
| 117 | + - web/oss |
| 118 | + - web/ee |
| 119 | + - sdk |
| 120 | + - api |
| 121 | +
|
| 122 | + - name: Fail if versions don't match |
| 123 | + if: steps.bump_versions.outputs.VERSIONS_MATCH != 'true' |
| 124 | + run: | |
| 125 | + echo "Versions in the three folders do not match. Please check and update manually." |
| 126 | + exit 1 |
| 127 | +
|
| 128 | + create-tag: |
| 129 | + needs: bump-version |
| 130 | + runs-on: ubuntu-latest |
| 131 | + |
| 132 | + steps: |
| 133 | + - name: Checkout repository |
| 134 | + uses: actions/checkout@v4 |
| 135 | + |
| 136 | + - name: Create and push tag |
| 137 | + run: | |
| 138 | + git config --global user.name "${{ github.actor }}" |
| 139 | + git config --global user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com" |
| 140 | + git tag -a "v${{ needs.bump-version.outputs.new_version }}" -m "Version ${{ needs.bump-version.outputs.new_version }}" |
| 141 | + git push origin "v${{ needs.bump-version.outputs.new_version }}" |
0 commit comments