-
Notifications
You must be signed in to change notification settings - Fork 74
130 lines (115 loc) · 4.47 KB
/
go-bindings.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
name: Go Bindings
on:
push:
branches: [ main ]
tags: [ v** ]
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
ci_checks:
name: Build checks
uses: ./.github/workflows/ci-checks.yml
build:
name: Build Go bindings
needs: ci_checks
runs-on: ubuntu-latest
strategy:
matrix:
apiver: [apiv1, apiv2]
steps:
- name: Checkout (build)
uses: actions/checkout@v3
with:
path: build
- name: Checkout (publish)
uses: actions/checkout@v3
with:
repository: ${{ matrix.apiver == 'apiv1' && 'hyperledger/fabric-protos-go' || 'hyperledger/fabric-protos-go-apiv2' }}
path: publish-${{ matrix.apiver }}
- name: Cache apiv1 build dependencies
uses: actions/cache@v3
if: matrix.apiver == 'apiv1'
env:
cache-name: makefile-deps
with:
path: ~/.cache/fabric-protos-apiv1
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Makefile.apiv1') }}
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('Makefile.apiv1') }}
${{ runner.os }}-${{ env.cache-name }}-
- name: Cache apiv2 build dependencies
uses: actions/cache@v3
if: matrix.apiver == 'apiv2'
env:
cache-name: makefile-deps
with:
path: ~/.cache/fabric-protos
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Makefile') }}
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('Makefile') }}
${{ runner.os }}-${{ env.cache-name }}-
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.20.2
check-latest: true
cache: true
cache-dependency-path: build/bindings/go-${{ matrix.apiver }}/go.sum
- name: Run make
run: make -f $MAKEFILE_NAME genprotos
working-directory: build
env:
MAKEFILE_NAME: ${{ matrix.apiver == 'apiv1' && 'Makefile.apiv1' || 'Makefile' }}
- name: Get commit message
run: echo "::set-output name=COMMIT_MESSAGE::$(git log --format=%B -n 1 $GITHUB_SHA)"
id: get-commit-message
working-directory: build
- name: Create publish commit
run: |
git config --global user.email "[email protected]"
git config --global user.name "hyperledger-bot"
# delete everything except the .git directory!
find . -mindepth 1 -maxdepth 1 -name '.git' -prune -o -exec rm -rf {} \;
cp -a ../build/bindings/$BINDINGS_DIR/. .
git add -A
git diff --cached --quiet || git commit -m "$COMMIT_MESSAGE" --no-edit
git status
git log --name-status
working-directory: publish-${{ matrix.apiver }}
env:
BINDINGS_DIR: go-${{ matrix.apiver }}
COMMIT_MESSAGE: ${{ steps.get-commit-message.outputs.COMMIT_MESSAGE }}
- name: Set up apiv1 deploy key
run: |
../build/.github/scripts/installDeployKey.sh fabric-protos-go $FABRIC_PROTOS_GO_DEPLOY_KEY
touch "${HOME}/.ssh/known_hosts"
ssh-keyscan -H github.com >> "${HOME}/.ssh/known_hosts"
git remote set-url origin [email protected]:hyperledger/fabric-protos-go.git
if: github.event_name != 'pull_request' && matrix.apiver == 'apiv1'
working-directory: publish-${{ matrix.apiver }}
env:
FABRIC_PROTOS_GO_DEPLOY_KEY: ${{ secrets.FABRIC_PROTOS_GO_DEPLOY_KEY }}
- name: Set up apiv2 deploy key
run: |
../build/.github/scripts/installDeployKey.sh fabric-protos-go-apiv2 $FABRIC_PROTOS_GO_APIV2_DEPLOY_KEY
touch "${HOME}/.ssh/known_hosts"
ssh-keyscan -H github.com >> "${HOME}/.ssh/known_hosts"
git remote set-url origin [email protected]:hyperledger/fabric-protos-go-apiv2.git
if: github.event_name != 'pull_request' && matrix.apiver == 'apiv2'
working-directory: publish-${{ matrix.apiver }}
env:
FABRIC_PROTOS_GO_APIV2_DEPLOY_KEY: ${{ secrets.FABRIC_PROTOS_GO_APIV2_DEPLOY_KEY }}
- name: Push GitHub publish commit
run: |
git push origin
if: github.ref == 'refs/heads/main'
working-directory: publish-${{ matrix.apiver }}
- name: Tag commit
run: |
git tag v${BINDING_VERSION}
git push origin v${BINDING_VERSION}
if: needs.ci_checks.outputs.publish_release == 'true'
working-directory: publish-${{ matrix.apiver }}
env:
BINDING_VERSION: ${{ needs.ci_checks.outputs.binding_version }}