Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/internal-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Publish package to the JFROG Artifactory
on:
push:
tags: '*.*.*'
paths-ignore:
- "pom.xml"
- "*.md"
branches:
- release/*

jobs:
build-and-deploy:
uses: ./.github/workflows/shared-build-and-deploy.yml
with:
ref: ${{ github.ref_name }}
is-internal: true
server-id: central
profile: jfrog
secrets:
server-username: ${{ secrets.ARTIFACTORY_USERNAME }}
server-password: ${{ secrets.ARTIFACTORY_PASSWORD }}
gpg-key: ${{ secrets.JFROG_GPG_KEY }}
gpg-passphrase: ${{ secrets.JFROG_GPG_PASSPHRASE }}
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- name: Check JIRA ID
uses: gsactions/commit-message-checker@v1
with:
pattern: '\[?[A-Z]{1,5}-[1-9][0-9]*.+$'
pattern: '(\[?[A-Z]{1,5}-[1-9][0-9]*)|(\[AUTOMATED\])|(Merge)|(Release).+$'
flags: 'gm'
excludeDescription: 'true'
checkAllCommitMessages: 'true'
Expand Down
40 changes: 12 additions & 28 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,15 @@ on:
push:
tags: '*.*.*'
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Maven Central Repository
uses: actions/setup-java@v1
with:
java-version: '1.8'
distribution: 'adopt'
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Value of the GPG private key to import
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase

- name: create-json
id: create-json
uses: jsdaniell/create-json@1.1.2
with:
name: "credentials.json"
json: ${{ secrets.TEST_CREDENTIALS_FILE_STRING }}

- name: Publish package to Maven Central
run: mvn --batch-mode deploy
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
build-and-deploy:
uses: ./.github/workflows/shared-build-and-deploy.yml
with:
ref: ${{ github.ref_name }}
is-internal: false
server-id: ossrh
profile: maven-central
secrets:
server-username: ${{ secrets.OSSRH_USERNAME }}
server-password: ${{ secrets.OSSRH_PASSWORD }}
gpg-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
105 changes: 105 additions & 0 deletions .github/workflows/shared-build-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: Shared Build and Deploy
on:
workflow_call:
inputs:
ref:
description: 'Git reference to use (e.g., main or branch name)'
required: true
type: string

is-internal:
description: 'Flag for internal release'
required: true
type: boolean

server-id:
description: 'Id of the repository'
required: true
type: string

profile:
description: 'Profile to pick from pom.xml'
required: true
type: string
secrets:
server-username:
required: true

server-password:
required: true

gpg-key:
required: true

gpg-passphrase:
required: true

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ inputs.ref }}
fetch-depth: 0

- name: Set up maven or jfrog repository
uses: actions/setup-java@v1
with:
java-version: '1.8'
distribution: 'adopt'
server-id: ${{ inputs.server-id }}
server-username: SERVER_USERNAME
server-password: SERVER_PASSWORD
gpg-private-key: ${{ secrets.gpg-key }} # Value of the GPG private key to import
gpg-passphrase: GPG_PASSPHRASE # env variable for GPG private key passphrase

- name: Get Previous tag
id: previoustag
uses: WyriHaximus/github-action-get-previous-tag@v1
with:
fallback: 1.0.0

- name: Bump Version
run: |
chmod +x ./scripts/bump_version.sh
if ${{ inputs.is-internal }}; then
./scripts/bump_version.sh "${{ steps.previoustag.outputs.tag }}" "$(git rev-parse --short "$GITHUB_SHA")"
else
./scripts/bump_version.sh "${{ steps.previoustag.outputs.tag }}"
fi

- name: Commit changes
run: |
git config user.name ${{ github.actor }}
git config user.email ${{ github.actor }}@users.noreply.github.com
git add pom.xml
if ${{ inputs.is-internal }}; then
git commit -m "[AUTOMATED] Private Release ${{ steps.previoustag.outputs.tag }}-dev-$(git rev-parse --short $GITHUB_SHA)"
git push origin ${{ github.ref_name }} -f
else
git commit -m "[AUTOMATED] Public Release - ${{ steps.previoustag.outputs.tag }}"
git push origin
fi

- name: Create env
if: ${{ inputs.is-internal }}
id: create-env
run: |
touch .env
echo SKYFLOW_CREDENTIALS=${{ secrets.SKYFLOW_CREDENTIALS }} >> .env
echo TEST_EXPIRED_TOKEN=${{ secrets.TEST_EXPIRED_TOKEN }} >> .env

- name: Create credentials json
id: create-json
uses: jsdaniell/create-json@1.1.2
with:
name: "credentials.json"
json: ${{ secrets.TEST_CREDENTIALS_FILE_STRING }}

- name: Publish package
run: mvn clean deploy -P ${{ inputs.profile }}
env:
SERVER_USERNAME: ${{ secrets.server-username }}
SERVER_PASSWORD: ${{ secrets.server-password }}
GPG_PASSPHRASE: ${{ secrets.gpg-passphrase }}
57 changes: 46 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,6 @@

<build>
<plugins>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.7</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
Expand Down Expand Up @@ -198,4 +187,50 @@
</plugins>
</build>

<profiles>
<profile>
<id>maven-central</id>
<distributionManagement>
<repository>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2</url>
</repository>
<snapshotRepository>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.7</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>jfrog</id>
<distributionManagement>
<repository>
<id>central</id>
<name>prekarilabs.jfrog.io-releases</name>
<url>https://prekarilabs.jfrog.io/artifactory/skyflow-java</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>prekarilabs.jfrog.io-snapshots</name>
<url>https://prekarilabs.jfrog.io/artifactory/skyflow-java</url>
</snapshotRepository>
</distributionManagement>
</profile>
</profiles>

</project>
40 changes: 40 additions & 0 deletions scripts/bump_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Input Arguments
Version=$1
CommitHash=$2
PomFile="$GITHUB_WORKSPACE/pom.xml"

if [ -z "$Version" ]; then
echo "Error: Version argument is required."
exit 1
fi

# Update only the main project's <version>
if [ -z "$CommitHash" ]; then
echo "Bumping main project version to $Version"

awk -v version="$Version" '
BEGIN { updated = 0 }
/<version>/ && updated == 0 {
sub(/<version>.*<\/version>/, "<version>" version "</version>")
updated = 1
}
{ print }
' "$PomFile" > tempfile && cat tempfile > "$PomFile" && rm -f tempfile

echo "--------------------------"
echo "Done. Main project version now at $Version"
else
echo "Bumping main project version to $Version-dev-$CommitHash"

awk -v version="$Version-dev.$CommitHash" '
BEGIN { updated = 0 }
/<version>/ && updated == 0 {
sub(/<version>.*<\/version>/, "<version>" version "</version>")
updated = 1
}
{ print }
' "$PomFile" > tempfile && cat tempfile > "$PomFile" && rm -f tempfile

echo "--------------------------"
echo "Done. Main project version now at $Version-dev.$CommitHash"
fi
Loading