Skip to content

Commit c673d6a

Browse files
authored
Create build-main.yml
1 parent fdb8a35 commit c673d6a

File tree

1 file changed

+113
-0
lines changed

1 file changed

+113
-0
lines changed

.github/workflows/build-main.yml

+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: build main
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
build:
10+
strategy:
11+
matrix:
12+
os: [ubuntu-latest, windows-latest]
13+
14+
runs-on: ${{ matrix.os }}
15+
steps:
16+
17+
- uses: actions/checkout@v3
18+
19+
- name: Set up JDK 8
20+
uses: actions/setup-java@v3
21+
with:
22+
distribution: 'temurin'
23+
java-version: '8'
24+
25+
- name: Cache local Maven repository
26+
uses: actions/[email protected]
27+
env:
28+
cache-name: cache-mvn
29+
with:
30+
path: ~/.m2/repository
31+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
32+
restore-keys: |
33+
${{ runner.os }}-build-${{ env.cache-name }}-
34+
${{ runner.os }}-build-
35+
${{ runner.os }}-
36+
37+
- name: Cache node modules
38+
uses: actions/cache@v2
39+
env:
40+
cache-name: cache-node-modules
41+
with:
42+
path: ~/.npm
43+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
44+
restore-keys: |
45+
${{ runner.os }}-build-${{ env.cache-name }}-
46+
47+
# since we also build on Windows Powershell, we need to add a space between -D maven.javadoc.skip=true
48+
# otherwise the build will fail https://stackoverflow.com/questions/38051787/maven-javadoc-skip-true-throws-an-error
49+
- name: Build with Maven
50+
run: |
51+
mvn -B spring-javaformat:apply --no-transfer-progress
52+
mvn -B verify -P coverage --no-transfer-progress -D maven.javadoc.skip=true
53+
54+
- uses: codecov/codecov-action@v2
55+
with:
56+
files: "'*/jacoco.xml'"
57+
58+
publish-snapshot:
59+
needs: build
60+
runs-on: ubuntu-latest
61+
62+
steps:
63+
- uses: actions/checkout@v3
64+
65+
- name: Set up settings.xml for GitHub Packages
66+
uses: actions/setup-java@v3
67+
with:
68+
distribution: 'temurin'
69+
java-version: '8'
70+
71+
- name: Cache local Maven repository
72+
uses: actions/[email protected]
73+
env:
74+
cache-name: cache-mvn
75+
with:
76+
path: ~/.m2/repository
77+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
78+
restore-keys: |
79+
${{ runner.os }}-build-${{ env.cache-name }}-
80+
${{ runner.os }}-build-
81+
${{ runner.os }}-
82+
83+
- name: Cache node modules
84+
uses: actions/cache@v2
85+
env:
86+
cache-name: cache-node-modules
87+
with:
88+
path: ~/.npm
89+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
90+
restore-keys: |
91+
${{ runner.os }}-build-${{ env.cache-name }}-
92+
${{ runner.os }}-build-
93+
${{ runner.os }}-
94+
95+
- name: Publish SNAPSHOT version to GitHub Packages (we can skip tests, since we only deploy, if the build workflow succeeded)
96+
run: mvn -B --no-transfer-progress deploy -DskipTests
97+
env:
98+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
99+
100+
- name: Extract Maven project version for Asciidoc GitHub Pages directory naming
101+
run: echo ::set-output name=version::$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
102+
id: project
103+
104+
- name: Show extracted Maven project version
105+
run: echo ${{ steps.project.outputs.version }}
106+
107+
- name: Deploy Asciidoc docs output to GitHub Pages
108+
uses: JamesIves/[email protected]
109+
with:
110+
branch: gh-pages # The branch the action should deploy to.
111+
folder: batch-web-spring-boot-docs/target/generated-docs # The folder the action should deploy.
112+
target-folder: ${{ steps.project.outputs.version }}
113+
clean: true # Automatically remove deleted files from the deploy branch

0 commit comments

Comments
 (0)