diff --git a/.github/workflows/bump-cli.yml b/.github/workflows/bump-cli.yml index 59946b0cf..eff9fb185 100644 --- a/.github/workflows/bump-cli.yml +++ b/.github/workflows/bump-cli.yml @@ -1,6 +1,19 @@ name: Bump CLI version on: workflow_dispatch: + inputs: + option: + description: "Option" + required: true + default: 'replace' + type: choice + options: + - prepend + - replace + version: + description: "Version" + required: false + type: string pull_request: branches: [main] paths: @@ -23,10 +36,18 @@ jobs: with: fetch-depth: 1 - name: Bump CLI + if: ${{ inputs.option == 'replace' }} env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | scripts/replace-cli-version.sh + - name: Prepend another version + if: ${{ inputs.option == 'prepend' }} + run: | + cat supported_cli_versions.json | jq '. |= ["${{ inputs.version }}"] + .' > supported_cli_versions_temp.json + mv supported_cli_versions_temp.json supported_cli_versions.json + echo "LATEST_VERSION=${{ inputs.version }}" >> $GITHUB_ENV + echo "PREVIOUS_VERSION=`jq -r '.[1]' supported_cli_versions.json`" >> $GITHUB_ENV - name: Commit, Push and Open a PR uses: ./.github/actions/create-pr with: diff --git a/.github/workflows/version-change.yml b/.github/workflows/version-change.yml deleted file mode 100644 index 569e0ea3e..000000000 --- a/.github/workflows/version-change.yml +++ /dev/null @@ -1,56 +0,0 @@ -name: Version Change -on: - workflow_dispatch: - inputs: - option: - description: "Option" - required: true - default: 'append' - type: choice - options: - - append - - prepend - - remove - version: - description: "Version" - required: true - type: string - -permissions: - contents: write - pull-requests: write - -jobs: - build: - name: Build - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 1 - - name: Remove Version - if: ${{ inputs.option == 'remove' }} - run: | - cat supported_cli_versions.json | jq 'del(.[] | select(. == "${{ inputs.version }}"))' > supported_cli_versions_temp.json - - name: Append Version - if: ${{ inputs.option == 'append' }} - run: | - cat supported_cli_versions.json | jq '. += ["${{ inputs.version }}"]' > supported_cli_versions_temp.json - - name: Prepend Version - if: ${{ inputs.option == 'prepend' }} - run: | - cat supported_cli_versions.json | jq '. |= ["${{ inputs.version }}"] + .' > supported_cli_versions_temp.json - - name: Move temp file to supported_cli_versions.json - run: | - mv supported_cli_versions_temp.json supported_cli_versions.json - - name: Commit, Push and Open a PR - uses: ./.github/actions/create-pr - with: - token: ${{ secrets.GITHUB_TOKEN }} - base-branch: main - head-branch: github-action/version-change - commit-message: ${{ inputs.option }} ${{ inputs.version }} - title: ${{ inputs.option }} ${{ inputs.version }} from/in supported_cli_versions.json - body: > - ${{ inputs.option }} ${{ inputs.version }} from/in supported_cli_versions.json