1+ name : Maven CI
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+ pull_request :
8+ branches :
9+ - main
10+
11+ jobs :
12+ build :
13+ runs-on : ubuntu-latest
14+
15+ steps :
16+ - name : Checkout code
17+ uses : actions/checkout@v4
18+
19+ - name : Set up JDK
20+ uses : actions/setup-java@v4
21+ with :
22+ java-version : ' 11'
23+ distribution : ' temurin'
24+
25+ - name : Install Maven
26+ run : sudo apt-get update && sudo apt-get install -y maven
27+
28+ - name : Configure Maven settings
29+ run : |
30+ mkdir -p ~/.m2
31+ echo "<settings>
32+ <servers>
33+ <server>
34+ <id>github</id>
35+ <username>${{ github.actor }}</username>
36+ <password>${{ secrets.GITHUB_TOKEN }}</password>
37+ </server>
38+ </servers>
39+ </settings>" > ~/.m2/settings.xml
40+
41+ - name : Build with Maven (skip tests)
42+ run : mvn -B clean package -DskipTests -Dmaven.test.skip=true --file pom.xml
43+
44+ - name : Upload build artifacts
45+ uses : actions/upload-artifact@v4
46+ with :
47+ name : build-artifacts
48+ path : target/*.jar
49+
50+ generate-docs :
51+ runs-on : ubuntu-latest
52+ needs : build
53+
54+ steps :
55+ - name : Checkout code
56+ uses : actions/checkout@v4
57+
58+ - name : Set up JDK
59+ uses : actions/setup-java@v4
60+ with :
61+ java-version : ' 11'
62+ distribution : ' temurin'
63+
64+ - name : Install Maven
65+ run : sudo apt-get update && sudo apt-get install -y maven
66+
67+ - name : Generate sources from Avro schema
68+ run : mvn clean install -DskipTests
69+
70+ - name : Generate Javadocs
71+ run : mvn javadoc:javadoc
72+
73+ - name : Upload Javadocs
74+ uses : actions/upload-artifact@v4
75+ with :
76+ name : javadocs
77+ path : target/site/apidocs/
78+
79+ deploy-docs :
80+ runs-on : ubuntu-latest
81+ needs : generate-docs
82+
83+ permissions :
84+ contents : write
85+
86+ steps :
87+ - name : Checkout code
88+ uses : actions/checkout@v4
89+
90+ - name : Configure Git
91+ run : |
92+ git config --global user.name "GitHub Actions"
93+ git config --global user.email "actions@github.com"
94+
95+ - name : Setup gh-pages branch
96+ run : |
97+ # Check if the gh-pages branch exists
98+ if git ls-remote --exit-code --heads origin gh-pages; then
99+ # If the branch exists, create a new orphan branch temporarily
100+ git checkout --orphan temp-gh-pages
101+ git rm -rf .
102+ else
103+ # If the branch does not exist, create it as an orphan branch
104+ git checkout --orphan gh-pages
105+ git rm -rf .
106+ fi
107+
108+ - name : Download Javadocs
109+ uses : actions/download-artifact@v4
110+ with :
111+ name : javadocs
112+ path : .
113+
114+ - name : Commit and push to gh-pages
115+ run : |
116+ git add .
117+ git commit -m "Deploy Javadocs for ${{ github.sha }}" || echo "No changes to commit"
118+
119+ if git ls-remote --exit-code --heads origin gh-pages; then
120+ git push --force origin HEAD:gh-pages
121+ else
122+ git push origin HEAD:gh-pages
123+ fi
124+
125+ deploy-package :
126+ runs-on : ubuntu-latest
127+ needs : build
128+
129+ permissions :
130+ packages : write
131+
132+ steps :
133+ - name : Checkout code
134+ uses : actions/checkout@v4
135+
136+ - name : Set up JDK
137+ uses : actions/setup-java@v4
138+ with :
139+ java-version : ' 11'
140+ distribution : ' temurin'
141+
142+ - name : Install Maven
143+ run : sudo apt-get update && sudo apt-get install -y maven
144+
145+ - name : Clear local Maven repository
146+ run : rm -rf ~/.m2/repository/com/codedstreams/
147+
148+ - name : Publish to GitHub Packages
149+ run : mvn deploy
150+ env :
151+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments