-
Notifications
You must be signed in to change notification settings - Fork 243
151 lines (132 loc) · 5.49 KB
/
nightly-build.yaml
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
name: Nightly builds
on:
# workflow_dispatch so that it can be triggered manually if needed
workflow_dispatch:
schedule:
- cron: "34 21 * * *"
concurrency: ${{ github.workflow }}
env:
IBM_CLOUD_API_KEY: ${{ secrets.IBM_CLOUD_API_KEY_NIGHTLY_BUILDS }}
IBM_CLOUD_RESOURCE_GROUP: ${{ secrets.IBM_CLOUD_RESOURCE_GROUP }}
IBM_CLOUD_REGION: eu-de
IBM_CLOUD_OBJET_STORAGE_SERVICE_INSTANCE: ${{ secrets.IBM_CLOUD_OBJET_STORAGE_SERVICE_INSTANCE }}
IBM_CLOUD_OBJECT_STORAGE_BUCKET: ${{ secrets.IBM_CLOUD_OBJECT_STORAGE_BUCKET }}
jobs:
check_bucket:
runs-on: ubuntu-latest
steps:
- name: Install IBM Cloud CLI
run: |
curl -fsSL https://clis.cloud.ibm.com/install/linux | sh
ibmcloud --version
ibmcloud config --check-version=false
ibmcloud plugin install -f cloud-object-storage
- name: Authenticate with IBM Cloud CLI
run: |
ibmcloud login --apikey "${IBM_CLOUD_API_KEY}" -r "${IBM_CLOUD_REGION}" -g "${IBM_CLOUD_RESOURCE_GROUP}" --quiet
- name: Set CRN
run: |
CRN=$(ibmcloud resource service-instance "${IBM_CLOUD_OBJET_STORAGE_SERVICE_INSTANCE}" --output json | jq -r '.[0].guid | values')
if [[ -z "$CRN" ]]; then
echo "Unable to determine CRN for service instance ${IBM_CLOUD_OBJET_STORAGE_SERVICE_INSTANCE}"
exit 1
fi
ibmcloud cos config crn --crn "${CRN}"
- name: Check if bucket exists
run: |
if ! ibmcloud cos buckets | grep "${IBM_CLOUD_OBJECT_STORAGE_BUCKET}"; then
echo "Bucket not found: ${IBM_CLOUD_OBJECT_STORAGE_BUCKET}"
exit 1
fi
build_for_platform:
runs-on: ubuntu-latest
needs: check_bucket
strategy:
fail-fast: false
matrix:
os: [linux, darwin, windows]
arch: [amd64, arm64, ppc64le, s390x]
exclude:
- os: darwin
arch: ppc64le
- os: darwin
arch: s390x
- os: windows
arch: arm64
- os: windows
arch: ppc64le
- os: windows
arch: s390x
name: "${{ matrix.os }}-${{ matrix.arch }}"
env:
GOOS: ${{ matrix.os }}
GOARCH: ${{ matrix.arch }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Get commit ID
run: |
sha=$(git describe --no-match --always --abbrev=9 --dirty --broken 2>/dev/null || git rev-parse --short HEAD 2>/dev/null)
echo "SHORT_SHA=${sha}" >> "$GITHUB_ENV"
- name: Cross-compile
env:
PROJECT: "github.com/redhat-developer/odo"
RELEASE_SEGMENT_WRITE_KEY: ${{ secrets.RELEASE_SEGMENT_WRITE_KEY }}
run: |
version="${{ env.SHORT_SHA }}-nightly"
binNameNoExt="odo-$GOOS-$GOARCH"
binName="${binNameNoExt}"
binNameWithSha="${binNameNoExt}-${{ env.SHORT_SHA }}"
if [ $GOOS == "windows" ]; then
binName="${binName}.exe"
binNameWithSha="${binNameWithSha}.exe"
fi
go build -o "$binName" \
-mod=vendor \
-ldflags="-s -w -X ${PROJECT}/pkg/segment.writeKey=${RELEASE_SEGMENT_WRITE_KEY} -X ${PROJECT}/pkg/version.GITCOMMIT=${version}" \
./cmd/odo/
cp -vr "$binName" "${binNameWithSha}"
- name: Generate archive
run: |
if [ $GOOS == "windows" ]; then
zip -9 -y -r -q "odo-${GOOS}-${GOARCH}.zip" "odo-${GOOS}-${GOARCH}.exe"
zip -9 -y -r -q "odo-${GOOS}-${GOARCH}-${{ env.SHORT_SHA }}.zip" "odo-${GOOS}-${GOARCH}-${{ env.SHORT_SHA }}.exe"
else
tar -czvf "odo-${GOOS}-${GOARCH}.tar.gz" "odo-${GOOS}-${GOARCH}"
tar -czvf "odo-${GOOS}-${GOARCH}-${{ env.SHORT_SHA }}.tar.gz" "odo-${GOOS}-${GOARCH}-${{ env.SHORT_SHA }}"
fi
- name: Generate SHA-256 checksums
run: |
for f in `find . -type f -name 'odo-${{ matrix.os }}-${{ matrix.arch }}*'`; do
bin=$(realpath "$f")
sha256sum -b "${bin}" | awk '{print $1}' > "${bin}".sha256
done
- name: Install IBM Cloud CLI
run: |
curl -fsSL https://clis.cloud.ibm.com/install/linux | sh
ibmcloud --version
ibmcloud config --check-version=false
ibmcloud plugin install -f cloud-object-storage
- name: Authenticate with IBM Cloud CLI
run: |
ibmcloud login --apikey "${IBM_CLOUD_API_KEY}" -r "${IBM_CLOUD_REGION}" -g "${IBM_CLOUD_RESOURCE_GROUP}" --quiet
- name: Set CRN
run: |
CRN=$(ibmcloud resource service-instance "${IBM_CLOUD_OBJET_STORAGE_SERVICE_INSTANCE}" --output json | jq -r '.[0].guid | values')
if [[ -z "$CRN" ]]; then
echo "Unable to determine CRN for service instance ${IBM_CLOUD_OBJET_STORAGE_SERVICE_INSTANCE}"
exit 1
fi
ibmcloud cos config crn --crn "${CRN}"
- name: Upload binaries
run: |
baseUrl="https://s3.${IBM_CLOUD_REGION}.cloud-object-storage.appdomain.cloud/${IBM_CLOUD_OBJECT_STORAGE_BUCKET}"
for f in `find . -type f -name 'odo-${{ matrix.os }}-${{ matrix.arch }}*'`; do
bin=$(realpath "$f")
ibmcloud cos upload --bucket "${IBM_CLOUD_OBJECT_STORAGE_BUCKET}" --key $(basename "$f") --file "${bin}"
echo "Binary $bin uploaded successfully and available at: ${baseUrl}/$(basename "$f")"
done