From efab1f8d926a7ad55794b2986e8b4402599e4c16 Mon Sep 17 00:00:00 2001 From: Jim Schubert Date: Mon, 12 Oct 2020 23:16:17 -0400 Subject: [PATCH 1/4] [build] Master/PR/Release workflows --- .github/workflows/maven.yml | 20 ++++++++-------- .github/workflows/pr.yml | 35 ++++++++++++++++++++++++++++ .github/workflows/release.yml | 43 +++++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/pr.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 886fa41fe..0073aaa9b 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -1,11 +1,12 @@ -name: Test +name: Main Build on: push: branches: - - master - pull_request: - branches: - - master + - master + paths-ignore: + - 'docs/**' + - '.circleci/**' + - '.github/**' jobs: build: runs-on: 'ubuntu-latest' @@ -18,7 +19,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Set up JDK - uses: joschi/setup-jdk@v2.3.0 + uses: actions/setup-java@v1 with: java-version: ${{ matrix.java_version }} - uses: actions/cache@v2.1.2 @@ -27,7 +28,8 @@ jobs: key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} restore-keys: | ${{ runner.os }}-maven- - - name: Build with Maven - run: ./mvnw -V -B -ntp -ff install '-DskipTests=true' '-Dmaven.javadoc.skip=true' - name: Run tests - run: ./mvnw -V -B -ntp -ff verify + run: ./mvnw -V -B -ntp -ff clean verify + - name: Release Snapshot + if: matrix.java_version == '11' + run: ./mvnw -V -B -ntp -ff deploy diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 000000000..3711c3dca --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,35 @@ +name: Pull Request Checks +on: + - pull_request + +jobs: + cleanup: + name: Cleanup any previous jobs + runs-on: ubuntu-latest + if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master'" + steps: + - uses: rokroskar/workflow-run-cleanup-action@v0.2.2 + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + build: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + java_version: ['8', '11', '15'] + env: + JAVA_OPTS: "-XX:+TieredCompilation -XX:TieredStopAtLevel=1" + steps: + - uses: actions/checkout@v2 + - name: Set up JDK + uses: actions/setup-java@v1 + with: + java-version: ${{ matrix.java_version }} + - uses: actions/cache@v2.1.2 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + - name: Run tests + run: ./mvnw -V -B -ntp -ff clean verify diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..61f639e02 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,43 @@ +name: Triggered Release +on: [workflow_dispatch] + +env: + OSS_USERNAME: ${{ secrets.OSS_USERNAME }} + OSS_PASSWORD: ${{ secrets.OSS_PASSWORD }} + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + +jobs: + release: + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + # Value of the distributionManagement/repository/id field of the pom.xml + server-id: sonatype-nexus-staging + gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} + server-username: OSS_USERNAME + server-password: OSS_PASSWORD + gpg-passphrase: GPG_PASSPHRASE + - uses: actions/cache@v2.1.2 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + - name: Setup Git + run: | + git config --global committer.email "noreply@github.com" + git config --global committer.name "GitHub Release" + git config --global author.email "${GITHUB_ACTOR}@users.noreply.github.com" + git config --global author.name "${GITHUB_ACTOR}" + - name: Release + run: ./mvnw -B clean release:prepare release:perform -Prelease -Dgpg.passphrase=${{secrets.GPG_PASSPHRASE}} -Drepository.url=https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git + - name: 'if failure -> rollback' + if: ${{ failure() }} + run: | + ./mvnw -B release:rollback -Prelease -Dgpg.passphrase=${{secrets.GPG_PASSPHRASE}} + echo "You may need to manually delete the GitHub tag, if it was created." From 2cd5ac0a853a6b624593b001e13901428fd17304 Mon Sep 17 00:00:00 2001 From: Jochen Schalanda Date: Tue, 13 Oct 2020 08:16:45 +0200 Subject: [PATCH 2/4] Update GitHub workflow badge in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d061d6d79..ada49dc7b 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Compare two OpenAPI specifications (3.x) and render the difference to HTML plaintext, or Markdown files. -[![Test](https://github.com/OpenAPITools/openapi-diff/workflows/Test/badge.svg)](https://github.com/OpenAPITools/openapi-diff/actions?query=branch%3Amaster+workflow%3ATest+) +[![Build](https://github.com/OpenAPITools/openapi-diff/workflows/Main%20Build/badge.svg)](https://github.com/OpenAPITools/openapi-diff/actions?query=branch%3Amaster+workflow%3A"Main+Build") [![Join the Slack chat room](https://img.shields.io/badge/Slack-Join%20the%20chat%20room-orange)](https://join.slack.com/t/openapi-generator/shared_invite/enQtNzAyNDMyOTU0OTE1LTY5ZDBiNDI5NzI5ZjQ1Y2E5OWVjMjZkYzY1ZGM2MWQ4YWFjMzcyNDY5MGI4NjQxNDBiMTlmZTc5NjY2ZTQ5MGM) From 565f3b444aba0246bcd650224fd8af9247a81143 Mon Sep 17 00:00:00 2001 From: Jochen Schalanda Date: Tue, 13 Oct 2020 08:17:56 +0200 Subject: [PATCH 3/4] Skip Maven `clean` phase --- .github/workflows/maven.yml | 2 +- .github/workflows/pr.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 0073aaa9b..d79dce909 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -29,7 +29,7 @@ jobs: restore-keys: | ${{ runner.os }}-maven- - name: Run tests - run: ./mvnw -V -B -ntp -ff clean verify + run: ./mvnw -V -B -ntp -ff verify - name: Release Snapshot if: matrix.java_version == '11' run: ./mvnw -V -B -ntp -ff deploy diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 3711c3dca..e5f282bd2 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -32,4 +32,4 @@ jobs: restore-keys: | ${{ runner.os }}-maven- - name: Run tests - run: ./mvnw -V -B -ntp -ff clean verify + run: ./mvnw -V -B -ntp -ff verify From 89c61df59c9321b9f9b85644d356551814ec083e Mon Sep 17 00:00:00 2001 From: Jochen Schalanda Date: Tue, 13 Oct 2020 08:18:14 +0200 Subject: [PATCH 4/4] Only run release workflow on `master` branch --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 61f639e02..dcd1a3d42 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,7 +9,7 @@ env: jobs: release: runs-on: ubuntu-latest - if: github.ref == 'refs/heads/main' + if: github.ref == 'refs/heads/master' steps: - uses: actions/checkout@v2 - name: Set up JDK 11