Skip to content
Open
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
72 changes: 72 additions & 0 deletions .github/actions/get-version/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Get version
description: Detects if build is a snapshot and gets the release or snapshot version

runs:
using: composite
steps:
# Checking if this particular build is a snapshot build
- name: Detect if snapshot
id: get-is-snapshot
shell: bash
run: |
# Check if tagged with release or release candidate
TAG=$(git describe --exact-match --tags HEAD 2>/dev/null || echo "")
echo "Detected Git tag: '$TAG'"

# Define regex patterns
RE_PROD='^v?[0-9]+\.[0-9]+\.[0-9]+$'
RE_RC='^v?[0-9]+\.[0-9]+\.[0-9]+-rc[0-9]+$'

if [[ "$TAG" =~ $RE_PROD ]]; then
echo "Production release tag detected: $TAG"
echo "is-snapshot=false" >> $GITHUB_OUTPUT
exit 0
elif [[ "$TAG" =~ $RE_RC ]]; then
echo "Release candidate tag detected: $TAG"
echo "is-snapshot=false" >> $GITHUB_OUTPUT
exit 0
else
echo "No matching tag found"
echo "is-snapshot=true" >> $GITHUB_OUTPUT
fi

# Checking if previous commit contains pom.xml. This should always return true
COMMIT_REF="HEAD~1"
if ! git show "${COMMIT_REF}:pom.xml" &>/dev/null; then
echo "Error: pom.xml not found in commit ${COMMIT_REF}"
echo "is-snapshot='true'" >> $GITHUB_OUTPUT
exit 0
fi

# Getting previous version
OLD_VERSIONS=$(git show "${COMMIT_REF}:pom.xml" | sed -n '0,/<version>/ s/.*<version>\([^<]*\)<\/version>.*/\1/p')

# Getting current version
NEW_VERSIONS=$(sed -n '0,/<version>/ s/.*<version>\([^<]*\)<\/version>.*/\1/p' pom.xml)

echo "old versions: ${OLD_VERSIONS}, new versions: ${NEW_VERSIONS}"
# Compare the extracted versions. CI will not commit snapshot version.
if [[ "${OLD_VERSIONS}" != "${NEW_VERSIONS}" ]]; then
echo "is-snapshot=false" >> $GITHUB_OUTPUT
else
echo "is-snapshot=true" >> $GITHUB_OUTPUT
fi

- name: Get release or snapshot-version
id: get-release-version
shell: bash
run: |
IS_SNAPSHOT=${{ steps.get-is-snapshot.outputs.is-snapshot }}
if [ $IS_SNAPSHOT == "true" ];then
echo release-version="$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)-SNAPSHOT_$GITHUB_SHA" >> $GITHUB_OUTPUT
else
echo release-version="$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_OUTPUT
fi

outputs:
is-snapshot:
description: Whether this is a snapshot build
value: ${{ steps.get-is-snapshot.outputs.is-snapshot }}
release-version:
description: The release or snapshot version
value: ${{ steps.get-release-version.outputs.release-version }}
63 changes: 63 additions & 0 deletions .github/actions/publish-build-info-to-jfrog/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Publish build-info to JFrog
description: "Publishes build-info to JFrog"

inputs:
jfrog-platform-url:
description: "JFrog platform URL"
required: false
default: https://aerospike.jfrog.io
oidc-provider:
description: "OIDC provider name"
required: true
oidc-audience:
description: "ODIC audience"
required: true
build-path:
description: "Path to which build info is to be published"
required: true
variables:
description: "Any additional variables to be published as part of build. The input here should be valid JSON in the form {'env_variable_key': 'env_variable_value'}, .e.g {'SONATYPE_STAGING_BUILD_ID': '070c07e25e937888ed9740ee825afa24bf184722'}"
required: true

runs:
using: "composite"
steps:
- name: Debug publish to github
shell: bash
run: |
echo "${{ inputs.jfrog-platform-url }}"
echo "${{ inputs.build-path }}"

- name: Set up JFrog credentials
id: setup-jfrog-cli
uses: step-security/setup-jfrog-cli@a6b41f8338bea0983ddff6bd4ede7d2dcd81e1fa # v4.8.1
env:
JF_URL: ${{ inputs.jfrog-platform-url }}
JF_PROJECT: database
with:
version: 2.72.2
oidc-provider-name: ${{ inputs.oidc-provider }}
oidc-audience: ${{ inputs.oidc-audience }}

# Parsing out env variables and values and setting them in the environment
- name: Set env variables provided with variables
shell: bash
run: |
ENV_VARIABLES='${{ inputs.variables }}'
echo "$ENV_VARIABLES" | jq -r 'to_entries | .[] | "\(.key)=\(.value)"' >> $GITHUB_ENV

# Pushing build info to JFrog
- name: Upload artifacts
shell: bash
run: |
BUILD_ID=$(echo "${{ inputs.build-path }}" | sed 's/.*_\(.*\)\/.*/\1/')
BUILD_PATH="promote_${BUILD_ID}"

# record env variables
jf rt bce ${BUILD_PATH} ${{ github.run_number }}

# record git info
jf rt bag ${BUILD_PATH} ${{ github.run_number }}

# publish build info
jf rt bp ${BUILD_PATH} ${{ github.run_number }}
91 changes: 91 additions & 0 deletions .github/actions/publish-to-github/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Publish artifacts to github
description: "Publish artifacts to github"

inputs:
staging-folder:
description: ""
required: false
default: staging
target-folder:
description: ""
required: false
default: github
release-notes:
description: "Release notes"
required: true
github-token:
description: "Github auth token"
required: true
artifact-version:
description: "Version of the artifact to release"
required: true
build-name-number:
description: "String containing build name, number and jdk versions"
required: true

runs:
using: "composite"
steps:
- name: Debug publish to github
shell: bash
run: |
echo "${{ inputs.staging-folder }}"
echo "${{ inputs.target-folder }}"
echo "${{ inputs.artifact-version }}"
echo "${{ inputs.release-notes }}"
echo "${{ inputs.build-name-number }}"

- id: get-artifact-version
shell: bash
run: |
VERSION="${{ inputs.artifact-version }}"
echo "artifact-version=${VERSION}" >> $GITHUB_OUTPUT

- name: Create upload archive for github
id: create-artifact
shell: bash
run: |
src="${{ inputs.staging-folder }}"
dest="${{ inputs.target-folder }}"

find "$src" -type f \
-exec cp {} "$dest" \;

# Listing staged artifacts to be uploaded
- id: get-github-release-artifact-names
working-directory: ${{ inputs.target-folder }}
shell: bash
run: |
ARTIFACTS=$(ls | sed "s|^|${{ inputs.target-folder }}/|")

echo "release-artifacts<<EOF" >> $GITHUB_OUTPUT
echo "${ARTIFACTS}" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

- name: Debug show content of the upload archive
shell: bash
run: |
pwd
ls ${{ inputs.target-folder }} | sed 's/^//'

- name: Debug GitHub publish input
shell: bash
working-directory: ${{ inputs.target-folder }}
run: |
echo "working directory: ${{ inputs.target-folder }}"
echo "tag name: Release ${{ steps.get-artifact-version.outputs.artifact-version }}"
echo "body: Changes for release ${{ steps.get-artifact-version.outputs.artifact-version }}"
echo "body: ${{ inputs.release-notes }}"
echo "files: ${{ steps.get-github-release-artifact-names.outputs.release-artifacts }}"

- name: Publish release to github
uses: step-security/action-gh-release@5f6a6ab53a5a2c000ff3a16fad038291e5b97ce7 # v2.4.2
with:
token: ${{ inputs.github-token }}
tag_name: ${{ steps.get-artifact-version.outputs.artifact-version }}
body: |
Changes for release ${{ steps.get-artifact-version.outputs.artifact-version }}
${{ inputs.release-notes }}
draft: true
prerelease: false
files: ${{ steps.get-github-release-artifact-names.outputs.release-artifacts }}
Loading
Loading