Skip to content

Build and Publish Cloud-Agent Revision from main run 62 #62

Build and Publish Cloud-Agent Revision from main run 62

Build and Publish Cloud-Agent Revision from main run 62 #62

Workflow file for this run

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: 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"
GITHUB_ACTOR_EMAIL: "[email protected]"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
JAVA_TOOL_OPTIONS: -Djava.net.preferIPv4Stack=true
SBT_OPTS: -Xmx2G
runs-on: ubuntu-latest
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
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Setup Java and Scala
uses: olafurpg/setup-scala@v14
with:
java-version: [email protected]
- uses: coursier/cache-action@v6
id: coursier-cache
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "lts/*"
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ env.GITHUB_ACTOR }}
password: ${{ env.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Get short commit hash
run: |
echo "COMMIT_HASH=${GITHUB_SHA::7}" >> $GITHUB_ENV
- name: Set build number
run: echo "BUILD_NUMBER=${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV
- name: Extract version from version.sbt
id: get_version
run: |
VERSION=$(grep -Eo 'version := "[^"]+"' version.sbt | sed 's/version := "//; s/"//; s/-SNAPSHOT//')
REVISION_VERSION=${VERSION}-${{ env.COMMIT_HASH }} # Revision version is used for the OAS file name and client libraries
BUILD_VERSION=${VERSION}-${{ env.BUILD_NUMBER }}-${{ env.COMMIT_HASH }} # Build version is used for the Docker image tag
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "REVISION_VERSION=${REVISION_VERSION}" >> $GITHUB_ENV
echo "BUILD_VERSION=${BUILD_VERSION}" >> $GITHUB_ENV
- name: Build and push Docker image
run: |
sbt "set version := \"${{ env.BUILD_VERSION }}\"" "docker:stage"
docker buildx build --platform=linux/arm64,linux/amd64 --push -t ghcr.io/hyperledger/identus-cloud-agent:${{ env.BUILD_VERSION}} ./cloud-agent/service/server/target/docker/stage
- name: Trigger helm chart update
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.ATALA_GITHUB_TOKEN }}
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 }}