From 09e0f1941f70c7c226e8ec69b27143c8a27bfd75 Mon Sep 17 00:00:00 2001 From: Egor Andreevici Date: Thu, 6 Apr 2023 17:41:48 +0200 Subject: [PATCH 1/3] Split workflows into build and release --- .github/workflows/build-pr.yml | 57 ++++++++++++++++++++ .github/workflows/{build.yml => release.yml} | 57 +++----------------- 2 files changed, 63 insertions(+), 51 deletions(-) create mode 100644 .github/workflows/build-pr.yml rename .github/workflows/{build.yml => release.yml} (52%) diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml new file mode 100644 index 0000000000..cadc4d9684 --- /dev/null +++ b/.github/workflows/build-pr.yml @@ -0,0 +1,57 @@ +name: Build + +on: + push: + branches-ignore: + - master + pull_request: + +env: + GRADLE_OPTS: "-Dorg.gradle.jvmargs=-Xmx4g -Dorg.gradle.daemon=false -Dkotlin.incremental=false" + +jobs: + jvm: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Validate Gradle Wrapper + uses: gradle/wrapper-validation-action@v1 + + - name: Configure JDK + uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: 19 + + - name: Test + run: ./gradlew build + + build-docs: + runs-on: ubuntu-latest + if: github.repository == 'square/kotlinpoet' + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Configure JDK + uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: 19 + + - name: Prep docs + run: ./gradlew dokkaHtml + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3.8 + + - name: Build mkdocs + run: | + pip3 install -r .github/workflows/mkdocs-requirements.txt + mkdocs build diff --git a/.github/workflows/build.yml b/.github/workflows/release.yml similarity index 52% rename from .github/workflows/build.yml rename to .github/workflows/release.yml index 2e37bd4621..9a87fe092e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/release.yml @@ -1,62 +1,17 @@ -name: Build +name: Release -on: [push, pull_request] +on: + push: + branches: + - master env: GRADLE_OPTS: "-Dorg.gradle.jvmargs=-Xmx4g -Dorg.gradle.daemon=false -Dkotlin.incremental=false" jobs: - jvm: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Validate Gradle Wrapper - uses: gradle/wrapper-validation-action@v1 - - - name: Configure JDK - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: 19 - - - name: Test - run: ./gradlew build - - build-docs: - runs-on: ubuntu-latest - if: github.repository == 'square/kotlinpoet' && github.ref != 'refs/heads/master' - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Configure JDK - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: 19 - - - name: Prep docs - run: ./gradlew dokkaHtml - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: 3.8 - - - name: Build mkdocs - run: | - pip3 install -r .github/workflows/mkdocs-requirements.txt - mkdocs build - publish: runs-on: ubuntu-latest - if: github.repository == 'square/kotlinpoet' && github.ref == 'refs/heads/master' - needs: - - jvm + if: github.repository == 'square/kotlinpoet' steps: - name: Checkout From a3555e66f515298e7b7864f2a83f48a9f633fff0 Mon Sep 17 00:00:00 2001 From: Egor Andreevici Date: Thu, 6 Apr 2023 18:00:08 +0200 Subject: [PATCH 2/3] Run release on tag pushes and set VERSION_NAME to tag value --- .github/workflows/release.yml | 10 ++++++++++ gradle.properties | 1 - 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9a87fe092e..3d6bc271ee 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,6 +4,8 @@ on: push: branches: - master + tags: + - '[0-9]+.[0-9]+*' env: GRADLE_OPTS: "-Dorg.gradle.jvmargs=-Xmx4g -Dorg.gradle.daemon=false -Dkotlin.incremental=false" @@ -23,6 +25,14 @@ jobs: distribution: 'zulu' java-version: 19 + - name: Set release version + if: startsWith(github.ref, 'refs/tags/') + run: echo "VERSION_NAME=${GITHUB_REF#refs/tags/}" >> gradle.properties + + - name: Set snapshot version + if: !startsWith(github.ref, 'refs/tags/') + run: echo "VERSION_NAME=$(date +'%Y%m%d.%H%M%S').$(git rev-parse --short HEAD)" >> gradle.properties + - name: Upload Artifacts run: ./gradlew publish env: diff --git a/gradle.properties b/gradle.properties index 1714ccf3c0..e41893eb29 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,6 @@ org.gradle.jvmargs='-Dfile.encoding=UTF-8' GROUP=com.squareup -VERSION_NAME=1.14.0-SNAPSHOT POM_URL=https://github.com/square/kotlinpoet POM_SCM_URL=https://github.com/square/kotlinpoet From a7c2b654f03e6a081f1b555723aba241ee768d48 Mon Sep 17 00:00:00 2001 From: Egor Andreevici Date: Thu, 6 Apr 2023 18:03:12 +0200 Subject: [PATCH 3/3] Add release trigger --- .github/workflows/release.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3d6bc271ee..f668e0aa3c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,6 +6,8 @@ on: - master tags: - '[0-9]+.[0-9]+*' + release: + types: [published] env: GRADLE_OPTS: "-Dorg.gradle.jvmargs=-Xmx4g -Dorg.gradle.daemon=false -Dkotlin.incremental=false"