From 0cc7e1d4de85b3877a676a03922e89f00a4d86b7 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Mon, 19 Feb 2024 15:04:27 +0100 Subject: [PATCH 1/7] ci(snapshot): skip deploy if no snapshot version --- .github/workflows/snapshot.yml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index 26eaa79..0d3ca7c 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -13,10 +13,27 @@ on: type: boolean jobs: + validate: + runs-on: ubuntu-latest + outputs: + is-snapshot: ${{ steps.validate.outputs.is-snapshot }} + steps: + - uses: actions/checkout@v4 + - name: Validate version is a snapshot version + id: validate + run: | + output=false + if [[ "$(./mvnw -q help:evaluate -Dexpression=project.version -DforceStdout)" =~ "-SNAPSHOT" ]]; then + echo "This is a snapshot version" + output=true + fi + echo "is-snapshot=$output" >> "$GITHUB_OUTPUT" + deploy: name: Deploy runs-on: ubuntu-latest - + needs: validate + if: ${{ needs.validate.outputs.is-snapshot == true}} steps: - id: buildkite name: Run Deploy From c5bbf5d4f0597b54a857e5d5bc86f1c58a709fc6 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Mon, 19 Feb 2024 15:12:18 +0100 Subject: [PATCH 2/7] use functions --- .github/workflows/snapshot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index 0d3ca7c..13add95 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -33,7 +33,7 @@ jobs: name: Deploy runs-on: ubuntu-latest needs: validate - if: ${{ needs.validate.outputs.is-snapshot == true}} + if: ${{ contains(needs.validate.outputs.is-snapshot, 'true') }} steps: - id: buildkite name: Run Deploy From 02558e70b33432160d6acea31fa353986b0f2125 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Mon, 19 Feb 2024 15:15:07 +0100 Subject: [PATCH 3/7] install required tools --- .github/workflows/snapshot.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index 13add95..cde64b4 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -19,6 +19,9 @@ jobs: is-snapshot: ${{ steps.validate.outputs.is-snapshot }} steps: - uses: actions/checkout@v4 + - uses: ./.github/workflows/maven-goal + with: + command: './mvnw -q help:evaluate -Dexpression=project.version -DforceStdout' - name: Validate version is a snapshot version id: validate run: | From 1ff22a62604237e56e29378238ac679a9e1b0b01 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Mon, 19 Feb 2024 15:15:35 +0100 Subject: [PATCH 4/7] avoid releases from snapshots --- .github/workflows/release.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 638b534..e5539ed 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -51,6 +51,15 @@ jobs: echo "Tag should match pom.xml project.version" exit 1 fi + - uses: ./.github/workflows/maven-goal + with: + command: './mvnw -q help:evaluate -Dexpression=project.version -DforceStdout' + - name: Validate version is a release version + run: | + if [[ "$(./mvnw -q help:evaluate -Dexpression=project.version -DforceStdout)" =~ "-SNAPSHOT" ]]; then + echo "This is a snapshot version" + exit 1 + fi release: name: Release From 599c76b5bd696d2f63a1b47a43f3679238692d4a Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Mon, 19 Feb 2024 15:48:22 +0100 Subject: [PATCH 5/7] Update .github/workflows/release.yml --- .github/workflows/release.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e5539ed..1a90927 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -51,9 +51,6 @@ jobs: echo "Tag should match pom.xml project.version" exit 1 fi - - uses: ./.github/workflows/maven-goal - with: - command: './mvnw -q help:evaluate -Dexpression=project.version -DforceStdout' - name: Validate version is a release version run: | if [[ "$(./mvnw -q help:evaluate -Dexpression=project.version -DforceStdout)" =~ "-SNAPSHOT" ]]; then From 46cb88e5e63a49c8a119720540efe7ad2a0fc81c Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Mon, 19 Feb 2024 15:56:53 +0100 Subject: [PATCH 6/7] Update .github/workflows/snapshot.yml --- .github/workflows/snapshot.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index cde64b4..13add95 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -19,9 +19,6 @@ jobs: is-snapshot: ${{ steps.validate.outputs.is-snapshot }} steps: - uses: actions/checkout@v4 - - uses: ./.github/workflows/maven-goal - with: - command: './mvnw -q help:evaluate -Dexpression=project.version -DforceStdout' - name: Validate version is a snapshot version id: validate run: | From a696105505ccf8880bc3b11510e8dacd021a68d6 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 20 Feb 2024 09:29:11 +0100 Subject: [PATCH 7/7] checkout the given ref to validate whether it exists and the version is correct --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1a90927..c39a904 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -40,6 +40,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 with: + ref: ${{ inputs.ref }} fetch-depth: 0 - name: Validate tag does not exist on current commit uses: ./.github/workflows/validate-tag