-
Notifications
You must be signed in to change notification settings - Fork 23
146 lines (123 loc) · 5 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
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 }}