Skip to content

Commit 5fa8d65

Browse files
committed
Add build GitHub Action
1 parent f22f5ae commit 5fa8d65

2 files changed

Lines changed: 298 additions & 1 deletion

File tree

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