• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
2# CI build that assembles artifacts and runs tests.
3# If validation is successful this workflow releases from the main dev branch.
4#
5# - skipping CI: add [skip ci] to the commit message
6# - skipping release: add [skip release] to the commit message
7#
8name: CI
9
10on:
11  push:
12    branches:
13      - main
14    tags:
15      - 3.*
16      - 4.*
17  pull_request:
18    branches:
19      - main
20
21jobs:
22
23  #
24  # SINGLE-JOB
25  #
26  verify:
27    runs-on:  ubuntu-latest
28    if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"
29
30    steps:
31
32      - name: 1. Check out code
33        uses: actions/checkout@v2 # https://github.com/actions/checkout
34
35      - name: 2. Set up Java 8
36        uses: actions/setup-java@v1 # https://github.com/actions/setup-java
37        with:
38          java-version: 8
39
40      - name: 3. Validate Gradle wrapper
41        uses: gradle/wrapper-validation-action@v1 # https://github.com/gradle/wrapper-validation-action
42
43  #
44  # Main build job
45  #
46  build:
47    needs: [verify]
48    runs-on:  ubuntu-latest
49
50    # Definition of the build matrix
51    strategy:
52      matrix:
53        mock-maker: ['mock-maker-default', 'mock-maker-inline']
54        kotlin: ['1.3.50', '1.4.21']
55        # Note that the old Travis CI referenced other Kotlin versions: '1.0.7', '1.1.61', '1.2.50'
56        # However, those versions of Kotlin don't work with latest Gradle
57
58    steps:
59
60    - name: 1. Check out code
61      uses: actions/checkout@v2 # https://github.com/actions/checkout
62
63    - name: 2. Set up Java 8
64      uses: actions/setup-java@v1 # https://github.com/actions/setup-java
65      with:
66        java-version: 8
67
68    - name: 3. Build with Kotlin ${{ matrix.kotlin }} and mock-maker ${{ matrix.mock-maker }}
69      run: |
70        ops/mockMakerInline.sh
71        ./gradlew build
72      env:
73        KOTLIN_VERSION: ${{ matrix.kotlin }}
74        MOCK_MAKER: ${{ matrix.mock-maker }}
75
76  #
77  # Release job, only for pushes to the main development branch
78  #
79  release:
80    runs-on: ubuntu-latest
81    needs: [build] # build job must pass before we can release
82
83    if: github.event_name == 'push'
84        && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/3.') || startsWith(github.ref, 'refs/tags/4.'))
85        && github.repository == 'mockito/mockito-kotlin'
86        && !contains(toJSON(github.event.commits.*.message), '[skip release]')
87
88    steps:
89
90    - name: Check out code
91      uses: actions/checkout@v2 # https://github.com/actions/checkout
92      with:
93        fetch-depth: '0' # https://github.com/shipkit/shipkit-changelog#fetch-depth-on-ci
94
95    - name: Set up Java 8
96      uses: actions/setup-java@v1
97      with:
98        java-version: 8
99
100    - name: Build and release
101      run: ./gradlew githubRelease publishToSonatype closeAndReleaseStagingRepository releaseSummary
102      env:
103        GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
104        NEXUS_TOKEN_USER: ${{secrets.NEXUS_TOKEN_USER}}
105        NEXUS_TOKEN_PWD: ${{secrets.NEXUS_TOKEN_PWD}}
106        PGP_KEY: ${{secrets.PGP_KEY}}
107        PGP_PWD: ${{secrets.PGP_PWD}}
108