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
54 changes: 54 additions & 0 deletions .github/actions/get-version/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
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: |
# Getting previous commit
COMMIT_REF="HEAD~1"

# Checking if previous commit contains pom.xml. This should always return true
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 '/<revision>/ { s/.*<revision>\([^<]*\)<\/revision>.*/\1/p; q }')

# Getting current version
NEW_VERSIONS=$(sed -n 's/.*<revision>\([^<]*\)<\/revision>.*/\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 }}
121 changes: 121 additions & 0 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
name: Build and release

permissions:
id-token: write
packages: write
contents: read
attestations: write

on:
workflow_call:
secrets:
GPG_SECRET_KEY:
required: true
GPG_PUBLIC_KEY:
required: true
GPG_PASS:
required: true
push:
branches:
- CLIENT-3872-add-release-scripts

jobs:
extract-version:
runs-on: ${{ vars.BUILD_CONTAINER_DISTRO_VERSION }}
steps:
- uses: actions/checkout@v5
- name: Extract Version
id: extract
uses: ./.github/actions/get-version
outputs:
version: ${{ steps.extract.outputs.release-version }}

build-packages:
needs: extract-version
uses: aerospike/shared-workflows/.github/workflows/reusable_execute-build.yaml@e9d98e77b7895f22a3a45393f8461d44901df7be
with:
runs-on: ${{ vars.BUILD_CONTAINER_DISTRO_VERSION }}
jf-project: ${{ vars.JFROG_PROJECT }}
jf-build-name: aerospike-client-java-reactive
jf-build-id: ${{ github.run_number }}-buildinfo-${{ needs.extract-version.outputs.version }}
gh-checkout-path: shared-workflows
gh-source-path: aerospike-client-java-reactive
working-directory: aerospike-client-java-reactive
setup-java: true
java-version: 8
java-distribution: "temurin"
build-script: |
# Start Aerospike via the GitHub Action
echo "Starting Aerospike DB..."
docker run -d --name aerospike -p 3000:3000 aerospike/aerospike-server
sleep 5

# Maven build
mvn clean install -B -U -Dgpg.skip=true

cd reactor-client

LOCAL_REPO=$(mvn help:evaluate -Dexpression=settings.localRepository -q -DforceStdout)
GROUP_ID=$(mvn help:evaluate -Dexpression=project.groupId -q -DforceStdout)
ARTIFACT_ID=$(mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout)
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)

GROUP_PATH=$(echo "$GROUP_ID" | tr '.' '/')
ARTIFACT_PATH="$LOCAL_REPO/$GROUP_PATH/$ARTIFACT_ID/$VERSION"

cd -

echo "Copying artifacts to ./build/"
for file in "$ARTIFACT_PATH"/*; do
if [[ "$file" == *"-jar-with-dependencies.jar" ]] || [[ "$file" == *"_remote.repositories" ]]; then
continue
fi
cp "$file" build/
done
gh-artifact-directory: build
gh-artifact-name: build-artifacts-${{ needs.extract-version.outputs.version }}
gh-retention-days: 1
jf-url: https://artifact.aerospike.io
publish-build-info: true
oidc-provider-name: ${{ vars.OIDC_PROVIDER_NAME }}
oidc-audience: ${{ vars.OIDC_AUDIENCE }}

sign-artifacts:
needs: [build-packages, extract-version]
uses: aerospike/shared-workflows/.github/workflows/reusable_sign-artifacts.yaml@f864dac717b2792d0ef7a967f0a4c06983fca7ce
with:
gh-retention-days: 1
gh-artifact-name: signed_build-artifacts-${{ needs.extract-version.outputs.version }}
gh-unsigned-artifacts: build-artifacts-${{ needs.extract-version.outputs.version }}
secrets:
gpg-private-key: ${{ secrets.GPG_SECRET_KEY }}
gpg-public-key: ${{ secrets.GPG_PUBLIC_KEY }}
gpg-key-pass: ${{ secrets.GPG_PASS }}

deploy-artifacts:
needs: [sign-artifacts, extract-version]
uses: aerospike/shared-workflows/.github/workflows/reusable_deploy-artifacts.yaml@f864dac717b2792d0ef7a967f0a4c06983fca7ce
with:
gh-workflows-ref: f864dac717b2792d0ef7a967f0a4c06983fca7ce
jf-project: ${{ vars.JFROG_PROJECT }}
jf-build-name: aerospike-client-java-reactive
jf-metadata-build-id: ${{ github.run_number }}-buildinfo
jf-build-id: ${{ github.run_number }}
gh-artifact-name: ${{ needs.sign-artifacts.outputs.gh-artifact-name }}
version: ${{ needs.extract-version.outputs.version }}
gh-retention-days: 1
oidc-provider-name: ${{ vars.OIDC_PROVIDER_NAME }}
oidc-audience: ${{ vars.OIDC_AUDIENCE }}
dry-run: true

create-release-bundle:
needs: [extract-version, deploy-artifacts]
uses: aerospike/shared-workflows/.github/workflows/reusable_create-release-bundle.yaml@f864dac717b2792d0ef7a967f0a4c06983fca7ce
with:
jf-project: ${{ vars.JFROG_PROJECT }}
jf-build-names: aerospike-client-java-reactive:${{ github.run_number }}
jf-bundle-name: aerospike-client-java-reactive
version: ${{ needs.extract-version.outputs.version }}
oidc-provider-name: ${{ vars.OIDC_PROVIDER_NAME }}
oidc-audience: ${{ vars.OIDC_AUDIENCE }}
dry-run: true
Loading