From dc08769577d226e70c166c784dfb9747d7395a21 Mon Sep 17 00:00:00 2001 From: Peter Trifanov Date: Tue, 17 Nov 2020 10:32:26 +0300 Subject: [PATCH 1/7] Use GITHUB_ENV file instead of set-env command ### What's done: * Updated diktat_snapshot.yml * Updated release.yml --- .github/workflows/diktat_snapshot.yml | 2 +- .github/workflows/release.yml | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/diktat_snapshot.yml b/.github/workflows/diktat_snapshot.yml index 76033fb5c5..a950e2d37d 100644 --- a/.github/workflows/diktat_snapshot.yml +++ b/.github/workflows/diktat_snapshot.yml @@ -29,7 +29,7 @@ jobs: run: | snapshot_version=$(printf 'VERSION=${project.version}\n0\n' | mvn -B help:evaluate | grep '^VERSION' | cut -d= -f2) base_version=${snapshot_version%-SNAPSHOT} - echo ::set-env name=BASE_VERSION::$base_version + echo "BASE_VERSION=$base_version" >> $GITHUB_ENV mvn -B versions:set -DnewVersion=$base_version-pre - name: Build and install # install diktat with version 'base_version-pre' to local maven repo diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 31a31b1544..c150217027 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -29,8 +29,9 @@ jobs: DIKTAT_GPG_PUB: ${{ secrets.DIKTAT_PGP_PUB }} DIKTAT_GPG_SEC: ${{ secrets.DIKTAT_PGP_SEC }} run: | - echo ::set-env name=PREVIOUS_VERSION::$(printf 'VERSION=${diktat-check.version}\n0\n' | mvn help:evaluate | grep '^VERSION' | cut -d= -f2) - echo ::set-env name=RELEASE_VERSION::${GITHUB_REF#'refs/tags/v'} + previous_version=$(printf 'VERSION=${diktat-check.version}\n0\n' | mvn help:evaluate | grep '^VERSION' | cut -d= -f2) + echo "PREVIOUS_VERSION=$previous_version" >> $GITHUB_ENV + echo "RELEASE_VERSION=${GITHUB_REF#'refs/tags/v'}" >> $GITHUB_ENV echo "$DIKTAT_GPG_PUB" > ~/diktat.pubring.gpg echo "$DIKTAT_GPG_SEC" > ~/diktat.secring.gpg gpg --import ~/diktat.pubring.gpg From 7c0540c5aaa82759997366ccfcbda7dc6a34587d Mon Sep 17 00:00:00 2001 From: Peter Trifanov Date: Tue, 17 Nov 2020 10:37:11 +0300 Subject: [PATCH 2/7] Use GITHUB_ENV file instead of set-env command ### What's done: * Updated diktat_snapshot.yml --- .github/workflows/diktat_snapshot.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/diktat_snapshot.yml b/.github/workflows/diktat_snapshot.yml index a950e2d37d..ea6fca0a0f 100644 --- a/.github/workflows/diktat_snapshot.yml +++ b/.github/workflows/diktat_snapshot.yml @@ -28,7 +28,9 @@ jobs: # base version is stored in env variable for later usage run: | snapshot_version=$(printf 'VERSION=${project.version}\n0\n' | mvn -B help:evaluate | grep '^VERSION' | cut -d= -f2) + echo "snapshot_version=$snapshot_version" base_version=${snapshot_version%-SNAPSHOT} + echo "base_version=$base_version" echo "BASE_VERSION=$base_version" >> $GITHUB_ENV mvn -B versions:set -DnewVersion=$base_version-pre - name: Build and install From 2b6d672cc53704b200ece22f0a7b0b9d289cfea5 Mon Sep 17 00:00:00 2001 From: Peter Trifanov Date: Tue, 17 Nov 2020 10:44:16 +0300 Subject: [PATCH 3/7] Use GITHUB_ENV file instead of set-env command ### What's done: * Updated diktat_snapshot.yml --- .github/workflows/diktat_snapshot.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/diktat_snapshot.yml b/.github/workflows/diktat_snapshot.yml index ea6fca0a0f..ec991b905f 100644 --- a/.github/workflows/diktat_snapshot.yml +++ b/.github/workflows/diktat_snapshot.yml @@ -28,10 +28,10 @@ jobs: # base version is stored in env variable for later usage run: | snapshot_version=$(printf 'VERSION=${project.version}\n0\n' | mvn -B help:evaluate | grep '^VERSION' | cut -d= -f2) - echo "snapshot_version=$snapshot_version" + echo snapshot_version=$snapshot_version base_version=${snapshot_version%-SNAPSHOT} - echo "base_version=$base_version" - echo "BASE_VERSION=$base_version" >> $GITHUB_ENV + echo base_version=$base_version + echo BASE_VERSION=$base_version >> $GITHUB_ENV mvn -B versions:set -DnewVersion=$base_version-pre - name: Build and install # install diktat with version 'base_version-pre' to local maven repo From aea1893d50e3db63a752f55f903a83c6d4e603b3 Mon Sep 17 00:00:00 2001 From: Peter Trifanov Date: Tue, 17 Nov 2020 10:47:20 +0300 Subject: [PATCH 4/7] Use GITHUB_ENV file instead of set-env command ### What's done: * Updated diktat_snapshot.yml --- .github/workflows/diktat_snapshot.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/diktat_snapshot.yml b/.github/workflows/diktat_snapshot.yml index ec991b905f..c0d2d2b7ba 100644 --- a/.github/workflows/diktat_snapshot.yml +++ b/.github/workflows/diktat_snapshot.yml @@ -6,6 +6,9 @@ on: pull_request: branches: [ master ] +env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: true + jobs: diktat_snapshot_check: runs-on: ubuntu-latest @@ -28,10 +31,8 @@ jobs: # base version is stored in env variable for later usage run: | snapshot_version=$(printf 'VERSION=${project.version}\n0\n' | mvn -B help:evaluate | grep '^VERSION' | cut -d= -f2) - echo snapshot_version=$snapshot_version base_version=${snapshot_version%-SNAPSHOT} - echo base_version=$base_version - echo BASE_VERSION=$base_version >> $GITHUB_ENV + echo ::set-env name=BASE_VERSION::$base_version mvn -B versions:set -DnewVersion=$base_version-pre - name: Build and install # install diktat with version 'base_version-pre' to local maven repo From 9c9d8030f2c5fee84f7f4359353dca3f084471c4 Mon Sep 17 00:00:00 2001 From: Peter Trifanov Date: Tue, 17 Nov 2020 10:56:38 +0300 Subject: [PATCH 5/7] Use GITHUB_ENV file instead of set-env command ### What's done: * Updated diktat_snapshot.yml --- .github/workflows/diktat_snapshot.yml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/diktat_snapshot.yml b/.github/workflows/diktat_snapshot.yml index c0d2d2b7ba..9465ea3941 100644 --- a/.github/workflows/diktat_snapshot.yml +++ b/.github/workflows/diktat_snapshot.yml @@ -6,9 +6,6 @@ on: pull_request: branches: [ master ] -env: - ACTIONS_ALLOW_UNSECURE_COMMANDS: true - jobs: diktat_snapshot_check: runs-on: ubuntu-latest @@ -27,12 +24,13 @@ jobs: restore-keys: | ${{ runner.os }}-maven-build - name: Set version - # set project version which will then be used to run diktat from local maven repo - # base version is stored in env variable for later usage + # Set project version which will then be used to run diktat from local maven repo. + # Base version is stored in env variable for later usage. + # Note: maven-help-plugin requires non-interactive mode (do not add -B flag). run: | - snapshot_version=$(printf 'VERSION=${project.version}\n0\n' | mvn -B help:evaluate | grep '^VERSION' | cut -d= -f2) + snapshot_version=$(printf 'VERSION=${project.version}\n0\n' | mvn help:evaluate | grep '^VERSION' | cut -d= -f2) base_version=${snapshot_version%-SNAPSHOT} - echo ::set-env name=BASE_VERSION::$base_version + echo "BASE_VERSION=$base_version" >> $GITHUB_ENV mvn -B versions:set -DnewVersion=$base_version-pre - name: Build and install # install diktat with version 'base_version-pre' to local maven repo From dd8ae9d71e1f5584081122932b9c779502f433f6 Mon Sep 17 00:00:00 2001 From: Peter Trifanov Date: Tue, 17 Nov 2020 10:59:20 +0300 Subject: [PATCH 6/7] Use GITHUB_ENV file instead of set-env command ### What's done: * Updated release.yml --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c150217027..4e76dc0a35 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,6 +28,7 @@ jobs: env: DIKTAT_GPG_PUB: ${{ secrets.DIKTAT_PGP_PUB }} DIKTAT_GPG_SEC: ${{ secrets.DIKTAT_PGP_SEC }} + # Note: maven-help-plugin requires non-interactive mode (do not add -B flag). run: | previous_version=$(printf 'VERSION=${diktat-check.version}\n0\n' | mvn help:evaluate | grep '^VERSION' | cut -d= -f2) echo "PREVIOUS_VERSION=$previous_version" >> $GITHUB_ENV From 2dcf2e3e9983b1aa69163984f606809b7f9e9078 Mon Sep 17 00:00:00 2001 From: Peter Trifanov Date: Tue, 17 Nov 2020 11:01:49 +0300 Subject: [PATCH 7/7] Use GITHUB_ENV file instead of set-env command ### What's done: * Build only maven plugin in diktat_snapshot.yml --- .github/workflows/diktat_snapshot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/diktat_snapshot.yml b/.github/workflows/diktat_snapshot.yml index 9465ea3941..37fa345dfb 100644 --- a/.github/workflows/diktat_snapshot.yml +++ b/.github/workflows/diktat_snapshot.yml @@ -34,7 +34,7 @@ jobs: mvn -B versions:set -DnewVersion=$base_version-pre - name: Build and install # install diktat with version 'base_version-pre' to local maven repo - run: mvn -B clean install -DskipTests=true + run: mvn -B clean install -DskipTests=true --projects diktat-maven-plugin --also-make - name: Revert project version and set proper version for diktat check # revert project version to avoid cycle dependency # set diktat version in plugin dependencies to the version which was built in the previous step