Skip to content

Commit 89bce9a

Browse files
committed
CI/CD changes
1 parent 5830c5b commit 89bce9a

38 files changed

+1848
-139
lines changed

.github/actions/build-and-test/action.yaml

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: "Build and test code base"
33

44
inputs:
55
crypto-type:
6-
description: ""
6+
description: "Crypto type to use. This should either be bouncycastle or gnu"
77
required: false
88
default: gnu
99
use-server-rc:
@@ -14,40 +14,45 @@ inputs:
1414
required: false
1515
default: "latest"
1616
description: "Server docker image tag"
17-
jfrog_docker_username:
17+
oidc-provider:
1818
required: true
19-
description: ""
20-
jfrog_docker_token:
19+
description: "OIDC provider"
20+
oidc-audience:
2121
required: true
22-
description: ""
22+
description: "OIDC audience"
2323
run-tests:
2424
required: true
25-
default: "false"
25+
default: "true"
2626
description: Spin up aerospike enterprise server and run tests
2727

2828
runs:
2929
using: "composite"
3030
steps:
31+
# Using script to set profile since we would like to have the sticky effect. Set it once and have it
32+
# remain for remainder of the job
3133
- name: Stage crypto
3234
shell: bash
3335
run: |
34-
./set_cypto ${{ inputs.crypto-type }}
36+
./set_crypto ${{ inputs.crypto-type }}
3537
38+
# Running build install
3639
- name: Build
3740
shell: bash
38-
run: mvn clean install -P ${{ inputs.crypto-type }}
41+
run: mvn clean install
3942

40-
- name: Run EE server
43+
# Starting test bench
44+
- name: Run Aerospike
4145
if: ${{ inputs.run-tests == 'true' }}
4246
uses: ./.github/actions/run-ee-server
4347
with:
4448
use-server-rc: ${{ inputs.use-server-rc }}
4549
server-tag: ${{ inputs.server-tag }}
46-
docker-hub-username: ${{ inputs.jfrog_docker_username }}
47-
docker-hub-password: ${{ inputs.jfrog_docker_token }}
50+
oidc-provider: ${{ inputs.oidc-provider }}
51+
oidc-audience: ${{ inputs.oidc-audience }}
4852

49-
- name: Test
53+
# Running tests
54+
- name: Run tests
5055
shell: bash
51-
if: ${{ inputs.run-tests == true }}
56+
if: ${{ inputs.run-tests == 'true' }}
5257
working-directory: test
5358
run: mvn test -DskipTests=false
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Create github release
2+
description: Creates a github release
3+
4+
inputs:
5+
artifact-version:
6+
description: ""
7+
required: true
8+
github-token:
9+
description: ""
10+
required: true
11+
12+
runs:
13+
using: composite
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v3
17+
18+
- name: Get previous tag
19+
shell: bash
20+
id: get-prev-tag
21+
run: |
22+
# Fetch all tags
23+
git fetch --tags
24+
echo "previous-tag=$(git tag --sort=-creatordate | sed -n '1p')" >> $GITHUB_OUTPUT
25+
26+
# Extract commit messages between previous tag and the current tag. This ensures that the messages is
27+
# in multiple lines and follows nicely formatted release notes.
28+
- name: Get release notes
29+
shell: bash
30+
id: release-notes
31+
run: |
32+
notes=$(git log "${{ steps.get-previous-tag.outputs.previous-tag }}..HEAD" --pretty=format:"%s" --no-merges)
33+
34+
# GitHub Actions requires that multiline output is escaped:
35+
notes="${notes//'%'/'%25'}"
36+
notes="${notes//$'\n'/'%0A'}"
37+
notes="${notes//$'\r'/'%0D'}"
38+
39+
echo "notes=$notes" >> $GITHUB_OUTPUT
40+
41+
- name: Debug
42+
shell: bash
43+
run: |
44+
echo "artifact-version: ${{ inputs.artifact-version }}"
45+
echo "body: ${{ steps.release-notes.outputs.notes }}"
46+
47+
- uses: rickstaa/action-create-tag@v1
48+
id: "tag_create"
49+
with:
50+
tag: ${{ inputs.artifact-version }}
51+
tag_exists_error: false
52+
message: "Latest release"
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Publish build-info to JFrog
2+
description: "Publishes build-info to JFrog"
3+
4+
inputs:
5+
jfrog-platform-url:
6+
description: "JFrog platform URL"
7+
required: false
8+
default: https://aerospike.jfrog.io
9+
oidc-provider:
10+
description: "OIDC provider name"
11+
required: true
12+
oidc-audience:
13+
description: "ODIC audience"
14+
required: true
15+
build-path:
16+
description: "Path to which build info is to be published"
17+
required: true
18+
variables:
19+
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'}"
20+
required: true
21+
22+
runs:
23+
using: "composite"
24+
steps:
25+
- name: Debug publish to github
26+
shell: bash
27+
run: |
28+
echo "${{ inputs.jfrog-platform-url }}"
29+
echo "${{ inputs.build-path }}"
30+
31+
- name: Set up JFrog credentials
32+
id: setup-jfrog-cli
33+
uses: jfrog/setup-jfrog-cli@v4
34+
env:
35+
JF_URL: ${{ inputs.jfrog-platform-url }}
36+
with:
37+
version: 2.72.2
38+
oidc-provider-name: ${{ inputs.oidc-provider }}
39+
oidc-audience: ${{ inputs.oidc-audience }}
40+
41+
# Parsing out env variables and values and setting them in the environment
42+
- name: Set env variables provided with variables
43+
shell: bash
44+
run: |
45+
ENV_VARIABLES='${{ inputs.variables }}'
46+
echo "$ENV_VARIABLES" | jq -r 'to_entries | .[] | "\(.key)=\(.value)"' >> $GITHUB_ENV
47+
48+
# Pushing build info to JFrog
49+
- name: Upload artifacts
50+
shell: bash
51+
run: |
52+
BUILD_ID=$(echo "${{ inputs.build-path }}" | sed 's/.*_\(.*\)\/.*/\1/')
53+
BUILD_PATH="promote_${BUILD_ID}"
54+
55+
# record env variables
56+
jf rt bce ${BUILD_PATH} ${{ github.run_number }}
57+
58+
# record git info
59+
jf rt bag ${BUILD_PATH} ${{ github.run_number }}
60+
61+
# publish build info
62+
jf rt bp ${BUILD_PATH} ${{ github.run_number }}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Publish artifacts to github
2+
description: "Publish artifacts to github"
3+
4+
inputs:
5+
staging-folder:
6+
description: ""
7+
required: false
8+
default: staging
9+
target-folder:
10+
description: ""
11+
required: false
12+
default: github
13+
release-notes:
14+
description: ""
15+
required: true
16+
github-token:
17+
description: ""
18+
required: true
19+
artifact-version:
20+
description: ""
21+
required: true
22+
23+
runs:
24+
using: "composite"
25+
steps:
26+
- name: Debug publish to github
27+
shell: bash
28+
run: |
29+
echo "${{ inputs.staging-folder }}"
30+
echo "${{ inputs.target-folder }}"
31+
echo "${{ inputs.artifact-version }}"
32+
echo "${{ inputs.release-notes }}"
33+
34+
- name: Create upload archive for github
35+
id: create-artifact
36+
shell: bash
37+
run: |
38+
src="${{ inputs.staging-folder }}"
39+
dest="${{ inputs.target-folder }}"
40+
41+
find "$src" -type f \
42+
-exec cp {} "$dest" \;
43+
44+
- id: get-github-release-artifact-names
45+
working-directory: ${{ inputs.target-folder }}
46+
shell: bash
47+
run: |
48+
ARTIFACTS=$(ls -l)
49+
50+
echo "release-artifacts<<EOF" >> $GITHUB_OUTPUT
51+
echo "${ARTIFACTS}" >> $GITHUB_OUTPUT
52+
echo "EOF" >> $GITHUB_OUTPUT
53+
54+
- name: Debug show content of the upload archive
55+
shell: bash
56+
run: |
57+
pwd
58+
ls -laR "${{ inputs.target-folder }}"
59+
60+
- name: Debug GitHub publish input
61+
shell: bash
62+
working-directory: ${{ inputs.target-folder }}
63+
run: |
64+
echo "working directory: ${{ inputs.target-folder }}"
65+
echo "tag name: Release ${{ inputs.artifact-version }}"
66+
echo "body: Changes for release ${{ inputs.artifact-version }}"
67+
echo "body: ${{ inputs.release-notes }}"
68+
echo "files: ${{ steps.get-github-release-artifact-names.outputs.release-artifacts }}"
69+
70+
# TODO: uncomment for production release
71+
#- name: Publish release to github
72+
# working-directory: ${{ inputs.target-folder }}
73+
# uses: softprops/action-gh-release@v2
74+
# with:
75+
# token: ${{ inputs.github-token }}
76+
# tag_name: Release ${{ inputs.artifact-version }}
77+
# body: |
78+
# Changes for release ${{ inputs.artifact-version }}
79+
# "${{ inputs.release-notes }}"
80+
# draft: false
81+
# prerelease: false
82+
# files: ${{ steps.get-github-release-artifact-names.outputs.release-artifacts }}

.github/actions/publish-to-jfrog/action.yaml

Lines changed: 78 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,50 +3,110 @@ description: "Publishes artifacts to JFrog"
33

44
inputs:
55
jfrog-releases-repo-name:
6-
description: ""
6+
description: "Jfrog releases repository name"
77
required: false
88
default: clients-maven-dev-local
99
jfrog-snapshots-repo-name:
10-
description: ""
10+
description: "Jfrog snapshots repository name"
1111
required: false
1212
default: clients-maven-dev-local
1313
jfrog-platform-url:
14-
description: ""
14+
description: "JFrog platform URL"
1515
required: false
16-
default: https://aerospike.jfrog.io/
16+
default: https://aerospike.jfrog.io
1717
oidc-provider:
18-
description: ""
19-
required: false
20-
default: gh-aerospike-clients
18+
description: "OIDC provider name"
19+
required: true
2120
oidc-audience:
22-
description: ""
21+
description: "OIDC audience"
22+
required: true
23+
artifact-id:
24+
description: "Artifact ID"
25+
required: true
26+
artifact-version:
27+
description: "Artifact version"
28+
required: true
29+
deploy-spec-path:
30+
description: "Deploy spec path. This directory contains any resources needed for public releases, like public facing POMs"
2331
required: false
24-
default: aerospike/clients
25-
crypto-type:
26-
description: ""
32+
default: deploy-resources
33+
package-install-location:
34+
description: "Location where the artifacts are installed"
2735
required: false
28-
default: gnu
36+
default: ~/.m2/repository
2937

3038
runs:
3139
using: "composite"
3240
steps:
41+
- name: Debug publish to github
42+
shell: bash
43+
run: |
44+
echo "${{ inputs.jfrog-releases-repo-name }}/github"
45+
echo "${{ inputs.jfrog-snapshots-repo-name }}"
46+
echo "${{ inputs.jfrog-platform-url }}"
47+
echo "${{ inputs.artifact-id }}"
48+
echo "${{ inputs.artifact-version }}"
49+
echo "${{ inputs.deploy-spec-path }}"
50+
echo "${{ inputs.package-install-location }}"
51+
3352
- name: Set up JFrog credentials
53+
id: setup-jfrog-cli
3454
uses: jfrog/setup-jfrog-cli@v4
3555
env:
3656
JF_URL: ${{ inputs.jfrog-platform-url }}
3757
with:
58+
version: 2.72.2
3859
oidc-provider-name: ${{ inputs.oidc-provider }}
3960
oidc-audience: ${{ inputs.oidc-audience }}
4061

41-
- name: Set crypto dependency
62+
- name: Configure jf cli
4263
shell: bash
4364
run: |
44-
./set_crypto ${{ inputs.crypto-type }}
65+
jf mvn-config \
66+
--repo-deploy-releases=${{ inputs.jfrog-releases-repo-name }} \
67+
--repo-deploy-snapshots=${{ inputs.jfrog-snapshots-repo-name }}
68+
69+
# Generating deploy spec to match the artifacts to be uploaded. Builds for java do not follow the standards since we have bouncycastle and gnu builds.
70+
# Technically speaking we should have multiple modules looking at how Maven does things. But for practical reasons we don't since we would have duplicate
71+
# code to maintain.
72+
- name: Generate deploy spec
73+
shell: bash
74+
working-directory: client
75+
run: |
76+
jq --arg targetPattern "${{ inputs.jfrog-releases-repo-name }}/com/aerospike/${{ inputs.artifact-id }}/${{ inputs.artifact-version }}/" \
77+
--arg publicPomPattern "${{ inputs.package-install-location }}/com/aerospike/${{ inputs.artifact-id }}/${{ inputs.artifact-version }}/*.pom" \
78+
--arg jarPattern "${{ inputs.package-install-location }}/com/aerospike/${{ inputs.artifact-id }}/${{ inputs.artifact-version }}/*.jar" \
79+
--arg ascPattern "${{ inputs.package-install-location }}/com/aerospike/${{ inputs.artifact-id }}/${{ inputs.artifact-version }}/*.asc" \
80+
'
81+
.files[0].pattern = $jarPattern |
82+
.files[0].target = $targetPattern |
83+
.files[1].pattern = $ascPattern |
84+
.files[1].target = $targetPattern |
85+
.files[2].pattern = $publicPomPattern |
86+
.files[2].target = $targetPattern
87+
' ${{ inputs.deploy-spec-path }}/publish-spec.json.template > ${{ inputs.deploy-spec-path }}/publish-spec.json
4588
46-
- name: Deploy release
89+
- name: Debug deploy spec
4790
shell: bash
4891
working-directory: client
4992
run: |
50-
jf mvn-config --repo-deploy-releases=${{ inputs.jfrog-releases-repo-name }} --repo-deploy-snapshots=${{ inputs.jfrog-snapshots-repo-name }}
51-
jf mvn source:jar javadoc:jar deploy -Dusername=${{ steps.setup-jfrog-cli.outputs.oidc-user }} ${{ steps.setup-jfrog-cli.outputs.oidc-token }}
52-
jf rt bp
93+
cat ${{ inputs.deploy-spec-path }}/publish-spec.json
94+
95+
# Publishing artifacts to JFrog
96+
- name: Upload artifacts
97+
shell: bash
98+
working-directory: client
99+
run: |
100+
jf rt upload --spec=${{ inputs.deploy-spec-path }}/publish-spec.json \
101+
--module=${{ inputs.artifact-id }} \
102+
--build-name=clients-java-push-to-dev_${{ inputs.artifact-id }} \
103+
--build-number=${{ github.run_number }}
104+
105+
# record env variables
106+
jf rt bce clients-java-push-to-dev_${{ inputs.artifact-id }} ${{ github.run_number }}
107+
108+
# record git info
109+
jf rt bag clients-java-push-to-dev_${{ inputs.artifact-id }} ${{ github.run_number }}
110+
111+
# publish build info
112+
jf rt bp clients-java-push-to-dev_${{ inputs.artifact-id }} ${{ github.run_number }}

0 commit comments

Comments
 (0)