-
Notifications
You must be signed in to change notification settings - Fork 312
175 lines (152 loc) · 4.96 KB
/
build-packages.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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
name: Build packages
# Big chunk of the build process logic is in the mage build targets
on:
workflow_call:
push:
branches: [master]
tags:
env:
GITHUB_OWNER: mysteriumnetwork
GITHUB_REPO: node
GITHUB_SNAPSHOT_REPO: node-builds
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_EC2_METADATA_DISABLED: true # disable AWS region lookup
jobs:
setup-env:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.21.x'
- name: Prepare environment
run: |
RELEASE_BUILD=false
if [[ "${GITHUB_REF}" == /refs/tags/* ]]; then RELEASE_BUILD=true; fi
RC_BUILD=false
if [[ "${GITHUB_REF}" == /refs/tags/*-rc ]]; then RC_BUILD=true; fi
SNAPSHOT_BUILD=false
if [[ "${GITHUB_REF}" == "refs/heads/master" ]]; then SNAPSHOT_BUILD=true; fi
PR_BUILD=false
if [[ "${SNAPSHOT_BUILD}" == "false" && "${RELEASE_BUILD}" == "false" ]]; then PR_BUILD=true; fi
if [[ "${RELEASE_BUILD}" == "true" ]]; then
BUILD_VERSION="${GITHUB_REF#/refs/tags/}";
elif [[ "${SNAPSHOT_BUILD}" == "true" ]]; then
BUILD_VERSION="$(git describe --abbrev=0 --tags)"-1snapshot-"$(date '+%Y%m%dT%H%M')"-"$(echo ${GITHUB_SHA} | cut -c1-8)";
elif [[ "${PR_BUILD}" == "true" ]]; then
BRANCH="${GITHUB_HEAD_REF////-}"
if [[ "${BRANCH}" == "" ]]; then BRANCH="${GITHUB_REF_NAME}"; fi
BUILD_VERSION="$(git describe --abbrev=0 --tags)"-1branch-"${BRANCH}";
fi
cat <<EOT >> env.sh
export RELEASE_BUILD=$RELEASE_BUILD;
export RC_BUILD=$RC_BUILD;
export PR_BUILD=$PR_BUILD;
export SNAPSHOT_BUILD=$SNAPSHOT_BUILD;
export BUILD_VERSION=$BUILD_VERSION;
export BUILD_NUMBER="${{ github.run_id }}"-ghactions;
export BUILD_COMMIT="$(echo ${GITHUB_SHA} | cut -c1-8)";
export BUILD_BRANCH="${GITHUB_REF_NAME}";
EOT
- uses: actions/upload-artifact@v4
with:
name: env.sh
path: env.sh
- name: Create bucket
if: |
github.ref == 'refs/heads/master' ||
github.ref_type == 'tag'
run: |
source env.sh
go run mage.go -v MakeBucket
build-packages:
runs-on: ubuntu-latest
needs: [setup-env]
strategy:
max-parallel: 6
matrix:
platform:
- PackageLinuxRaspberryImage
- PackageLinuxAmd64
- PackageLinuxArm
- PackageLinuxDebianAmd64
- PackageLinuxDebianArm64
- PackageLinuxDebianArm
- PackageMacOSAmd64
- PackageMacOSArm64
- PackageWindowsAmd64
- PackageAndroid
- PackageAndroidProvider
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.21.x'
- uses: actions/download-artifact@v4
with:
name: env.sh
- name: Setup FPM
run: |
sudo apt-get install ruby-dev build-essential
sudo gem i fpm -f
- name: Build package
run: |
source env.sh
unset CI # workaround for "PackageAndroid" target
sudo -E go run mage.go -v ${{ matrix.platform }}
build-swagger:
runs-on: ubuntu-latest
needs: [setup-env, build-packages]
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.21.x'
- uses: actions/download-artifact@v4
with:
name: env.sh
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build docker
run: |
source env.sh
go run mage.go -v PackageDockerSwaggerRedoc
release:
needs: [build-packages, build-swagger]
uses: ./.github/workflows/release.yml
secrets: inherit
if: |
github.ref == 'refs/heads/master' ||
github.ref_type == 'tag'
cleanup-env:
runs-on: ubuntu-latest
needs: [release]
if: |
always() &&
(github.ref == 'refs/heads/master' || github.ref_type == 'tag')
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.21.x'
- uses: actions/download-artifact@v4
with:
name: env.sh
- name: Remove bucket
run: |
source env.sh
go run mage.go -v RemoveBucket || true # ignore if bucket was not available