Skip to content

Commit dbbce17

Browse files
committed
Add build GitHub Action
1 parent f22f5ae commit dbbce17

2 files changed

Lines changed: 293 additions & 1 deletion

File tree

Lines changed: 292 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,292 @@
1+
name: Build and Publish DataStax Netty to GitHub Packages
2+
3+
on:
4+
# Allows manual trigger from the Actions tab
5+
workflow_dispatch:
6+
7+
# Trigger on version tags
8+
push:
9+
branches:
10+
- dse-netty-4.1.132
11+
tags:
12+
- '*.dse'
13+
- 'dse-netty-*'
14+
15+
permissions:
16+
contents: read
17+
packages: write
18+
19+
env:
20+
MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryhandler.count=5 -Dmaven.wagon.httpconnectionManager.ttlSeconds=240
21+
22+
# Cancel running jobs when a new push happens to the same branch/tag
23+
concurrency:
24+
group: ${{ github.workflow }}-${{ github.ref }}
25+
cancel-in-progress: true
26+
27+
jobs:
28+
# Stage 1: Build full Netty library on Linux x64
29+
build-linux-x64:
30+
runs-on: ubuntu-latest
31+
name: Build Linux x86_64 (Full)
32+
33+
steps:
34+
- uses: actions/checkout@v4
35+
36+
# Cache .m2/repository
37+
- name: Cache local Maven repository
38+
uses: actions/cache@v4
39+
continue-on-error: true
40+
with:
41+
path: ~/.m2/repository
42+
key: cache-maven-${{ hashFiles('**/pom.xml') }}
43+
restore-keys: |
44+
cache-maven-${{ hashFiles('**/pom.xml') }}
45+
cache-maven-
46+
47+
# Configure Maven settings for GitHub Packages
48+
- name: Configure Maven settings
49+
uses: s4u/maven-settings-action@v3.0.0
50+
with:
51+
servers: |
52+
[{
53+
"id": "github",
54+
"username": "${{ github.actor }}",
55+
"password": "${{ secrets.GITHUB_TOKEN }}"
56+
}]
57+
58+
- name: Create local staging directory
59+
run: mkdir -p ~/local-staging
60+
61+
- name: Build docker image
62+
run: docker build -f docker/Dockerfile-netty-centos6 -t netty-centos6 .
63+
64+
- name: Build and stage artifacts
65+
run: |
66+
docker run -t \
67+
-v ~/.m2:/root/.m2:Z \
68+
-v ~/local-staging:/root/local-staging:Z \
69+
-v $(pwd):/code:Z \
70+
-w /code \
71+
--entrypoint="" \
72+
netty-centos6 \
73+
bash -ic "./mvnw -B clean install -DskipTests ; find /root/.m2/ ; ./mvnw -B deploy -DaltDeploymentRepository=local::file:/root/local-staging ; ls -Fla /root/local-staging/"
74+
ls -Fla ~/local-staging/
75+
find ~/.m2/
76+
77+
- name: Upload local staging directory
78+
uses: actions/upload-artifact@v4
79+
with:
80+
name: linux-x86_64-local-staging
81+
path: ~/local-staging
82+
if-no-files-found: error
83+
include-hidden-files: true
84+
85+
# Stage 2: Build macOS Intel x86_64 native libraries
86+
build-macos-intel:
87+
runs-on: macos-15-intel
88+
name: Build macOS x86_64 (Native Libraries)
89+
needs: [build-linux-x64]
90+
91+
steps:
92+
- uses: actions/checkout@v4
93+
94+
- name: Set up JDK 8
95+
uses: actions/setup-java@v4
96+
with:
97+
distribution: 'zulu'
98+
java-version: '8'
99+
100+
# Cache .m2/repository
101+
- name: Cache local Maven repository
102+
uses: actions/cache@v4
103+
continue-on-error: true
104+
with:
105+
path: ~/.m2/repository
106+
key: cache-maven-macos-intel-${{ hashFiles('**/pom.xml') }}
107+
restore-keys: |
108+
cache-maven-macos-intel-${{ hashFiles('**/pom.xml') }}
109+
cache-maven-
110+
111+
- name: Install tools via brew
112+
run: brew bundle
113+
continue-on-error: true
114+
115+
- name: Create local staging directory
116+
run: mkdir -p ~/local-staging
117+
118+
- name: Build and stage native libraries
119+
run: |
120+
./mvnw -B -U \
121+
-pl resolver-dns-native-macos,transport-native-unix-common,transport-native-kqueue \
122+
deploy \
123+
-DskipTests \
124+
-DserverId=github \
125+
-DaltDeploymentRepository="artifactory::default::https://maven.pkg.github.com/riptano/netty"
126+
127+
- name: Upload local staging directory
128+
uses: actions/upload-artifact@v4
129+
with:
130+
name: macos-x86_64-local-staging
131+
path: ~/local-staging
132+
if-no-files-found: error
133+
include-hidden-files: true
134+
135+
# Stage 3: Build macOS ARM aarch64 native libraries
136+
build-macos-arm:
137+
runs-on: macos-15
138+
name: Build macOS aarch64 (Native Libraries)
139+
needs: [build-linux-x64]
140+
141+
steps:
142+
- uses: actions/checkout@v4
143+
144+
- name: Set up JDK 8
145+
uses: actions/setup-java@v4
146+
with:
147+
distribution: 'zulu'
148+
java-version: '8'
149+
150+
# Cache .m2/repository
151+
- name: Cache local Maven repository
152+
uses: actions/cache@v4
153+
continue-on-error: true
154+
with:
155+
path: ~/.m2/repository
156+
key: cache-maven-macos-arm-${{ hashFiles('**/pom.xml') }}
157+
restore-keys: |
158+
cache-maven-macos-arm-${{ hashFiles('**/pom.xml') }}
159+
cache-maven-
160+
161+
- name: Install tools via brew
162+
run: brew bundle
163+
continue-on-error: true
164+
165+
- name: Create local staging directory
166+
run: mkdir -p ~/local-staging
167+
168+
- name: Build and stage native libraries
169+
run: |
170+
./mvnw -B -ntp clean package org.sonatype.plugins:nexus-staging-maven-plugin:deploy \
171+
-pl resolver-dns-native-macos,transport-native-unix-common,transport-native-kqueue \
172+
-DserverId=github \
173+
-DaltStagingDirectory=$HOME/local-staging \
174+
-DskipRemoteStaging=true \
175+
-DskipTests=true
176+
177+
- name: Upload local staging directory
178+
uses: actions/upload-artifact@v4
179+
with:
180+
name: macos-aarch64-local-staging
181+
path: ~/local-staging
182+
if-no-files-found: error
183+
include-hidden-files: true
184+
185+
# Stage 4: Merge artifacts and publish to GitHub Packages
186+
publish-to-github-packages:
187+
runs-on: ubuntu-latest
188+
name: Merge and Publish to GitHub Packages
189+
needs: [build-linux-x64, build-macos-intel, build-macos-arm]
190+
191+
steps:
192+
- uses: actions/checkout@v4
193+
194+
- name: Set up JDK 8
195+
uses: actions/setup-java@v4
196+
with:
197+
distribution: 'zulu'
198+
java-version: '8'
199+
200+
# Cache .m2/repository
201+
- name: Cache local Maven repository
202+
uses: actions/cache@v4
203+
continue-on-error: true
204+
with:
205+
path: ~/.m2/repository
206+
key: cache-maven-${{ hashFiles('**/pom.xml') }}
207+
restore-keys: |
208+
cache-maven-${{ hashFiles('**/pom.xml') }}
209+
cache-maven-
210+
211+
# Configure Maven settings for GitHub Packages
212+
- name: Configure Maven settings
213+
uses: s4u/maven-settings-action@v3.0.0
214+
with:
215+
servers: |
216+
[{
217+
"id": "github",
218+
"username": "${{ github.actor }}",
219+
"password": "${{ secrets.GITHUB_TOKEN }}"
220+
}]
221+
222+
# Setup environment variables
223+
- name: Prepare environment variables
224+
run: |
225+
echo "LOCAL_STAGING_DIR=$HOME/local-staging" >> $GITHUB_ENV
226+
227+
# Download all staging artifacts
228+
- name: Download Linux x86_64 staging directory
229+
uses: actions/download-artifact@v4
230+
with:
231+
name: linux-x86_64-local-staging
232+
path: ~/linux-x86_64-local-staging
233+
234+
- name: Download macOS x86_64 staging directory
235+
uses: actions/download-artifact@v4
236+
with:
237+
name: macos-x86_64-local-staging
238+
path: ~/macos-x86_64-local-staging
239+
240+
- name: Download macOS aarch64 staging directory
241+
uses: actions/download-artifact@v4
242+
with:
243+
name: macos-aarch64-local-staging
244+
path: ~/macos-aarch64-local-staging
245+
246+
# Install artifacts to local Maven repository
247+
- name: Copy build artifacts to local maven repository
248+
run: |
249+
bash ./.github/scripts/local_staging_install_release.sh \
250+
~/.m2/repository \
251+
~/linux-x86_64-local-staging \
252+
~/macos-x86_64-local-staging \
253+
~/macos-aarch64-local-staging
254+
255+
# Generate netty-all and deploy to local staging
256+
- name: Generate netty-all and deploy to local staging
257+
run: |
258+
mkdir -p ~/all-local-staging
259+
./mvnw -B --file pom.xml -Pnative-dependencies -pl all \
260+
clean package org.sonatype.plugins:nexus-staging-maven-plugin:deploy \
261+
-DaltStagingDirectory=$HOME/all-local-staging \
262+
-DskipRemoteStaging=true \
263+
-DskipTests=true
264+
265+
# Merge all staging repositories
266+
- name: Merge staging repositories
267+
run: |
268+
bash ./.github/scripts/local_staging_install_release.sh \
269+
~/local-staging \
270+
~/linux-x86_64-local-staging \
271+
~/macos-x86_64-local-staging \
272+
~/macos-aarch64-local-staging \
273+
~/all-local-staging
274+
275+
# Deploy to GitHub Packages
276+
- name: Deploy to GitHub Packages
277+
run: |
278+
./mvnw -B --file pom.xml \
279+
org.sonatype.plugins:nexus-staging-maven-plugin:deploy-staged \
280+
-DaltStagingDirectory=$HOME/local-staging \
281+
-DserverId=github \
282+
-DnexusUrl=https://maven.pkg.github.com/${{ github.repository }} \
283+
-DrepositoryId=github
284+
285+
- name: Upload merged staging directory (for debugging)
286+
uses: actions/upload-artifact@v4
287+
if: always()
288+
with:
289+
name: merged-local-staging
290+
path: ~/local-staging
291+
if-no-files-found: warn
292+
include-hidden-files: true

docker-datastax-release.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ if ! which docker > /dev/null ; then
1212
fi
1313

1414
sudo docker build -f docker/Dockerfile-netty-centos6 -t netty-centos6 .
15-
sudo docker run -t --network host -v ~/.m2:/root/.m2:Z -v ~/.ssh:/root/.ssh:Z -v ~/.gnupg:/root/.gnupg:Z -v `pwd`:/code:Z -w /code --entrypoint="" netty-centos6 bash -ic "./mvnw -B clean deploy -Partifactory -DskipTests -DaltDeploymentRepository=\"artifactory::default::https://repo.aws.dsinternal.org/artifactory/datastax-releases-local\""
15+
sudo docker run -t --network host -v ~/.m2:/root/.m2:Z -v ~/.ssh:/root/.ssh:Z -v ~/.gnupg:/root/.gnupg:Z -v `pwd`:/code:Z -w /code --entrypoint="" netty-centos6 bash -ic "./mvnw -B clean deploy -Partifactory -DskipTests -DaltDeploymentRepository=\"artifactory::default::https://maven.pkg.github.com/riptano/netty\""

0 commit comments

Comments
 (0)