Skip to content

Commit eabe16a

Browse files
add version
1 parent c9eefba commit eabe16a

File tree

1 file changed

+87
-18
lines changed

1 file changed

+87
-18
lines changed

.github/workflows/release.yaml

Lines changed: 87 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,101 @@
1-
name: Trigger Jenkins Job
1+
name: Maven Deploy and Release
22

33
on:
44
push:
55
branches:
6+
- github-action
67
- latest
78
paths:
89
- superstream-clients/pom.xml
910

1011
jobs:
11-
trigger-jenkins:
12-
runs-on: self-hosted
12+
deploy:
13+
runs-on: ubuntu-latest
14+
15+
env:
16+
HOME: /home/runner
1317

1418
steps:
15-
- name: Checkout code
16-
uses: actions/checkout@v3
19+
- name: Determine deployment type
20+
id: deployment
21+
run: |
22+
# Automatic deployment based on branch
23+
if [ "${{ github.ref }}" == "refs/heads/latest" ]; then
24+
echo "type=production" >> $GITHUB_OUTPUT
25+
echo "branch=latest" >> $GITHUB_OUTPUT
26+
else
27+
echo "type=beta" >> $GITHUB_OUTPUT
28+
echo "branch=github-action" >> $GITHUB_OUTPUT
29+
fi
30+
31+
- name: Checkout
32+
uses: actions/checkout@v4
33+
with:
34+
fetch-depth: 0
1735

18-
- name: Trigger Jenkins Job
36+
- name: Set up JDK 17
37+
uses: actions/setup-java@v4
38+
with:
39+
java-version: '17'
40+
distribution: 'temurin'
41+
cache: 'maven'
42+
43+
- name: Import GPG key
1944
env:
20-
JENKINS_TOKEN: ${{ secrets.JENKINS_TOKEN }}
45+
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
46+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
2147
run: |
22-
HTTP_STATUS=$(curl -w "%{http_code}" -o /tmp/jenkins_response.txt -f -X POST \
23-
"https://jenkins.superstream.ai/job/DevOps/job/Superstream/job/SDK/job/superstream-clients-java/buildWithParameters?DEPLOYMENT_TYPE=production" \
24-
--user "[email protected]:$JENKINS_TOKEN")
25-
26-
if [ $? -ne 0 ] || [ "$HTTP_STATUS" -ne 201 ] && [ "$HTTP_STATUS" -ne 200 ]; then
27-
echo "Jenkins trigger failed with HTTP status: $HTTP_STATUS"
28-
cat /tmp/jenkins_response.txt
29-
exit 1
30-
fi
31-
32-
echo "Successfully triggered Jenkins build (HTTP $HTTP_STATUS)"
48+
echo "$GPG_PRIVATE_KEY" | gpg --batch --yes --passphrase "$GPG_PASSPHRASE" --import
49+
echo "allow-loopback-pinentry" > ~/.gnupg/gpg-agent.conf
50+
gpg --list-secret-keys --keyid-format LONG
51+
echo "D64C041FB68170463BE78AD7C4E3F1A8A5F0A659:6:" | gpg --import-ownertrust
52+
53+
- name: Read Version from pom.xml
54+
id: version
55+
working-directory: superstream-clients
56+
run: |
57+
POM_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
58+
echo "Original version from pom.xml: $POM_VERSION"
59+
echo "base=$POM_VERSION" >> $GITHUB_OUTPUT
60+
61+
- name: Create Maven Settings
62+
run: |
63+
mkdir -p ~/.m2
64+
echo "${{ secrets.MAVEN_SETTINGS }}" > ~/.m2/settings.xml
65+
66+
- name: Build and Deploy Beta
67+
if: steps.deployment.outputs.type == 'beta'
68+
working-directory: superstream-clients
69+
env:
70+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
71+
run: |
72+
mvn -B package --file pom.xml
73+
BETA_VERSION="${{ steps.version.outputs.base }}-beta"
74+
echo "Setting beta version: $BETA_VERSION"
75+
mvn versions:set -DnewVersion=$BETA_VERSION
76+
mvn -s ~/.m2/settings.xml deploy -DautoPublish=true -Dgpg.passphrase="$GPG_PASSPHRASE"
77+
78+
- name: Build and Deploy Production
79+
if: steps.deployment.outputs.type == 'production'
80+
working-directory: superstream-clients
81+
env:
82+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
83+
run: |
84+
mvn -B package --file pom.xml
85+
mvn -s ~/.m2/settings.xml deploy -DautoPublish=true -Dgpg.passphrase="$GPG_PASSPHRASE"
86+
87+
- name: Create GitHub Release
88+
if: steps.deployment.outputs.type == 'production'
89+
env:
90+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
91+
run: |
92+
VERSION="${{ steps.version.outputs.base }}"
93+
git config user.name "github-actions[bot]"
94+
git config user.email "github-actions[bot]@users.noreply.github.com"
95+
git checkout -b $VERSION
96+
git push origin $VERSION
97+
cd superstream-clients
98+
gh release create $VERSION target/superstream-clients-${VERSION}.jar --generate-notes
99+
100+
101+

0 commit comments

Comments
 (0)