-
Notifications
You must be signed in to change notification settings - Fork 2
283 lines (259 loc) · 9.21 KB
/
release.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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
name: release
on:
push:
tags:
- 'v*.*.*'
branches:
- main
pull_request:
branches:
- main
env:
APP_NAME: 'manticore-buddy'
MAINTAINER: 'Manticore'
DESC: 'Manticore Buddy'
LIBCURL_NAME: 'libcurl'
LIBCURL_VERSION: '7.29.0'
jobs:
vars:
runs-on: ubuntu-22.04
outputs:
app_version: ${{ steps.vars.outputs.app_version }}
app_date: ${{ steps.vars.outputs.app_date }}
app_commit: ${{ steps.vars.outputs.app_commit }}
rpm_suffix: ${{ steps.vars.outputs.rpm_suffix }}
deb_suffix: ${{ steps.vars.outputs.deb_suffix }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.head_ref || github.ref }}
- id: vars
run: |
version=$(<APP_VERSION)
date=$( date +%y%m%d%H )
commit=${{ github.event.pull_request.head.sha || github.sha }}
commit=${commit:0:7}
echo "app_version=$version" >> $GITHUB_OUTPUT
echo "app_date=$date" >> $GITHUB_OUTPUT
echo "app_commit=$commit" >> $GITHUB_OUTPUT
echo "rpm_suffix=_${date}.$commit" >> $GITHUB_OUTPUT
echo "deb_suffix=-${date}-$commit" >> $GITHUB_OUTPUT
build-artifact:
if: ${{ github.event_name != 'pull_request' }}
runs-on: ubuntu-22.04
needs:
- vars
steps:
- uses: actions/checkout@v3
- name: Prepare release directory
run: |
git clone https://github.com/manticoresoftware/phar_builder.git
./phar_builder/bin/build --name="Manticore Buddy" --package="${{ env.APP_NAME }}"
- uses: manticoresoftware/upload_artifact_with_retries@main
with:
name: version
path: ${{ github.workspace }}
- name: Create artifact
run: |
name="${{ env.APP_NAME }}_${{ needs.vars.outputs.app_version }}${{ needs.vars.outputs.rpm_suffix }}"
echo "$name"
mkdir build/bin
cp build/${{ env.APP_NAME }} build/bin/${{ env.APP_NAME }}
tar czf "$name.tar.gz" -C build bin/${{ env.APP_NAME }} share
cd build
zip -r "$name.zip" share/modules
mv "$name.zip" ..
cd ..
shell: bash
- uses: manticoresoftware/upload_artifact_with_retries@main
with:
name: artifact
path: ./*.{tar.gz,zip}
build-linux-packages:
runs-on: ubuntu-22.04
needs:
- vars
steps:
- uses: actions/checkout@v3
- name: Build binary
run: |
git clone https://github.com/manticoresoftware/phar_builder.git
./phar_builder/bin/build --name="Manticore Buddy" --package="${{ env.APP_NAME }}"
- name: Prepare packages structure
run: |
mkdir -p .debpkg/usr/share/manticore/modules/${{ env.APP_NAME }}/bin
mkdir -p .rpmpkg/usr/share/manticore/modules/${{ env.APP_NAME }}/bin
cp -rp build/share/modules/${{ env.APP_NAME }}/* .debpkg/usr/share/manticore/modules/${{ env.APP_NAME }}/
cp -rp build/share/modules/${{ env.APP_NAME }}/* .rpmpkg/usr/share/manticore/modules/${{ env.APP_NAME }}/
cp -r build/${{ env.APP_NAME }} .debpkg/usr/share/manticore/modules/${{ env.APP_NAME }}/bin/${{ env.APP_NAME }}
cp -r build/${{ env.APP_NAME }} .rpmpkg/usr/share/manticore/modules/${{ env.APP_NAME }}/bin/${{ env.APP_NAME }}
sudo chown -R root:root .debpkg
sudo chown -R root:root .rpmpkg
- uses: manticoresoftware/actions-build-deb-action@master
name: Build DEB packages
with:
package: ${{ env.APP_NAME }}
package_root: .debpkg
maintainer: ${{ env.MAINTAINER }}
version: ${{ needs.vars.outputs.app_version }}${{ needs.vars.outputs.deb_suffix }}
arch: 'all'
desc: '${{ env.DESC }}'
depends: '${{ env.LIBCURL_NAME }}4 (>= ${{ env.LIBCURL_VERSION}})'
- name: Build RPM packages
run: |
sudo apt-get update -y -q
sudo apt-get install -y rpm
RPMBUILD_DIR="$HOME/rpmbuild"
RPMBUILD_SOURCE_DIR="$RPMBUILD_DIR/SOURCES"
RPMBUILD_SPEC_DIR="$RPMBUILD_DIR/SPECS"
WORKDIR="/tmp/work"
mkdir "$WORKDIR"
spec_file=rpm.spec
cp "packages/$spec_file" "$WORKDIR"
cp -rp ".rpmpkg" "$WORKDIR/${{ env.APP_NAME }}"
cd "$WORKDIR"
# Prepare spec file for RPM
sed -i 's/{{ NAME }}/${{ env.APP_NAME }}/g' $spec_file
sed -i 's/{{ VERSION }}/${{ needs.vars.outputs.app_version }}${{ needs.vars.outputs.rpm_suffix }}/g' $spec_file
sed -i 's/{{ MAINTAINER }}/${{ env.MAINTAINER }}/g' $spec_file
sed -i 's/{{ DESC }}/${{ env.DESC }}/g' $spec_file
sed -i 's/{{ LIBCURL_NAME }}/${{ env.LIBCURL_NAME }}/g' $spec_file
sed -i 's/{{ LIBCURL_VERSION }}/v${{ env.LIBCURL_VERSION }}/g' $spec_file
tar czf tmp.tar.gz "${{ env.APP_NAME }}/"
mkdir -p "$RPMBUILD_SOURCE_DIR"
mkdir -p "$RPMBUILD_SPEC_DIR"
mv tmp.tar.gz "$RPMBUILD_SOURCE_DIR"
cp -p $spec_file "$RPMBUILD_SPEC_DIR"
rpmbuild -bb "$RPMBUILD_SPEC_DIR/$spec_file"
ls -lah "$RPMBUILD_DIR/RPMS/noarch"/*.rpm
cp -p "$RPMBUILD_DIR/RPMS/noarch"/*.rpm $GITHUB_WORKSPACE
- name: Rename packages to proper name
run: |
ls -la ./*.rpm
version=${{ needs.vars.outputs.app_version }}${{ needs.vars.outputs.rpm_suffix }}
rpm_path="./${{ env.APP_NAME }}-${version}-1.noarch.rpm"
cp $rpm_path "./${{ env.APP_NAME }}-${version}-1.el7.noarch.rpm"
cp $rpm_path "./${{ env.APP_NAME }}-${version}-1.el8.noarch.rpm"
cp $rpm_path "./${{ env.APP_NAME }}-${version}-1.el9.noarch.rpm"
ls -la ./*.deb
version=${{ needs.vars.outputs.app_version }}${{ needs.vars.outputs.deb_version }}
- uses: manticoresoftware/upload_artifact_with_retries@main
with:
name: artifact-deb
path: ./*_all.deb
- uses: manticoresoftware/upload_artifact_with_retries@main
with:
name: artifact-el7-rpm
path: ./*.el7.noarch.rpm
- uses: manticoresoftware/upload_artifact_with_retries@main
with:
name: artifact-el8-rpm
path: ./*.el8.noarch.rpm
- uses: manticoresoftware/upload_artifact_with_retries@main
with:
name: artifact-el9-rpm
path: ./*.el9.noarch.rpm
create-release:
runs-on: ubuntu-22.04
needs:
- build-artifact
- build-linux-packages
if: startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Generate changelog
run: |
bin/git-changelog > ./changelog
- name: Create Release
id: create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body_path: ./changelog
draft: true
prerelease: false
deploy:
if: ${{ github.event_name != 'pull_request' }}
needs:
- build-artifact
- build-linux-packages
runs-on: ubuntu-22.04
strategy:
matrix:
include:
- artifact: artifact-deb
type: deb
arch: all
delimiter: "-"
distro: buster
- artifact: artifact-deb
type: deb
arch: all
delimiter: "-"
distro: bionic
- artifact: artifact-deb
type: deb
arch: all
delimiter: "-"
distro: focal
- artifact: artifact-deb
type: deb
arch: all
delimiter: "-"
distro: jammy
- artifact: artifact-deb
type: deb
arch: all
delimiter: "-"
distro: bullseye
- artifact: artifact-deb
type: deb
arch: all
delimiter: "-"
distro: bookworm
- artifact: artifact-el7-rpm
type: rpm
arch: noarch
delimiter: "_"
distro: 7
- artifact: artifact-el8-rpm
type: rpm
arch: noarch
delimiter: "_"
distro: 8
- artifact: artifact-el9-rpm
type: rpm
arch: noarch
delimiter: "_"
distro: 9
- artifact: artifact
type: arc
arch: noarch
delimiter: "_"
distro: ""
steps:
- name: Deploy package
uses: manticoresoftware/publish_to_repo@main
with:
ssh_key: ${{ secrets.REPO_SSH_KEY }}
distr: ${{ matrix.distro }}
arch: ${{ matrix.arch }}
artifact: ${{ matrix.artifact }}
type: ${{ matrix.type }}
delimiter: ${{ matrix.delimiter }}
update-manticoresearch-deps:
needs:
- vars
runs-on: ubuntu-22.04
steps:
- name: Update deps
uses: manticoresoftware/manticoresearch/actions/update-deps@master
with:
name: buddy
version: "${{ needs.vars.outputs.app_version }} ${{ needs.vars.outputs.app_date }} ${{ needs.vars.outputs.app_commit }}"
token: ${{ secrets.PR_TOKEN }}