-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: build and publish the cloud-agent revision together with a helm c…
…hart and http clients (#1289) Signed-off-by: Yurii Shynbuiev <[email protected]>
- Loading branch information
1 parent
88efa9c
commit 5416423
Showing
2 changed files
with
130 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,35 @@ | ||
name: Build and Publish Revision | ||
|
||
run-name: Build and Publish Cloud-Agent Revision from ${{ github.head_ref || github.ref_name }} run ${{ github.run_number }} | ||
|
||
concurrency: | ||
group: release | ||
group: build-${{ github.sha }} | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- "main" | ||
- "beta" | ||
paths: | ||
- "cloud-agent/**" | ||
- "castor/**" | ||
- "connect/**" | ||
- "mercury/**" | ||
- "pollux/**" | ||
- "shared/**" | ||
- "shared-test/**" | ||
- "*.sbt" | ||
- "project/**" | ||
- "prism-node/**" | ||
|
||
permissions: | ||
contents: write | ||
packages: write | ||
|
||
jobs: | ||
build: | ||
name: "Build and Publish Cloud-Agent Revision" | ||
if: ${{ !contains(github.event.head_commit.message, 'chore(release)') }} | ||
env: | ||
GITHUB_ACTOR: "hyperledger-bot" | ||
|
@@ -19,11 +38,15 @@ jobs: | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | ||
JAVA_TOOL_OPTIONS: -Djava.net.preferIPv4Stack=true | ||
SBT_OPTS: -Xmx2G | ||
|
||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: write | ||
packages: write | ||
outputs: | ||
COMMIT_HASH: ${{ env.COMMIT_HASH }} | ||
BUILD_VERSION: ${{ env.BUILD_VERSION }} | ||
REVISION_VERSION: ${{ env.REVISION_VERSION }} | ||
OAS_CHECKSUM: ${{ env.OAS_CHECKSUM }} | ||
OAS_PUBLISHED: ${{ steps.upload-oas.conclusion == 'success' }} | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
@@ -36,6 +59,9 @@ jobs: | |
with: | ||
java-version: [email protected] | ||
|
||
- uses: coursier/cache-action@v6 | ||
id: coursier-cache | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
|
@@ -55,7 +81,8 @@ jobs: | |
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Get short commit hash | ||
run: echo "COMMIT_HASH=${GITHUB_SHA::7}" >> $GITHUB_ENV | ||
run: | | ||
echo "COMMIT_HASH=${GITHUB_SHA::7}" >> $GITHUB_ENV | ||
- name: Set build number | ||
run: echo "BUILD_NUMBER=${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV | ||
|
@@ -64,10 +91,11 @@ jobs: | |
id: get_version | ||
run: | | ||
VERSION=$(grep -Eo 'version := "[^"]+"' version.sbt | sed 's/version := "//; s/"//; s/-SNAPSHOT//') | ||
REVISION_VERSION=${VERSION}-${{ env.COMMIT_HASH }} | ||
BUILD_VERSION=${REVISION_VERSION}-${{ env.BUILD_NUMBER }} | ||
echo "VERSION=${VERSION}" >> $GITHUB_ENV | ||
- name: Set build version | ||
run: echo "BUILD_VERSION=${{ env.VERSION }}-${{ env.COMMIT_HASH }}-${{ env.BUILD_NUMBER }}" >> $GITHUB_ENV | ||
echo "REVISION_VERSION=${REVISION_VERSION}" >> $GITHUB_ENV | ||
echo "BUILD_VERSION=${BUILD_VERSION}" >> $GITHUB_ENV | ||
- name: Build and push Docker image | ||
run: | | ||
|
@@ -81,3 +109,38 @@ jobs: | |
repository: input-output-hk/atala-prism-helm-charts | ||
event-type: build-chart-package | ||
client-payload: '{"version": "${{ env.BUILD_VERSION }}", "chart": "cloud-agent"}' | ||
|
||
- name: Build Cloud-Agent Open API Specification | ||
id: build-oas | ||
run: | | ||
sbt "cloudAgentServer/test:runMain org.hyperledger.identus.api.util.Tapir2StaticOAS ../../../cloud-agent-openapi-spec-${{ env.REVISION_VERSION}}.yaml revision" | ||
checksum=$(sha256sum ./cloud-agent-openapi-spec-${{ env.REVISION_VERSION }}.yaml | awk '{ print $1 }') | ||
OAS_CHECKSUM=${checksum:0:8} | ||
echo "OAS_CHECKSUM=$OAS_CHECKSUM" >> $GITHUB_ENV | ||
- name: Publish Cloud-Agent Open API Specification | ||
id: upload-oas | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: cloud-agent-openapi-spec-${{ env.OAS_CHECKSUM}} | ||
path: ./cloud-agent-openapi-spec-${{ env.REVISION_VERSION}}.yaml | ||
overwrite: true | ||
compression-level: 0 | ||
|
||
- name: Set outputs | ||
id: set_outputs | ||
run: | | ||
echo "COMMIT_HASH=${{ env.COMMIT_HASH }}" >> $GITHUB_ENV | ||
echo "BUILD_VERSION=${{ env.BUILD_VERSION }}" >> $GITHUB_ENV | ||
echo "REVISION_VERSION=${{ env.REVISION_VERSION }}" >> $GITHUB_ENV | ||
echo "OAS_CHECKSUM=${{ env.OAS_CHECKSUM }}" >> $GITHUB_ENV | ||
echo "OAS_PUBLISHED=${{ env.OAS_PUBLISHED }}" >> $GITHUB_ENV | ||
build-and-publish-clients: | ||
needs: build | ||
if: needs.build.outputs.OAS_PUBLISHED | ||
uses: ./.github/workflows/release-clients.yml | ||
secrets: inherit | ||
with: | ||
revision: ${{ needs.build.outputs.REVISION_VERSION }} | ||
check_sum: ${{ needs.build.outputs.OAS_CHECKSUM }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,45 @@ | ||
name: Publish Identus-cloud-agent clients | ||
|
||
run-name: Build and publish Identus Cloud Agent clients from from ${{ github.head_ref || github.ref_name }} run ${{ github.run_number }} | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
version: | ||
description: "Version to release clients (e.g. v1.33.0)" | ||
revision: | ||
description: "Revision to build and publish clients (e.g. 1.33.0-a3j4456-1)" | ||
required: true | ||
type: string | ||
check_sum: | ||
description: "Checksum of the OAS specification" | ||
required: true | ||
type: string | ||
workflow_dispatch: | ||
inputs: | ||
releaseTag: | ||
description: "Tag to release clients (e.g. cloud-agent-v1.33.0)" | ||
required: true | ||
required: false | ||
type: string | ||
revision: | ||
description: "Revision to build and publish clients (e.g. 1.33.0-a3j4456-1)" | ||
required: false | ||
type: string | ||
check_sum: | ||
description: "Checksum of the OAS specification" | ||
required: false | ||
type: string | ||
push: | ||
tags: | ||
- "cloud-agent-v*" | ||
|
||
permissions: | ||
contents: read | ||
contents: write | ||
packages: write | ||
|
||
jobs: | ||
publish-clients: | ||
name: "Build and publish Identus Cloud Agent clients" | ||
runs-on: ubuntu-latest | ||
env: | ||
VERSION_TAG: ${{inputs.releaseTag || github.ref_name}} | ||
GITHUB_ACTOR: "hyperledger-bot" | ||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | ||
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
@@ -60,6 +73,29 @@ jobs: | |
- name: Setup yq - portable yaml processor | ||
uses: mikefarah/[email protected] | ||
|
||
- name: Delete existing Open API specification | ||
if: ${{ !inputs.releaseTag }} | ||
run: | | ||
echo "Current directory: $(pwd)" | ||
rm -f ./cloud-agent/service/api/http/cloud-agent-openapi-spec.yaml | ||
- name: Download OpenAPI specification | ||
if: ${{ !inputs.releaseTag }} | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: cloud-agent-openapi-spec-${{ inputs.check_sum }} | ||
path: ./cloud-agent/service/api/http | ||
|
||
- name: Rename OpenAPI specification | ||
working-directory: cloud-agent/service/api/http | ||
run: | | ||
mv cloud-agent-openapi-spec-${{ inputs.revision }}.yaml cloud-agent-openapi-spec.yaml | ||
- name: Set revision version | ||
if: ${{ !inputs.releaseTag }} | ||
working-directory: cloud-agent/client/generator | ||
run: yarn version --new-version ${{ inputs.revision }} --no-git-tag-version | ||
|
||
- name: Install generator dependencies | ||
working-directory: cloud-agent/client/generator | ||
run: yarn install | ||
|
@@ -68,6 +104,23 @@ jobs: | |
working-directory: cloud-agent/client/generator | ||
run: yarn generate:all | ||
|
||
- name: Set version for clients | ||
run: | | ||
if [ -z "${{ github.event.inputs.releaseTag }}" ]; then | ||
echo "VERSION_TAG=cloud-agent-v${{ inputs.revision }}" >> $GITHUB_ENV | ||
else | ||
echo "VERSION_TAG=${{ github.event.inputs.releaseTag }}" >> $GITHUB_ENV | ||
fi | ||
- name: Publish clients | ||
working-directory: cloud-agent/client/generator | ||
run: yarn publish:clients | ||
env: | ||
VERSION_TAG: ${{ env.VERSION_TAG }} | ||
run: | | ||
if [ -z "${{ github.event.inputs.releaseTag }}" ]; then | ||
echo "Using revision version for publishing: ${VERSION_TAG}" | ||
yarn publish:clients | ||
else | ||
echo "Using release tag for publishing: ${VERSION_TAG}" | ||
yarn publish:clients | ||
fi |