-
Notifications
You must be signed in to change notification settings - Fork 532
121 lines (105 loc) · 4.55 KB
/
deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support documentation.
# This workflow will download a prebuilt Java version, install dependencies, build and deploy/publish a new release
# For more information see: https://docs.github.com/en/actions/guides/building-and-testing-java-with-maven
name: Deploy and Publish
on:
workflow_run:
workflows: ["Build and Test"]
branches: [ master ]
types:
- completed
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
deploy:
if: "!contains(github.event.head_commit.message, 'skip ci')"
name: Deploy and Publish
env:
MVN_ARGS: '-B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Set up Java
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
- name: Build Java package
run: mvn verify -fae -DskipITs -Dskip.unit.tests $MVN_ARGS
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 20
- name: Install Semantic Release dependencies
run: |
pip3 install --user bump2version
npm install -g semantic-release
npm install -g @semantic-release/changelog
npm install -g @semantic-release/exec
npm install -g @semantic-release/git
npm install -g @semantic-release/github
npm install -g @semantic-release/commit-analyzer
npm install -g @semantic-release/release-notes-generator
- name: Check if semantic release generated a release
id: is_new_release
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
echo ::set-output name=IS_NEW_RELEASE::$(npx semantic-release --dry-run | grep -c -i "Published release")
echo "The full TAG - ${{ github.ref }}"
- name: Get the nextRelease.version from semantic release
if: ${{ steps.is_new_release.outputs.IS_NEW_RELEASE == '1' }}
id: next_release
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: echo ::set-output name=NEXT_RELEASE::$(npx semantic-release --dry-run | grep -oP "Published release \K[0-9]+\.[0-9]+\.[0-9]+")
- name: Publish to Git Releases and Tags
if: ${{ steps.is_new_release.outputs.IS_NEW_RELEASE == '1' }}
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npx semantic-release # --dry-run --branches 9662_addcheck
- name: Publish to Maven Central
env:
GHA_TAG: "refs/tags/v14.0.0" # for setMavenVersion_gha
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} # for .travis.settings.xml
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
GPG_KEYNAME: ${{ secrets.SIGNING_KEY }}
GPG_PASSPHRASE: ${{ secrets.SIGNING_PASSWORD }}
SIGNING_PASSPHRASE: ${{ secrets.SIGNING_PASSPHRASE }} # for setupSigning_gha
run: |
echo "The NEXT_RELEASE - ${{ steps.next_release.outputs.NEXT_RELEASE }}"
echo -e "\n\033[0;35mCommand: setupSigning"
build/setupSigning_gha.sh
echo -e "\n\033[0;35mCommand: setMavenVersion"
build/setMavenVersion_gha.sh
echo -e "\n\033[0;35mCommand: mvn deploy"
mvn deploy --settings build/.travis.settings.xml -DskipITs -Dskip.unit.tests -P central $MVN_ARGS
- name: Publish Java docs
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
GHA_REPO_SLUG: ${{ github.repository }}
GHA_BRANCH: ${{ github.ref }} # non PR only need to get last part
GHA_PULL_REQUEST: ${{ github.event.number }}
GHA_BUILD_NUMBER: ${{ github.run_number }}
GHA_JOB_NUMBER: ${{ github.job_number }}
GHA_COMMIT: ${{ github.sha }}
GHA_TAG: "refs/tags/v14.0.0" # for setMavenVersion_gha
run: |
build/setMavenVersion_gha.sh
mvn clean javadoc:aggregate $MVN_ARGS
build/publish_gha.sh
- name: SKIP - Publish/Deploy to Git and Maven Central
if: ${{ steps.is_new_release.outputs.IS_NEW_RELEASE == '0' }}
run: |
echo -e "\n\033[0;35mCommand: Skipping the deployment because semantic release has determined there are no relevant changes that warrent a new release.\n"