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