Skip to content

Add yml to build/release using GH Actions #329

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#
# CI build that assembles artifacts and runs tests.
# If validation is successful this workflow releases from the main dev branch.
#
# - skipping CI: add [skip ci] to the commit message
# - skipping release: add [skip release] to the commit message
#
name: CI

on:
push:
branches: ['release/1.x']
tags-ignore: [v*] # release tags are automatically generated after a successful CI build, no need to run CI against them
pull_request:
branches: ['**']

jobs:

#
# Main build job
#
build:
runs-on: ubuntu-latest
if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"

# Definition of the build matrix
strategy:
matrix:
java: [8, 11]

# All build steps
# SINGLE-MATRIX-JOB means that the step does not need to be executed on every job in the matrix
steps:

- name: 1. Check out code
uses: actions/checkout@v2 # https://github.com/actions/checkout
with:
fetch-depth: '0' # https://github.com/shipkit/shipkit-changelog#fetch-depth-on-ci

- name: 2. Set up Java ${{ matrix.java }}
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}

- name: 3. Build on Java ${{ matrix.java }}
run: ./gradlew build bintrayUpload --scan -PbintrayDryRun

#
# Release job, only for pushes to the main development branch
#
release:
runs-on: ubuntu-latest
needs: [build] # build job must pass before we can release

if: github.event_name == 'push'
&& github.ref == 'refs/heads/release/1.x'
&& github.repository == 'mockito/mockito'
&& !contains(toJSON(github.event.commits.*.message), '[skip release]')

steps:

- name: Check out code
uses: actions/checkout@v2 # https://github.com/actions/checkout
with:
fetch-depth: '0' # https://github.com/shipkit/shipkit-changelog#fetch-depth-on-ci

- name: Set up Java 8
uses: actions/setup-java@v1
with:
java-version: 8

- name: Build and publish to Bintray/MavenCentral
run: ./gradlew bintrayUpload githubRelease --scan
env:
MAVEN_CENTRAL_RELEASE: ${{contains(toJSON(github.event.commits.*.message), '[ci maven-central-release]')}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
BINTRAY_API_KEY: ${{secrets.BINTRAY_API_KEY}}
NEXUS_TOKEN_USER: ${{secrets.NEXUS_TOKEN_USER}}
NEXUS_TOKEN_PWD: ${{secrets.NEXUS_TOKEN_PWD}}