diff --git a/.github/workflows/create-version.yml b/.github/workflows/create-version.yml new file mode 100644 index 0000000..1e3caec --- /dev/null +++ b/.github/workflows/create-version.yml @@ -0,0 +1,176 @@ +name: Create Version + +on: + push: + branches: [ ] + pull_request: + branches: [ ] + + workflow_dispatch: + inputs: + versionIncrementType: + description: 'Version Increment Type' + required: true + default: 'patch' + type: choice + options: + - patch + - minor + - major + - manual + manualVersionNumber: + description: 'Manually Enter Version Number (Requires manual Version Increment Type)' + required: false + type: string + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + + version_increment_is_bump: + name: Check If Version Increment Is Bump + runs-on: ubuntu-latest + if: github.event_name == 'workflow_dispatch' + outputs: + isBump: ${{ steps.check_if_increment_is_bump.outputs.value }} + steps: + - name: Check If Version Increment Is Bump + id: check_if_increment_is_bump + run: | + if [ ${{ inputs.versionIncrementType }} == 'patch' ]; then + echo "value=true" >> "$GITHUB_OUTPUT" + elif [ ${{ inputs.versionIncrementType }} == 'minor' ]; then + echo "value=true" >> "$GITHUB_OUTPUT" + elif [ ${{ inputs.versionIncrementType }} == 'major' ]; then + echo "value=true" >> "$GITHUB_OUTPUT" + else + echo echo "value=false" >> "$GITHUB_OUTPUT" + fi + + current_version: + name: Store Current Version + runs-on: ubuntu-latest + if: github.event_name == 'workflow_dispatch' + outputs: + version: ${{ steps.version.outputs.version }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Set Version Output + id: version + run: grep s\\.version\\s LocalizationServices.podspec | sed 's/s.//' | sed "s/'//g" | sed 's/ //g' >> $GITHUB_OUTPUT + + print_current_version: + name: Print Current Version + runs-on: ubuntu-latest + needs: [ current_version ] + steps: + - name: Print Current Version + env: + VERSION: ${{ needs.current_version.outputs.version }} + run: | + printf '%s\n' "$VERSION" + + bump_version: + name: Store Bump Version + runs-on: ubuntu-latest + outputs: + version: ${{ steps.version.outputs.version }} + needs: [ current_version, version_increment_is_bump ] + steps: + - name: Bump Version + if: ${{ needs.version_increment_is_bump.outputs.isBump == 'true' }} + id: bump-semver + uses: actions-ecosystem/action-bump-semver@v1 + with: + current_version: ${{ needs.current_version.outputs.version }} + level: ${{ inputs.versionIncrementType }} + - name: Store Bump Version + id: version + run: | + echo "version=${{ steps.bump-semver.outputs.new_version }}" >> $GITHUB_OUTPUT + + print_bump_version: + name: Print Bump Version + runs-on: ubuntu-latest + needs: [ bump_version, version_increment_is_bump ] + if: ${{ needs.version_increment_is_bump.outputs.isBump == 'true' }} + steps: + - name: Print Bump Version + env: + VERSION: ${{ needs.bump_version.outputs.version }} + run: | + printf '%s\n' "$VERSION" + + manual_version: + name: Store Manual Version + runs-on: ubuntu-latest + outputs: + version: ${{ steps.version.outputs.version }} + if: inputs.versionIncrementType == 'manual' + steps: + - name: Store Manual Version + id: version + run: | + echo "version=${{ inputs.manualVersionNumber }}" >> $GITHUB_OUTPUT + + print_manual_version: + name: Print Manual Version + runs-on: ubuntu-latest + needs: [ manual_version ] + if: inputs.versionIncrementType == 'manual' + steps: + - name: Print Manual Version + env: + VERSION: ${{ needs.manual_version.outputs.version }} + run: | + printf '%s\n' "$VERSION" + + new_version: + name: Store New Version + runs-on: ubuntu-latest + needs: [ version_increment_is_bump, bump_version ] + if: ${{ needs.version_increment_is_bump.outputs.isBump == 'true' || inputs.versionIncrementType == 'manual' }} + outputs: + version: ${{ steps.version.outputs.version }} + steps: + - name: Store New Version + id: version + run: | + if [ ${{ needs.version_increment_is_bump.outputs.isBump }} == 'true' ]; then + echo "version=${{ needs.bump_version.outputs.version }}" >> $GITHUB_OUTPUT + elif [ ${{ inputs.versionIncrementType }} == 'manual' ]; then + echo "version=${{ inputs.manualVersionNumber }}" >> $GITHUB_OUTPUT + else + echo "No Version" + fi + + print_new_version: + name: Print New Version + runs-on: ubuntu-latest + needs: [ new_version ] + steps: + - name: Print New Version + env: + VERSION: ${{ needs.new_version.outputs.version }} + run: | + printf '%s\n' "$VERSION" + + bump_podspec_version: + name: Bump Podspec Version + runs-on: ubuntu-latest + needs: [ current_version, new_version ] + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Bump Podspec Version + run: | + sed -i "s/s.version = '${{ needs.current_version.outputs.version }}'/s.version = '${{ needs.new_version.outputs.version }}'/g" LocalizationServices.podspec + - name: Create Version Bump Pull Request + uses: peter-evans/create-pull-request@v6 + with: + branch: "versionBump/${{ needs.new_version.outputs.version }}" + title: "Bump version after release" + commit-message: "Bump version to ${{needs.new_version.outputs.version}}" \ No newline at end of file