Skip to content

Commit 4dadb91

Browse files
Merge pull request #134 from skyflowapi/SK-1753-internal-release-workflow
SK-1753 internal release workflow
2 parents 6a9e583 + 5c48271 commit 4dadb91

4 files changed

Lines changed: 153 additions & 24 deletions

File tree

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Publish package to the JFROG Artifactory
2+
on:
3+
push:
4+
tags: '*.*.*'
5+
paths-ignore:
6+
- "pom.xml"
7+
- "*.md"
8+
branches:
9+
- release/*
10+
11+
jobs:
12+
publish:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
with:
17+
ref: ${{ github.ref_name }}
18+
fetch-depth: 0
19+
20+
- name: Set up Jfrog artifactory
21+
uses: actions/setup-java@v1
22+
with:
23+
java-version: '1.8'
24+
distribution: 'adopt'
25+
server-id: central
26+
server-username: JFROG_USERNAME
27+
server-password: JFROG_PASSWORD
28+
gpg-private-key: ${{ secrets.JFROG_GPG_KEY }} # Value of the GPG private key to import
29+
gpg-passphrase: JFROG_GPG_PASSPHRASE # env variable for GPG private key passphrase
30+
31+
- name: Get Previous tag
32+
id: previoustag
33+
uses: WyriHaximus/github-action-get-previous-tag@v1
34+
with:
35+
fallback: 1.0.0
36+
37+
- name: Bump Version
38+
run: |
39+
chmod +x ./scripts/bump_version.sh
40+
./scripts/bump_version.sh "${{ steps.previoustag.outputs.tag }}" "$(git rev-parse --short "$GITHUB_SHA")"
41+
42+
- name: Commit changes
43+
run: |
44+
git config user.name ${{ github.actor }}
45+
git config user.email ${{ github.actor }}@users.noreply.github.com
46+
git add pom.xml
47+
git commit -m "[AUTOMATED] Private Release ${{ steps.previoustag.outputs.tag }}-dev.$(git rev-parse --short $GITHUB_SHA)"
48+
git push origin -f
49+
50+
- name: Create env
51+
id: create-env
52+
run: |
53+
touch .env
54+
echo SKYFLOW_CREDENTIALS=${{ secrets.SKYFLOW_CREDENTIALS }} >> .env
55+
echo TEST_EXPIRED_TOKEN=${{ secrets.TEST_EXPIRED_TOKEN }} >> .env
56+
57+
- name: Create credentials json
58+
id: create-json
59+
uses: jsdaniell/create-json@1.1.2
60+
with:
61+
name: "credentials.json"
62+
json: ${{ secrets.TEST_CREDENTIALS_FILE_STRING }}
63+
64+
- name: Publish package to Jfrog Artifactory
65+
run: mvn clean deploy -P jfrog
66+
env:
67+
JFROG_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
68+
JFROG_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
69+
JFROG_GPG_PASSPHRASE: ${{ secrets.JFROG_GPG_PASSPHRASE }}

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
json: ${{ secrets.TEST_CREDENTIALS_FILE_STRING }}
2727

2828
- name: Publish package to Maven Central
29-
run: mvn --batch-mode deploy
29+
run: mvn --batch-mode deploy -P maven-central
3030
env:
3131
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
3232
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}

pom.xml

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,6 @@
4444
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
4545
</properties>
4646

47-
<distributionManagement>
48-
<snapshotRepository>
49-
<id>ossrh</id>
50-
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
51-
</snapshotRepository>
52-
<repository>
53-
<id>ossrh</id>
54-
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2</url>
55-
</repository>
56-
</distributionManagement>
57-
5847
<dependencies>
5948
<!-- newly added v2 dependencies -->
6049
<dependency>
@@ -132,17 +121,17 @@
132121

133122
<build>
134123
<plugins>
135-
<plugin>
136-
<groupId>org.sonatype.plugins</groupId>
137-
<artifactId>nexus-staging-maven-plugin</artifactId>
138-
<version>1.6.7</version>
139-
<extensions>true</extensions>
140-
<configuration>
141-
<serverId>ossrh</serverId>
142-
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
143-
<autoReleaseAfterClose>true</autoReleaseAfterClose>
144-
</configuration>
145-
</plugin>
124+
<!-- <plugin>-->
125+
<!-- <groupId>org.sonatype.plugins</groupId>-->
126+
<!-- <artifactId>nexus-staging-maven-plugin</artifactId>-->
127+
<!-- <version>1.6.7</version>-->
128+
<!-- <extensions>true</extensions>-->
129+
<!-- <configuration>-->
130+
<!-- <serverId>ossrh</serverId>-->
131+
<!-- <nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>-->
132+
<!-- <autoReleaseAfterClose>true</autoReleaseAfterClose>-->
133+
<!-- </configuration>-->
134+
<!-- </plugin>-->
146135
<plugin>
147136
<groupId>org.apache.maven.plugins</groupId>
148137
<artifactId>maven-source-plugin</artifactId>
@@ -253,4 +242,35 @@
253242
</repository>
254243
</repositories>
255244

256-
</project>
245+
<profiles>
246+
<profile>
247+
<id>maven-central</id>
248+
<distributionManagement>
249+
<repository>
250+
<id>ossrh</id>
251+
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2</url>
252+
</repository>
253+
<snapshotRepository>
254+
<id>ossrh</id>
255+
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
256+
</snapshotRepository>
257+
</distributionManagement>
258+
</profile>
259+
<profile>
260+
<id>jfrog</id>
261+
<distributionManagement>
262+
<repository>
263+
<id>central</id>
264+
<name>prekarilabs.jfrog.io-releases</name>
265+
<url>https://prekarilabs.jfrog.io/artifactory/skyflow-java</url>
266+
</repository>
267+
<snapshotRepository>
268+
<id>snapshots</id>
269+
<name>prekarilabs.jfrog.io-snapshots</name>
270+
<url>https://prekarilabs.jfrog.io/artifactory/skyflow-java</url>
271+
</snapshotRepository>
272+
</distributionManagement>
273+
</profile>
274+
</profiles>
275+
276+
</project>

scripts/bump_version.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Input Arguments
2+
Version=$1
3+
CommitHash=$2
4+
PomFile="$GITHUB_WORKSPACE/pom.xml"
5+
6+
if [ -z "$Version" ]; then
7+
echo "Error: Version argument is required."
8+
exit 1
9+
fi
10+
11+
# Update only the main project's <version>
12+
if [ -z "$CommitHash" ]; then
13+
echo "Bumping main project version to $Version"
14+
15+
awk -v version="$Version" '
16+
BEGIN { updated = 0 }
17+
/<version>/ && updated == 0 {
18+
sub(/<version>.*<\/version>/, "<version>" version "</version>")
19+
updated = 1
20+
}
21+
{ print }
22+
' "$PomFile" > tempfile && cat tempfile > "$PomFile" && rm -f tempfile
23+
24+
echo "--------------------------"
25+
echo "Done. Main project version now at $Version"
26+
else
27+
echo "Bumping main project version to $Version-dev-$CommitHash"
28+
29+
awk -v version="$Version-dev.$CommitHash" '
30+
BEGIN { updated = 0 }
31+
/<version>/ && updated == 0 {
32+
sub(/<version>.*<\/version>/, "<version>" version "</version>")
33+
updated = 1
34+
}
35+
{ print }
36+
' "$PomFile" > tempfile && cat tempfile > "$PomFile" && rm -f tempfile
37+
38+
echo "--------------------------"
39+
echo "Done. Main project version now at $Version-dev.$CommitHash"
40+
fi

0 commit comments

Comments
 (0)