From f22a106e217423232d3fa11a9cbc010625431236 Mon Sep 17 00:00:00 2001 From: Egor Vasilyev Date: Tue, 21 Mar 2023 17:48:56 +0300 Subject: [PATCH 1/6] change plugin version generation #1981 --- .github/workflows/build-and-run-tests.yml | 1 - .../publish-plugin-and-cli-from-branch.yml | 82 +++++++++++++++---- 2 files changed, 67 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build-and-run-tests.yml b/.github/workflows/build-and-run-tests.yml index eed520a298..d3e8e68ba4 100644 --- a/.github/workflows/build-and-run-tests.yml +++ b/.github/workflows/build-and-run-tests.yml @@ -22,7 +22,6 @@ jobs: needs: build-and-run-tests uses: ./.github/workflows/publish-plugin-and-cli-from-branch.yml with: - minor-release: 'none' # upload artifacts on push action to main only upload-artifact: ${{ github.event_name == 'push' }} secrets: inherit diff --git a/.github/workflows/publish-plugin-and-cli-from-branch.yml b/.github/workflows/publish-plugin-and-cli-from-branch.yml index d3790f3dfb..c39af70b78 100644 --- a/.github/workflows/publish-plugin-and-cli-from-branch.yml +++ b/.github/workflows/publish-plugin-and-cli-from-branch.yml @@ -18,6 +18,18 @@ on: description: "Upload artifacts or not" required: false default: false + commit_sha: + required: false + type: string + description: "(optional) Commit SHA" + custom_year: + required: false + type: string + description: "(optional) Year" + custom_month: + required: false + type: string + description: "(optional) Month" workflow_dispatch: inputs: @@ -50,6 +62,18 @@ on: options: - true - false + commit_sha: + required: false + type: string + description: "(optional) Commit SHA" + custom_year: + required: false + type: string + description: "(optional) Year" + custom_month: + required: false + type: string + description: "(optional) Month" jobs: publish_plugin_and_cli: @@ -65,28 +89,56 @@ jobs: container: unittestbot/java-env:java17-zulu-jdk-gradle7.6.1-kotlinc1.8.0 steps: - uses: actions/checkout@v3 + - name: Check out ${{ github.event.inputs.commit_sha }} commit + if: github.event.inputs.commit_sha != '' + run: | + git config --global --add safe.directory ${GITHUB_WORKSPACE} + git fetch + git checkout ${{ github.event.inputs.commit_sha }} # "You can make an environment variable available to any subsequent steps in a workflow job by # defining or updating the environment variable and writing this to the GITHUB_ENV environment file." - - name: Set environment variables - run: | - echo "VERSION="$(date +%Y).$(date +%-m).${GITHUB_RUN_NUMBER}"" >> $GITHUB_ENV - echo "POSTFIX=${{ github.event.inputs.version-postfix }}" >> $GITHUB_ENV - - name: Set production version - if: ${{ github.event.inputs.version-postfix == 'no-postfix-prod' || github.event.inputs.version-postfix == 'alpha' || github.event.inputs.version-postfix == 'beta' }} - run: | - echo "VERSION="$(date +%Y).$(date +%-m)"" >> $GITHUB_ENV - - name: Set version for minor release + - name: Construct version | Set year + run: echo "VERSION=$(date +%Y)" >> $GITHUB_ENV + - name: Construct version | Set custom year + if: ${{ github.event.inputs.custom_year != '' }} + run: echo "VERSION=${{ github.event.inputs.custom_year }}" >> $GITHUB_ENV + - name: Construct version | Set month + run: echo "VERSION=${{ env.VERSION }}.$(date +%-m)" >> $GITHUB_ENV + - name: Construct version | Set custom month + if: ${{ github.event.inputs.custom_month != '' }} + run: echo "VERSION=${{ env.VERSION }}.${{ github.event.inputs.custom_month }}" >> $GITHUB_ENV + - name: Construct version | Set run number if no-postfix + if: ${{ github.event.inputs.version-postfix == 'no-postfix' }} + run: echo "VERSION=${{ env.VERSION }}.${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV + - name: Construct version | Set minor release if: ${{ github.event.inputs.minor-release != 'none' }} - run: | - echo "VERSION=${{ env.VERSION }}.${{ github.event.inputs.minor-release }}" >> $GITHUB_ENV - - name: Create version with postfix - if: ${{ (env.POSTFIX == 'alpha') || (env.POSTFIX == 'beta') }} - run: - echo "VERSION=${{ env.VERSION }}-${{ env.POSTFIX }}" >> $GITHUB_ENV + run: echo "VERSION=${{ env.VERSION }}.${{ github.event.inputs.minor-release }}" >> $GITHUB_ENV + - name: Construct version | Create version with postfix + if: ${{ github.event.inputs.version-postfix == 'alpha' || github.event.inputs.version-postfix == 'beta' }} + run: echo "VERSION=${{ env.VERSION }}-${{ github.event.inputs.version-postfix }}" >> $GITHUB_ENV - name: Print environment variables run: printenv +# - name: Set environment variables +# run: | +# echo "VERSION="$(date +%Y).$(date +%-m).${GITHUB_RUN_NUMBER}"" >> $GITHUB_ENV +# echo "POSTFIX=${{ github.event.inputs.version-postfix }}" >> $GITHUB_ENV +# - name: Set production version +# if: ${{ github.event.inputs.version-postfix == 'no-postfix-prod' || github.event.inputs.version-postfix == 'alpha' || github.event.inputs.version-postfix == 'beta' }} +# run: | +# echo "VERSION="$(date +%Y).$(date +%-m)"" >> $GITHUB_ENV +# - name: Set version for minor release +# if: ${{ github.event.inputs.minor-release != 'none' }} +# run: | +# echo "VERSION=${{ env.VERSION }}.${{ github.event.inputs.minor-release }}" >> $GITHUB_ENV +# - name: Create version with postfix +# if: ${{ (env.POSTFIX == 'alpha') || (env.POSTFIX == 'beta') }} +# run: +# echo "VERSION=${{ env.VERSION }}-${{ env.POSTFIX }}" >> $GITHUB_ENV +# - name: Print environment variables +# run: printenv + - name: Build UTBot IntelliJ IDEA plugin run: | gradle clean buildPlugin --no-daemon --build-cache --no-parallel ${{ matrix.configuration.extra_options }} -Dorg.gradle.jvmargs=-Xmx2g -Dkotlin.daemon.jvm.options=-Xmx4g -PsemVer=${{ env.VERSION }} From 7a433d3f3072a32b8cfe3dbdddf52dcce6a83b39 Mon Sep 17 00:00:00 2001 From: Egor Vasilyev Date: Wed, 22 Mar 2023 12:46:18 +0300 Subject: [PATCH 2/6] fix month --- .../workflows/publish-plugin-and-cli-from-branch.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/publish-plugin-and-cli-from-branch.yml b/.github/workflows/publish-plugin-and-cli-from-branch.yml index c39af70b78..3d98b04376 100644 --- a/.github/workflows/publish-plugin-and-cli-from-branch.yml +++ b/.github/workflows/publish-plugin-and-cli-from-branch.yml @@ -99,22 +99,24 @@ jobs: # "You can make an environment variable available to any subsequent steps in a workflow job by # defining or updating the environment variable and writing this to the GITHUB_ENV environment file." - name: Construct version | Set year - run: echo "VERSION=$(date +%Y)" >> $GITHUB_ENV + run: echo "APP_YEAR=$(date +%Y)" >> $GITHUB_ENV - name: Construct version | Set custom year if: ${{ github.event.inputs.custom_year != '' }} - run: echo "VERSION=${{ github.event.inputs.custom_year }}" >> $GITHUB_ENV + run: echo "APP_YEAR=${{ github.event.inputs.custom_year }}" >> $GITHUB_ENV - name: Construct version | Set month - run: echo "VERSION=${{ env.VERSION }}.$(date +%-m)" >> $GITHUB_ENV + run: echo "APP_MONTH=$(date +%-m)" >> $GITHUB_ENV - name: Construct version | Set custom month if: ${{ github.event.inputs.custom_month != '' }} - run: echo "VERSION=${{ env.VERSION }}.${{ github.event.inputs.custom_month }}" >> $GITHUB_ENV + run: echo "APP_MONTH=${{ github.event.inputs.custom_month }}" >> $GITHUB_ENV + - name: Construct version | Set basic version + run: echo "VERSION=${{ env.APP_YEAR }}.${{ env.APP_MONTH }}" >> $GITHUB_ENV - name: Construct version | Set run number if no-postfix if: ${{ github.event.inputs.version-postfix == 'no-postfix' }} run: echo "VERSION=${{ env.VERSION }}.${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV - name: Construct version | Set minor release if: ${{ github.event.inputs.minor-release != 'none' }} run: echo "VERSION=${{ env.VERSION }}.${{ github.event.inputs.minor-release }}" >> $GITHUB_ENV - - name: Construct version | Create version with postfix + - name: Construct version | Set postfix if: ${{ github.event.inputs.version-postfix == 'alpha' || github.event.inputs.version-postfix == 'beta' }} run: echo "VERSION=${{ env.VERSION }}-${{ github.event.inputs.version-postfix }}" >> $GITHUB_ENV - name: Print environment variables From 46dd50cfdd92be684a0a4950ccc7df829aa5fa25 Mon Sep 17 00:00:00 2001 From: Egor Vasilyev Date: Wed, 22 Mar 2023 13:13:18 +0300 Subject: [PATCH 3/6] remove comments --- .../publish-plugin-and-cli-from-branch.yml | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/.github/workflows/publish-plugin-and-cli-from-branch.yml b/.github/workflows/publish-plugin-and-cli-from-branch.yml index 3d98b04376..de00365980 100644 --- a/.github/workflows/publish-plugin-and-cli-from-branch.yml +++ b/.github/workflows/publish-plugin-and-cli-from-branch.yml @@ -122,25 +122,6 @@ jobs: - name: Print environment variables run: printenv -# - name: Set environment variables -# run: | -# echo "VERSION="$(date +%Y).$(date +%-m).${GITHUB_RUN_NUMBER}"" >> $GITHUB_ENV -# echo "POSTFIX=${{ github.event.inputs.version-postfix }}" >> $GITHUB_ENV -# - name: Set production version -# if: ${{ github.event.inputs.version-postfix == 'no-postfix-prod' || github.event.inputs.version-postfix == 'alpha' || github.event.inputs.version-postfix == 'beta' }} -# run: | -# echo "VERSION="$(date +%Y).$(date +%-m)"" >> $GITHUB_ENV -# - name: Set version for minor release -# if: ${{ github.event.inputs.minor-release != 'none' }} -# run: | -# echo "VERSION=${{ env.VERSION }}.${{ github.event.inputs.minor-release }}" >> $GITHUB_ENV -# - name: Create version with postfix -# if: ${{ (env.POSTFIX == 'alpha') || (env.POSTFIX == 'beta') }} -# run: -# echo "VERSION=${{ env.VERSION }}-${{ env.POSTFIX }}" >> $GITHUB_ENV -# - name: Print environment variables -# run: printenv - - name: Build UTBot IntelliJ IDEA plugin run: | gradle clean buildPlugin --no-daemon --build-cache --no-parallel ${{ matrix.configuration.extra_options }} -Dorg.gradle.jvmargs=-Xmx2g -Dkotlin.daemon.jvm.options=-Xmx4g -PsemVer=${{ env.VERSION }} From 5722b569d47af79ca8714e5e5e1a168a95b6ed69 Mon Sep 17 00:00:00 2001 From: Egor Vasilyev Date: Tue, 18 Apr 2023 13:10:57 +0300 Subject: [PATCH 4/6] version generation refactored --- .../publish-plugin-and-cli-from-branch.yml | 79 ++++--------------- 1 file changed, 15 insertions(+), 64 deletions(-) diff --git a/.github/workflows/publish-plugin-and-cli-from-branch.yml b/.github/workflows/publish-plugin-and-cli-from-branch.yml index de00365980..f57811b603 100644 --- a/.github/workflows/publish-plugin-and-cli-from-branch.yml +++ b/.github/workflows/publish-plugin-and-cli-from-branch.yml @@ -3,16 +3,6 @@ name: "[M] Plugin and CLI: publish as archives" on: workflow_call: inputs: - minor-release: - type: string - description: "It adds minor release indicator to version." - required: false - default: 'none' - version-postfix: - type: string - description: "It adds postfix (alpha or beta) to version (optional)." - required: false - default: no-postfix upload-artifact: type: string description: "Upload artifacts or not" @@ -22,38 +12,14 @@ on: required: false type: string description: "(optional) Commit SHA" - custom_year: - required: false + custom_version: type: string - description: "(optional) Year" - custom_month: + description: "Custom version" required: false - type: string - description: "(optional) Month" + default: "" workflow_dispatch: inputs: - minor-release: - type: choice - description: "It adds minor release indicator to version." - required: true - default: 'none' - options: - - 'none' - - '1' - - '2' - - '3' - - '4' - version-postfix: - type: choice - description: "It adds alpha or beta postfix to version." - required: true - default: no-postfix-prod - options: - - no-postfix-prod - - no-postfix - - alpha - - beta upload-artifact: type: choice description: "Upload artifacts or not" @@ -66,14 +32,11 @@ on: required: false type: string description: "(optional) Commit SHA" - custom_year: - required: false + custom_version: type: string - description: "(optional) Year" - custom_month: + description: "Custom version" required: false - type: string - description: "(optional) Month" + default: "" jobs: publish_plugin_and_cli: @@ -98,27 +61,15 @@ jobs: # "You can make an environment variable available to any subsequent steps in a workflow job by # defining or updating the environment variable and writing this to the GITHUB_ENV environment file." - - name: Construct version | Set year - run: echo "APP_YEAR=$(date +%Y)" >> $GITHUB_ENV - - name: Construct version | Set custom year - if: ${{ github.event.inputs.custom_year != '' }} - run: echo "APP_YEAR=${{ github.event.inputs.custom_year }}" >> $GITHUB_ENV - - name: Construct version | Set month - run: echo "APP_MONTH=$(date +%-m)" >> $GITHUB_ENV - - name: Construct version | Set custom month - if: ${{ github.event.inputs.custom_month != '' }} - run: echo "APP_MONTH=${{ github.event.inputs.custom_month }}" >> $GITHUB_ENV - - name: Construct version | Set basic version - run: echo "VERSION=${{ env.APP_YEAR }}.${{ env.APP_MONTH }}" >> $GITHUB_ENV - - name: Construct version | Set run number if no-postfix - if: ${{ github.event.inputs.version-postfix == 'no-postfix' }} - run: echo "VERSION=${{ env.VERSION }}.${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV - - name: Construct version | Set minor release - if: ${{ github.event.inputs.minor-release != 'none' }} - run: echo "VERSION=${{ env.VERSION }}.${{ github.event.inputs.minor-release }}" >> $GITHUB_ENV - - name: Construct version | Set postfix - if: ${{ github.event.inputs.version-postfix == 'alpha' || github.event.inputs.version-postfix == 'beta' }} - run: echo "VERSION=${{ env.VERSION }}-${{ github.event.inputs.version-postfix }}" >> $GITHUB_ENV + - name: Setup custom version + if: ${{ github.event.inputs.custom_version != '' }} + run: | + echo "VERSION=${{ github.event.inputs.custom_version }}" >> $GITHUB_ENV + - name: Setup version + if: ${{ github.event.inputs.custom_version == '' }} + run: | + echo "VERSION=$(date +%Y).$(date +%-m).${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV + - name: Print environment variables run: printenv From fda70a27a66329842149ea71bc455aeaea782e31 Mon Sep 17 00:00:00 2001 From: Egor Vasilyev Date: Thu, 20 Apr 2023 12:52:34 +0300 Subject: [PATCH 5/6] first 4 symbols from branch name added into version --- .github/workflows/publish-plugin-and-cli-from-branch.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-plugin-and-cli-from-branch.yml b/.github/workflows/publish-plugin-and-cli-from-branch.yml index f57811b603..08c1f36ee7 100644 --- a/.github/workflows/publish-plugin-and-cli-from-branch.yml +++ b/.github/workflows/publish-plugin-and-cli-from-branch.yml @@ -68,7 +68,7 @@ jobs: - name: Setup version if: ${{ github.event.inputs.custom_version == '' }} run: | - echo "VERSION=$(date +%Y).$(date +%-m).${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV + echo "VERSION=${GITHUB_REF_NAME:0:4}-$(date +%Y).$(date +%-m).${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV - name: Print environment variables run: printenv From 3d31e82825ed0f7e52572b3ec98eb5d6d72a4ea5 Mon Sep 17 00:00:00 2001 From: Egor Vasilyev Date: Thu, 20 Apr 2023 13:23:03 +0300 Subject: [PATCH 6/6] add shell type --- .github/workflows/publish-plugin-and-cli-from-branch.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/publish-plugin-and-cli-from-branch.yml b/.github/workflows/publish-plugin-and-cli-from-branch.yml index 08c1f36ee7..3c76174e43 100644 --- a/.github/workflows/publish-plugin-and-cli-from-branch.yml +++ b/.github/workflows/publish-plugin-and-cli-from-branch.yml @@ -67,6 +67,7 @@ jobs: echo "VERSION=${{ github.event.inputs.custom_version }}" >> $GITHUB_ENV - name: Setup version if: ${{ github.event.inputs.custom_version == '' }} + shell: bash run: | echo "VERSION=${GITHUB_REF_NAME:0:4}-$(date +%Y).$(date +%-m).${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV