diff --git a/.github/actions/clone/action.yml b/.github/actions/clone/action.yml new file mode 100644 index 0000000..f9af81c --- /dev/null +++ b/.github/actions/clone/action.yml @@ -0,0 +1,14 @@ +name: "Clone code and set up Java" + +runs: + using: "composite" + steps: + - name: "Clone code" + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: "Set up Adopt OpenJDK 17" + uses: actions/setup-java@v3 + with: + distribution: adopt + java-version: 17 diff --git a/.github/actions/lint/action.yml b/.github/actions/lint/action.yml new file mode 100644 index 0000000..03b7a6c --- /dev/null +++ b/.github/actions/lint/action.yml @@ -0,0 +1,11 @@ +name: "Lint code" + +runs: + using: "composite" + steps: + - name: "Clone code and set up Java" + uses: ./.github/actions/clone + - name: "Detekt" + run: sh gradlew detekt + - name: "KtLint" + run: sh gradlew ktlintCheck diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..923f8ed --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,21 @@ +name: "Lint and build code" + +on: + push: + branches: + - "**" + - "!main" + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: "Lint code" + uses: ./.github/actions/lint + + build: + needs: lint + runs-on: macos-latest + steps: + - name: "Validate Gradle wrapper" + uses: gradle/wrapper-validation-action@v1 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 932bf60..7db65d6 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,41 +1,22 @@ -name: Publish +name: "Lint and build code, and publish artifacts to repository" + on: push: branches: - - main + - "main" jobs: lint: runs-on: ubuntu-latest steps: - - name: "Clone repo" - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: "Set up Adopt OpenJDK 17" - uses: actions/setup-java@v3 - with: - distribution: adopt - java-version: 17 - - name: "Detekt" - run: sh gradlew detekt - - name: "KtLint" - run: sh gradlew ktlintCheck + - name: "Lint code" + uses: ./.github/actions/lint build: needs: lint runs-on: macos-latest steps: - - name: "Clone repo" - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: "Set up Adopt OpenJDK 17" - uses: actions/setup-java@v3 - with: - distribution: adopt - java-version: 17 - - name: Validate Gradle wrapper + - name: "Validate Gradle wrapper" uses: gradle/wrapper-validation-action@v1 publish: