-
Notifications
You must be signed in to change notification settings - Fork 31
155 lines (140 loc) · 4.82 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
147
148
149
150
151
152
153
154
155
#
# Copyright SecureKey Technologies Inc. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
name: "build"
env:
GO_VERSION: '1.22'
on:
push:
pull_request:
jobs:
SemanticPullRequest:
name: Semantic Pull Request Check
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Checks:
runs-on: ubuntu-20.04
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '${{ env.GO_VERSION }}'
- name: Run checks
run: |
echo $PATH
go env
echo ${{ github.workspace }}
make checks
UnitTest:
runs-on: ubuntu-20.04
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '${{ env.GO_VERSION }}'
- name: Run unit tests
run: make unit-test
- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_UPLOAD_TOKEN }}
verbose: true
BDDTest:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '${{ env.GO_VERSION }}'
- run: sudo apt-get update && sudo apt install docker-compose -y
- name: Run BDD tests
run: |
echo '127.0.0.1 file-server.trustbloc.local' | sudo tee -a /etc/hosts
echo '127.0.0.1 did-resolver.trustbloc.local' | sudo tee -a /etc/hosts
echo '127.0.0.1 oidc-provider.example.com' | sudo tee -a /etc/hosts
echo '127.0.0.1 vc-rest-echo.trustbloc.local' | sudo tee -a /etc/hosts
echo '127.0.0.1 api-gateway.trustbloc.local' | sudo tee -a /etc/hosts
echo '127.0.0.1 cognito-mock.trustbloc.local' | sudo tee -a /etc/hosts
echo '127.0.0.1 mock-login-consent.example.com' | sudo tee -a /etc/hosts
echo '127.0.0.1 cognito-auth.local' | sudo tee -a /etc/hosts
echo '127.0.0.1 mock-trustregistry.trustbloc.local' | sudo tee -a /etc/hosts
echo '127.0.0.1 mock-attestation.trustbloc.local' | sudo tee -a /etc/hosts
make bdd-test
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish:
name: Publish image
if: github.event_name == 'push' && (github.repository == 'trustbloc/vcs' && github.ref == 'refs/heads/main')
needs: [Checks, UnitTest, BDDTest]
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- name: Setup Go 1.22
uses: actions/setup-go@v2
with:
go-version: '1.22'
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
- name: Get current published version
run: |
TAG=$(git describe --tags --always `git rev-list --tags --max-count=1`)
VERSION=$(git rev-parse --short=7 HEAD)
if [[ $TAG == $VERSION ]]; then
TAG=v0.0.0
fi
echo "CURRENT_SEMVER=${TAG:1}" >> $GITHUB_ENV
- name: Bump published version
id: bump_version
uses: christian-draeger/[email protected]
with:
current-version: "${{ env.CURRENT_SEMVER }}"
version-fragment: 'bug'
- name: Set ENV vars
run: |
VERSION=$(git rev-parse --short=7 HEAD)
echo "IMAGE_TAG"=v${{ steps.bump_version.outputs.next-version }}-snapshot-$VERSION >> $GITHUB_ENV
echo "VCS_IMAGE_PREFIX"=ghcr.io/trustbloc-cicd/vc-server >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Github Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ secrets.CR_USER }}
password: ${{ secrets.CR_PAT }}
- name: Build and Push container vcs image
uses: docker/build-push-action@v2
with:
context: .
file: ./images/vc-rest/Dockerfile
platforms: linux/amd64,linux/arm64
build-args: |
ALPINE_VER=3.18
GO_VER=1.22
push: true
tags: |
${{ env.VCS_IMAGE_PREFIX }}:${{ env.IMAGE_TAG }}
${{ env.VCS_IMAGE_PREFIX }}:latest
- name: Build binaries
run: make build-wallet-cli-binaries
- uses: actions/upload-artifact@v2
with:
name: wallet-cli
path: |
./.build/dist/bin/wallet-cli-darwin-amd64.tar.gz
./.build/dist/bin/wallet-cli-linux-amd64.tar.gz
./.build/dist/bin/wallet-cli-linux-arm64.tar.gz
./.build/dist/bin/wallet-cli-darwin-arm64.tar.gz