Build and Publish Revision #30
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
name: Build and Publish Revision | ||
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 Revision(${{ github.sha.slice(0, 7) }}) | ||
Check failure on line 31 in .github/workflows/build.yml GitHub Actions / Build and Publish RevisionInvalid workflow file
|
||
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 }} | ||
BUILD_VERSION=${REVISION_VERSION}-${{ env.BUILD_NUMBER }} | ||
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 }} |