-
Notifications
You must be signed in to change notification settings - Fork 0
100 lines (88 loc) · 3.32 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
name: Build
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
jobs:
build:
runs-on: [ self-hosted, "${{ matrix.archconfig }}", go]
strategy:
matrix:
archconfig: [ x86_64, aarch64 ]
fail-fast: false
steps:
- name: Cleanup previous jobs
run: |
echo "Cleaning up previous runs"
sudo rm -rf ${{ github.workspace }}/*
sudo rm -rf ${{ github.workspace }}/.??*
- name: Checkout code
uses: actions/checkout@v3
- name: Display Go version
run: |
go version
- name: Find SHA
run: |
if [[ "${{github.event.pull_request.head.sha}}" != "" ]]
then
echo "ARTIFACT_SHA=$(echo ${{ github.event.pull_request.head.sha }})" >> $GITHUB_ENV
#echo "ARTIFACT_SHA=$(echo ${GITHUB_SHA})" >> $GITHUB_ENV
else
echo "ARTIFACT_SHA=$(echo ${GITHUB_REF##*/})" >> $GITHUB_ENV
fi
- name: Build bima binaries
run: |
mkdir -p ./dist
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-s -w" -ldflags "-w" -ldflags "-linkmode 'external' -extldflags '-static'" \
-ldflags "-X main.version=${VERSION}" -o ./dist/bima_x86_64 ./cmd/bima
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -ldflags "-s -w" -ldflags "-w" -ldflags "-linkmode 'external' -extldflags '-static'" \
-ldflags "-X main.version=${VERSION}" -o ./dist/bima_aarch64 ./cmd/bima
- name: Upload bima_x86_64 to S3
if: matrix.archconfig == 'x86_64' && ${{ github.event.pull_request.user.login != 'dependabot[bot]' }}
uses: cloudkernels/minio-upload@v3
with:
url: https://s3.nubificus.co.uk
access-key: ${{ secrets.AWS_ACCESS_KEY }}
secret-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
local-path: dist/bima_x86_64
remote-path: nbfc-assets/github/bima/dist/${{ env.ARTIFACT_SHA }}/${{ matrix.archconfig }}/
policy: 1
- name: Upload bima_aarch64 to S3
if: matrix.archconfig == 'aarch64' && ${{ github.event.pull_request.user.login != 'dependabot[bot]' }}
uses: cloudkernels/minio-upload@v3
with:
url: https://s3.nubificus.co.uk
access-key: ${{ secrets.AWS_ACCESS_KEY }}
secret-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
local-path: dist/bima_aarch64
remote-path: nbfc-assets/github/bima/dist/${{ env.ARTIFACT_SHA }}/${{ matrix.archconfig }}/
policy: 1
invoke_test:
needs: build
runs-on: [self-hosted]
steps:
- name: Find SHA
run: |
if [[ "${{github.event.pull_request.head.sha}}" != "" ]]
then
echo "ARTIFACT_NAME=$(echo ${{ github.event.pull_request.head_sha }})" >> $GITHUB_ENV
#echo "ARTIFACT_NAME=$(echo ${GITHUB_SHA})" >> $GITHUB_ENV
else
echo "ARTIFACT_NAME=$(echo ${GITHUB_REF##*/})" >> $GITHUB_ENV
fi
#- name: Repository Dispatch
# uses: peter-evans/repository-dispatch@v1
# with:
# token: ${{ secrets.GITHUB_TOKEN}}
# event-type: my-event
- name: Invoke workflow
uses: benc-uk/workflow-dispatch@v1
with:
workflow: "Test bima"
token: ${{ secrets.GITHUB_TOKEN }}
ref: ${{ github.event.pull_request.head.ref }}
inputs: "{ \"artifact\": \"${{ env.ARTIFACT_NAME }}\" }"