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..f668e0aa3c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/release.yml @@ -1,33 +1,21 @@ -name: Build +name: Release -on: [push, pull_request] +on: + push: + branches: + - master + tags: + - '[0-9]+.[0-9]+*' + release: + types: [published] 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: + publish: runs-on: ubuntu-latest - if: github.repository == 'square/kotlinpoet' && github.ref != 'refs/heads/master' + if: github.repository == 'square/kotlinpoet' steps: - name: Checkout @@ -39,34 +27,13 @@ jobs: distribution: 'zulu' java-version: 19 - - name: Prep docs - run: ./gradlew dokkaHtml + - name: Set release version + if: startsWith(github.ref, 'refs/tags/') + run: echo "VERSION_NAME=${GITHUB_REF#refs/tags/}" >> gradle.properties - - 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 - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Configure JDK - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: 19 + - 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 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