diff --git a/.github/workflows/create-release.yaml b/.github/workflows/create-release.yaml
new file mode 100644
index 00000000..c0132ca7
--- /dev/null
+++ b/.github/workflows/create-release.yaml
@@ -0,0 +1,21 @@
+name: create-release
+
+on:
+ workflow_dispatch:
+ inputs:
+ version:
+ type: string
+ required: true
+ description: New version to set
+
+jobs:
+ build-stage:
+ name: Build stage
+ uses: ./.github/workflows/release-stage.yaml
+ with:
+ # This will need to change to point to staging branch
+ ref: dev/dev-ci-fixes-stage
+ version: ${{ inputs.version }}
+ build-number: ${{ github.run_number }}
+ is-snapshot: false
+ secrets: inherit
diff --git a/.github/workflows/promote-prod.yaml b/.github/workflows/promote-prod.yaml
index ae9f2224..dc77ff8b 100644
--- a/.github/workflows/promote-prod.yaml
+++ b/.github/workflows/promote-prod.yaml
@@ -11,13 +11,18 @@ on:
build-number:
type: number
description: Build number used to build artifact to be promoted
+ target-branch:
+ type: choice
+ description: Target branch to promote to
+ options:
+ - dev-stage
jobs:
promote-from-stage-to-prod:
- name: Promot from stage to prod
+ name: Promote from stage to prod
uses: ./.github/workflows/promote.yaml
with:
build-number: ${{ inputs.build-number }}
target-repository: clients-maven-stage-local
- target-branch: dev-stage
+ target-branch: ${{ inputs.target-branch }}
secrets: inherit
diff --git a/.github/workflows/promote.yaml b/.github/workflows/promote.yaml
index 23301f1b..b5a0ea57 100644
--- a/.github/workflows/promote.yaml
+++ b/.github/workflows/promote.yaml
@@ -12,6 +12,10 @@ on:
target-branch:
type: string
description: Target branch to promote token
+ jf-target-build:
+ type: string
+ description: Target build name
+ default: create-release
secrets:
SONATYPE_MAVEN_USER:
required: true
@@ -42,7 +46,7 @@ jobs:
- name: Get info
id: get-build-info
run: |
- echo build-info=$(jf rt curl /api/build/clients-java-push-to-dev/${{ inputs.build-number }}) >> $GITHUB_OUTPUT
+ echo build-info=$(jf rt curl /api/build/${{ inputs.jf-target-build }}/${{ inputs.build-number }}) >> $GITHUB_OUTPUT
- name: Get commit hash from repo
id: get-commit-hash
@@ -90,7 +94,7 @@ jobs:
BUILD_NAMES=(${{ steps.get-build-name.outputs.build-names }})
if [ ${#MODULES[@]} -eq 0 ];then
- echo "Missing build names for modules in 'clients-java-push-to-dev'"
+ echo "Missing build names for modules in '${{ inputs.jf-target-build }}'"
fi
for BUILD_NAME in "${BUILD_NAMES[@]}"; do
diff --git a/.github/workflows/push-to-stage.yaml b/.github/workflows/push-to-stage.yaml
index 5448b164..e5c90855 100644
--- a/.github/workflows/push-to-stage.yaml
+++ b/.github/workflows/push-to-stage.yaml
@@ -11,5 +11,6 @@ jobs:
name: Build stage
uses: ./.github/workflows/release-stage.yaml
with:
- branch: ${{ github.ref }}
+ ref: ${{ github.ref }}
+ build-number: ${{ github.run_number }}
secrets: inherit
diff --git a/.github/workflows/release-stage.yaml b/.github/workflows/release-stage.yaml
index 7420c270..88881c56 100644
--- a/.github/workflows/release-stage.yaml
+++ b/.github/workflows/release-stage.yaml
@@ -1,9 +1,19 @@
on:
workflow_call:
inputs:
- branch:
+ ref:
type: string
required: true
+ version:
+ type: string
+ required: false
+ build-number:
+ type: string
+ required: true
+ is-snapshot:
+ type: boolean
+ required: false
+ default: true
jobs:
debug-job:
@@ -11,7 +21,7 @@ jobs:
steps:
- name: debug
run: |
- echo "${{ inputs.branch }}"
+ echo "${{ inputs.ref }}"
echo "${{ github.base_ref }}"
java-version:
@@ -23,7 +33,7 @@ jobs:
- name: Checkout client
uses: actions/checkout@v4
with:
- ref: ${{ inputs.branch }}
+ ref: ${{ inputs.ref }}
- name: Get java version
id: get-java-version
@@ -41,9 +51,11 @@ jobs:
matrix:
crypto-type: [bouncycastle, gnu]
with:
+ ref: ${{ inputs.ref }}
java-version: ${{ needs.java-version.outputs.java-version }}
- branch: ${{ inputs.branch }}
crypto-type: ${{ matrix.crypto-type }}
+ version: ${{ inputs.version }}
+ is-snapshot: ${{ inputs.is-snapshot }}
secrets: inherit
aggregate-published-artifacts:
diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml
index 2e6e45c9..41205b5c 100644
--- a/.github/workflows/release.yaml
+++ b/.github/workflows/release.yaml
@@ -5,7 +5,7 @@ permissions:
on:
workflow_call:
inputs:
- branch:
+ ref:
type: string
required: true
java-version:
@@ -14,6 +14,12 @@ on:
crypto-type:
type: string
required: true
+ version:
+ type: string
+ required: true
+ is-snapshot:
+ type: boolean
+ required: true
secrets:
GPG_SECRET_KEY_ORG:
required: true
@@ -31,8 +37,8 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
with:
- ref: ${{ inputs.branch }}
-
+ ref: ${{ inputs.ref }}
+
# Java plugin will setup gpg but we are not using maven to deploy do JFrog.
# - jf mvn clean install on publish does not publish POM we would like to publish
- name: Setup Java
@@ -43,9 +49,25 @@ jobs:
gpg-private-key: ${{ secrets.GPG_SECRET_KEY_ORG }}
gpg-passphrase: GPG_PASS
+ - name: Get release or snapshot-version
+ id: get-release-version
+ shell: bash
+ run: |
+ IS_SNAPSHOT='${{ inputs.is-snapshot }}'
+ if [ $IS_SNAPSHOT == 'true' ];then
+ echo release-version="$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)_$GITHUB_SHA" >> $GITHUB_OUTPUT
+ else
+ echo release-version="${{ inputs.version }}"
+ fi
+
+ - name: Set version
+ shell: bash
+ run: |
+ ./set_version ${{ steps.get-release-version.outputs.release-version }} ${{ inputs.crypto-type }}
+
- name: Build all modules
shell: bash
- run: mvn clean install -P ${{ inputs.crypto-type }} # The crypto profile is usually set with set_crypto but since we need to toggle multiple prfiles set_crypto option is not being picked up
+ run: mvn clean install -P ${{ inputs.crypto-type }} # The crypto profile is usually set with set_crypto but since we need to toggle multiple profiles set_crypto option is not being picked up
- name: Stage artifacts for publish
working-directory: client
@@ -72,6 +94,21 @@ jobs:
run: |
echo artifact-version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) >> $GITHUB_OUTPUT
+ - name: Debug
+ if: ${{ inputs.is-snapshot != true }}
+ run: |
+ echo "should commit"
+
+ - name: Commit new version
+ # Only committing version if this is a release and not snapshot build
+ if: ${{ inputs.is-snapshot != true }}
+ uses: stefanzweifel/git-auto-commit-action@v4
+ with:
+ commit_message: 'Bumping version to ${{ inputs.version }} [skip ci]'
+ commit_author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
+ tagging_message: Bumping version ${{ inputs.version }}
+ branch: ${{ inputs.ref }}
+
- name: Publish to JFrog
uses: ./.github/actions/publish-to-jfrog
with:
diff --git a/set_version b/set_version
new file mode 100755
index 00000000..3bb1aec4
--- /dev/null
+++ b/set_version
@@ -0,0 +1,56 @@
+#!/usr/bin/env bash
+
+#
+# Function definitions
+#
+function update_version() {
+ VERSION="$1"
+ BUILD_TYPE=$2
+ PARENT_POM="pom.xml"
+ PUBLIC_POM="client/deploy-resources/${BUILD_TYPE}_pom.xml"
+
+ # Detecting host type. `sed` on bsd and linux are not the same
+ if [[ "$(uname)" == "Darwin" ]]; then
+ sed -i "" "s#[^<]*#${VERSION}#g" "$PARENT_POM"
+ sed -i "" "1,/[^<]*<\/version>/ s#[^<]*#${VERSION}#" "$PUBLIC_POM"
+ else
+ sed -i "s#[^<]*#${VERSION}#g" "$PARENT_POM"
+ sed -i "0,/[^<]*<\/version>/ s//${VERSION}<\/version>/" "$PUBLIC_POM"
+ fi
+}
+
+function main() {
+ VERSION=$1
+ BUILD_TYPE=$2
+
+ # If version has been set using set_crypto we are honoring that setting
+ if [ -f "bouncycastle.config" ];then
+ BUILD_TYPE="bouncycastle"
+ elif [ -f "gnu.config" ];then
+ BUILD_TYPE="gnu"
+ fi
+
+ update_version $VERSION $BUILD_TYPE
+}
+
+#
+# Main entry
+#
+VERSION=$1
+BUILD_TYPE=${2:-"gnu"}
+REGEX="^[0-9]+\.[0-9]+\.[0-9]+(_[a-zA-Z0-9]+)?$"
+
+if [ -z $VERSION ];then
+ printf "Missing version ..."
+
+ exit 1
+elif [[ ! "$1" =~ $REGEX ]];then
+ printf "Version format not valid. Valid format are [0 - 9].[0 - 9].[0 - 9] | [0 - 9].[0 - 9].[0 - 9]_[git_sha]"
+
+ exit 1
+else
+ # Call main
+ main $VERSION $BUILD_TYPE
+
+ exit 0
+fi
\ No newline at end of file