-
-
Notifications
You must be signed in to change notification settings - Fork 1
170 lines (170 loc) · 6.44 KB
/
java-build.yaml
File metadata and controls
170 lines (170 loc) · 6.44 KB
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: Java ☕🦆🌞 Test 🦂 Build 🧱 Release 🚰 and Publish 📦
on:
push:
branches:
- 'main'
paths:
- 'java/**'
- '!java/**.md'
- '!java/.vscode/**'
- '.github/workflows/java-*'
workflow_dispatch:
permissions: {}
defaults:
run:
shell: bash
working-directory: java
jobs:
context:
name: GitHub 🐱👤 Context 📑
uses: ./.github/workflows/github-context.yaml
test:
name: Java ☕🦆🌞 Test 🦂
permissions:
actions: read
contents: read
security-events: write
uses: ./.github/workflows/java-test.yaml
workflow-conditions:
name: 🛑🛑🛑 Stop builds that didn't change the release version 🛑🛑🛑
runs-on: ubuntu-latest
outputs:
version-file-changed: ${{ steps.version-file-check.outputs.version-file-changed }}
version-tag-exists: ${{ steps.version-tag-exists.outputs.version-tag-exists }}
steps:
- name: 🏁 Checkout
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
fetch-depth: 2
- name: Check if version files changed
id: version-file-check
run: |
export VERSION_FILE="java/pom.xml"
[ "$(git diff HEAD^1.. --name-only | grep -e "^$VERSION_FILE$")" == "$VERSION_FILE" ] && echo "version-file-changed=${{toJSON(true)}}" >> $GITHUB_OUTPUT || echo "version-file-changed=${{toJSON(false)}}" >> $GITHUB_OUTPUT
- name: Notify on version-file-check
run: echo "::Notice::version-file-changed is ${{ fromJSON(steps.version-file-check.outputs.version-file-changed) }}"
- name: Check if version specified in version file has not released.
id: version-tag-exists
run: |
git fetch --tags
export VER=$(mvn help:evaluate -Dexpression="project.version" -q -DforceStdout)
[ -z "$(git tag -l "java-v$VER")" ] && echo "version-tag-exists=${{toJSON(false)}}" >> $GITHUB_OUTPUT || echo "version-tag-exists=${{toJSON(true)}}" >> $GITHUB_OUTPUT
- name: Notify on version-tag-exists
run: echo "::Notice::version-tag-exists is ${{ fromJSON(steps.version-tag-exists.outputs.version-tag-exists) }}"
# Now any step that should only run on the version change can use
# "needs: [workflow-conditions]" Which will yield the condition checks below.
# We want to "release" automatically if "version-file-changed" is true on push
# Or manually if workflow_dispatch. BOTH need "version-tag-exists" is false.
build:
name: Java ☕🦆🌞 Build 🧱
needs: [test, workflow-conditions]
if: >-
${{ ((fromJSON(needs.workflow-conditions.outputs.version-file-changed) == true && github.event_name == 'push') ||
github.event_name == 'workflow_dispatch') && fromJSON(needs.workflow-conditions.outputs.version-tag-exists) == false }}
runs-on: ubuntu-latest
steps:
- name: 🏁 Checkout
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: ☕🦆🌞 Set up Java
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
with:
distribution: 'adopt'
java-version: '11'
architecture: x64
cache: maven
- name: 🏺 Build jar and source
run: make build_noninteractive
- name: 🆙 Upload jar
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: Package
path: java/target/*.jar
if-no-files-found: error
release:
name: Java ☕🦆🌞 Release 🚰
needs: [build]
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: 🏁 Checkout
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: 🆒 Download dists
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
with:
name: Package
path: java/target
- name: 🚰 Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
export VER=$(mvn help:evaluate -Dexpression="project.version" -q -DforceStdout)
gh release create java-v$VER --generate-notes -t "Java: Version $VER"
publish:
name: Java ☕🦆🌞 Publish 📦
needs: [release]
permissions:
packages: write
runs-on: ubuntu-latest
steps:
- name: 🏁 Checkout
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: ☕🦆🌞 Set up Java; for publishing to Maven Central Repository
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
with:
java-version: '11'
distribution: 'adopt'
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: 📦 Publish to the Maven Central Repository
run: make deploy_noninteractive_ossrh
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
- name: ☕🦆🌞 Set up Java; for publishing to GitHub Packages
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
with:
java-version: '11'
distribution: 'adopt'
server-id: github
- name: 📦 Publish to GitHub Packages
run: make deploy_noninteractive_github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
docs:
name: Java ☕🦆🌞 Docs 📄
needs: [release, publish]
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: 🏁 Checkout
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: ☕🦆🌞 Set up Java
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
with:
distribution: 'adopt'
java-version: '11'
architecture: x64
cache: maven
- name: 📄 Docs
run: |
git config --global user.email "actions@github.com"
git config --global user.name "Github Actions"
make docs_deploy SHORTSHA=$(git rev-parse --short HEAD) PASSWORD=$GITHUB_TOKEN
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
docs-merge:
name: GitHub 🐱👤 Pages 📄 Merger 🧬
needs: [docs]
permissions:
contents: write
pages: write
id-token: write
uses: ./.github/workflows/github-pages.yaml
with:
merge_from: 'gh-pages-java'