ci-cd #82
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: ci-cd | |
on: | |
push: | |
branches: [master] | |
tags: [1.*] | |
paths: | |
- ".github/workflows/ci-cd.yml" | |
- "src/**" | |
- "pom.xml" | |
pull_request: | |
branches: [master] | |
schedule: | |
# ┌───────────── minute (0 - 59) | |
# │ ┌───────────── hour (0 - 23) | |
# │ │ ┌───────────── day of the month (1 - 31) | |
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC) | |
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT) | |
# * * * * * | |
- cron: "15 1 * * 1" | |
permissions: | |
contents: write | |
concurrency: | |
group: ci-cd | |
cancel-in-progress: false | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
env: | |
MVN: mvn --show-version --batch-mode | |
steps: | |
- name: jdk11 | |
uses: actions/setup-java@v2 | |
with: | |
java-version: "11" | |
distribution: "adopt" | |
server-id: ossrh | |
server-username: OSSRH_USR | |
server-password: OSSRH_PWD | |
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} | |
- name: checkout | |
uses: actions/checkout@v2 | |
- name: cache ~/.m2 | |
uses: actions/cache@v2 | |
with: | |
path: ~/.m2 | |
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | |
- name: version set | |
if: startsWith(github.ref, 'refs/tags/') | |
run: $MVN versions:set -DnewVersion=${GITHUB_REF#refs/tags/} | |
- name: mvn clean compile | |
run: $MVN clean compile | |
- name: mvn test | |
run: $MVN test | |
- name: mvn deploy | |
if: github.event_name != 'pull_request' | |
run: $MVN --activate-profiles deploy --define gpg.passphrase=${{ secrets.GPG_PASSPHRASE }} --define skipTests deploy | |
env: | |
OSSRH_USR: ${{ secrets.OSSRH_USR }} | |
OSSRH_PWD: ${{ secrets.OSSRH_PWD }} | |
- name: github release | |
uses: softprops/action-gh-release@v1 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
files: | | |
target/payload-*.jar | |
target/payload-*.jar.asc | |
- name: mvn release | |
if: startsWith(github.ref, 'refs/tags/') | |
run: $MVN --activate-profiles deploy nexus-staging:release | |
env: | |
OSSRH_USR: ${{ secrets.OSSRH_USR }} | |
OSSRH_PWD: ${{ secrets.OSSRH_PWD }} | |
# - name: Step To run on failure | |
# if: ${{ failure() }} | |
# run: $MVN --activate-profiles deploy nexus-staging:drop | |
# env: | |
# OSSRH_USR: ${{ secrets.OSSRH_USR }} | |
# OSSRH_PWD: ${{ secrets.OSSRH_PWD }} |