-
-
Notifications
You must be signed in to change notification settings - Fork 38
198 lines (190 loc) · 8.37 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
on:
release:
types: [published]
permissions:
contents: write
packages: write
env:
github_token: ${{ secrets.GITHUB_TOKEN }}
github_repository: ${{ github.repository }}
release_tag: ${{ github.event.release.tag_name }}
package_name: swiftwave
homepage: https://swiftwave.org
license: Apache-2.0
summary: SwiftWave is a self-hosted lightweight PaaS solution to deploy and manage your applications on any VPS
maintainer: Tanmoy Sarkar <[email protected]>"
debian_architectures: "amd64,arm64,i386"
rpm_architectures: "x86_64,aarch64,i386"
go_archs: "amd64,arm64,386"
control_file: |
Package: $PACKAGE_NAME
Version: $RELEASE_VERSION
Architecture: $ARCH
Maintainer: $MAINTAINER
Description: $SUMMARY
Homepage: $HOMEPAGE
spec_file: |
Name: $PACKAGE_NAME
Version: $RELEASE_VERSION
Release: $RELEASE_NUMBER
Summary: $SUMMARY
Packager: $MAINTAINER
License: $LICENSE
URL: $HOMEPAGE
SOURCE0: $PACKAGE_NAME
%description
$SUMMARY
%install
mkdir -p %{buildroot}/usr/bin/
install -m 755 %{SOURCE0} %{buildroot}/usr/bin/$PACKAGE_NAME
%files
/usr/bin/$PACKAGE_NAME
%global __strip /bin/true
asset_builder_download_link: https://github.com/wangyoucao577/assets-uploader/releases/download/v0.13.0/github-assets-uploader-v0.13.0-linux-amd64.tar.gz
jobs:
debian-packager:
name: Package Debian Binary
runs-on: ubuntu-latest
steps:
- name: Setup Environment
run: |
release_tag="${{ env.release_tag }}"
release_version=$(echo "$release_tag" | cut -d'-' -f1)
release_number=$(echo "$release_tag" | cut -d'-' -f2)
echo "release_version=${release_version}" >> $GITHUB_ENV
echo "release_number=${release_number}" >> $GITHUB_ENV
wget -q -O - $asset_builder_download_link | sudo tar -xz -C /usr/bin/
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: recursive
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: 1.22.1
- name: Setup Node.js
uses: actions/setup-node@v4
- name: Build Dashboard
run: |
(rm -rf swiftwave_service/dashboard/www || true)
mkdir -p swiftwave_service/dashboard/www
cd dashboard
npm i
npm run build:prod
cd ..
cp -r dashboard/dist/* swiftwave_service/dashboard/www/
- name: Set Version
run: |
rm swiftwave_service/config/local_config/.version
echo "${{ github.event.release.tag_name }}" >> swiftwave_service/config/local_config/.version
- name: Create Directory to dump .deb
run: mkdir -p ~/deb_builds
- name: Build for all architectures
run: |
architectures=(${debian_architectures//,/ })
go_archs=(${go_archs//,/ })
for i in "${!architectures[@]}"; do
mkdir -p ~/deb_builds/${package_name}_${release_tag}_${architectures[$i]}/usr/bin
mkdir -p ~/deb_builds/${package_name}_${release_tag}_${architectures[$i]}/DEBIAN
GOOS=linux GOARCH=${go_archs[$i]} go build -o ${package_name} -buildvcs=false .
mv ${package_name} ~/deb_builds/${package_name}_${release_tag}_${architectures[$i]}/usr/bin
control_content="${control_file//\$PACKAGE_NAME/${package_name}}"
control_content="${control_content//\$RELEASE_VERSION/${release_version}}"
control_content="${control_content//\$ARCH/${architectures[$i]}}"
control_content="${control_content//\$LICENSE/${license}}"
control_content="${control_content//\$SUMMARY/${summary}}"
control_content="${control_content//\$HOMEPAGE/${homepage}}"
control_content="${control_content//\$MAINTAINER/${maintainer}}"
echo "$control_content" > ~/deb_builds/${package_name}_${release_tag}_${architectures[$i]}/DEBIAN/control
dpkg --build ~/deb_builds/${package_name}_${release_tag}_${architectures[$i]}
done
- name: Upload debian packages
run: |
for i in ~/deb_builds/*.deb; do
echo "Built: $i"
echo "Uploading $i"
/usr/bin/github-assets-uploader -f $i -mediatype application/octet-stream -token $github_token -overwrite -repo $github_repository -tag $release_tag
done
rpm-packager:
name: Package RPM Binary
runs-on: ubuntu-latest
container: almalinux:latest
steps:
- name: Setup Environment
run: |
IFS='-' read -ra version_parts <<< "${{ env.release_tag }}"
echo "release_version=${version_parts[0]}" >> $GITHUB_ENV
echo "release_number=${version_parts[1]}" >> $GITHUB_ENV
dnf install -y tree createrepo rpm-build rpm-sign wget gcc python3 yum-utils git-all
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install 20
wget -q -O - $asset_builder_download_link | tar -xz -C /usr/bin/
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: recursive
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: 1.22.1
- name: Build Dashboard
run: |
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
(rm -rf swiftwave_service/dashboard/www || true)
mkdir -p swiftwave_service/dashboard/www
cd dashboard
npm i
npm run build:prod
cd ..
cp -r dashboard/dist/* swiftwave_service/dashboard/www/
- name: Set Version
run: |
rm swiftwave_service/config/local_config/.version
echo "${{ github.event.release.tag_name }}" >> swiftwave_service/config/local_config/.version
- name: Build for all architectures
run: |
architectures=(${rpm_architectures//,/ })
go_archs=(${go_archs//,/ })
for i in "${!architectures[@]}"; do
mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
GOOS=linux GOARCH=${go_archs[$i]} go build -o ${package_name} -buildvcs=false .
chmod +x ${package_name}
mv ${package_name} ~/rpmbuild/SOURCES
spec_content="${spec_file//\$PACKAGE_NAME/${package_name}}"
spec_content="${spec_content//\$RELEASE_VERSION/${release_version}}"
spec_content="${spec_content//\$RELEASE_NUMBER/${release_number}}"
spec_content="${spec_content//\$SUMMARY/${summary}}"
spec_content="${spec_content//\$LICENSE/${license}}"
spec_content="${spec_content//\$HOMEPAGE/${homepage}}"
spec_content="${spec_content//\$MAINTAINER/${maintainer}}"
echo "$spec_content" > ~/rpmbuild/SPECS/${package_name}.spec
rpmbuild -bb ~/rpmbuild/SPECS/${package_name}.spec --target ${architectures[$i]}
cp ~/rpmbuild/RPMS/*/*.rpm ~/
rm -rf ~/rpmbuild/*
done
- name: Print Build Info
run: |
for i in ~/*.rpm; do
echo "Built: $i"
rpm -qip $i
done
- name: Upload RPM packages
run: |
for i in ~/*.rpm; do
echo "Built: $i"
echo "Uploading $i"
/usr/bin/github-assets-uploader -f $i -mediatype application/octet-stream -token $github_token -overwrite -repo $github_repository -tag $release_tag
done
trigger-package-repo:
name: Trigger package repo to update
runs-on: ubuntu-latest
needs: [debian-packager, rpm-packager]
if: ${{ !endsWith(github.event.release.tag_name,'-rc') }}
steps:
- name: Setup environment
run: |
TRIGGER_URL="http://update.repo.swiftwave.org/?repo_name=${github_repository}&release_tag=${release_tag}"
curl --header 'Authorization: ${{ secrets.PACKAGE_REPO_TRIGGER_TOKEN }}' $TRIGGER_URL