Repository navigation
161 lines (137 loc) · 4.9 KB
/
Copy pathci-cd.yml
File metadata and controls
161 lines (137 loc) · 4.9 KB
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
name: PolyOS Lab CI/CD Build & Release
on:
push:
branches:
- main
permissions:
contents: write
jobs:
build-and-release:
name: Build and Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Auto-increment Tag
run: |
VERSION_NUM=$(node -p "require('./dashboard/package.json').version")
NEW_TAG="v$VERSION_NUM"
echo "Determined version from package.json: $VERSION_NUM"
echo "tag_name=$NEW_TAG" >> $GITHUB_ENV
echo "version_num=$VERSION_NUM" >> $GITHUB_ENV
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
# Sync README.md version
node -e "
const fs = require('fs');
let readme = fs.readFileSync('README.md', 'utf8');
readme = readme.replace(/VERSIYON-[0-9.]+-blue/g, 'VERSIYON-$VERSION_NUM-blue');
fs.writeFileSync('README.md', readme);
"
# Commit updates back to main
git add README.md dashboard/package.json dashboard/package-lock.json || true
git commit -m "chore: release version $VERSION_NUM [skip ci]" || true
git push origin main || true
# Push the tag
git tag -d $NEW_TAG || true
git push origin :refs/tags/$NEW_TAG || true
git tag $NEW_TAG
git push origin $NEW_TAG
# 1. Set up Go & Build (Client only)
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.20'
cache-dependency-path: |
client/go.sum
- name: Run Go Vet & Test
run: |
cd client
go vet ./...
go test ./...
- name: Compile Go Binaries
run: |
cd client
GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o polyos-client .
# 2. Node.js & Electron/React Build (bundles polyos-server)
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
cache-dependency-path: dashboard/package-lock.json
- name: Build Teacher Dashboard (.deb)
run: |
cd dashboard
npm ci
npm run electron:build
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# 4. Create Client Debian Package (.deb) with Autostart & Systemd Daemon
- name: Package Client into .deb
run: |
VERSION=${{ env.version_num }}
PKG_DIR="polyos-client_${VERSION}_amd64"
mkdir -p $PKG_DIR/DEBIAN
mkdir -p $PKG_DIR/usr/bin
mkdir -p $PKG_DIR/lib/systemd/system
# Copy client binary
cp client/polyos-client $PKG_DIR/usr/bin/
# Create systemd service
cat <<EOF > $PKG_DIR/lib/systemd/system/polyos-client.service
[Unit]
Description=PolyOS Lab Client Service
After=network.target display-manager.service
[Service]
Type=simple
ExecStart=/usr/bin/polyos-client
Restart=always
RestartSec=5
Environment=DISPLAY=:0
Environment=XAUTHORITY=/var/run/lightdm/root/:0
[Install]
WantedBy=graphical.target
EOF
# Create control file
cat <<EOF > $PKG_DIR/DEBIAN/control
Package: polyos-client
Version: ${VERSION}
Section: utils
Priority: optional
Architecture: amd64
Depends: xinput, scrot, xdotool, xclip, python3, python3-tk
Maintainer: Emirhan Gok <emiran404@github.com>
Description: PolyOS Lab student client daemon
EOF
# Create postinst script
cat <<EOF > $PKG_DIR/DEBIAN/postinst
#!/bin/sh
set -e
systemctl daemon-reload
systemctl enable polyos-client.service
systemctl start polyos-client.service
EOF
chmod 755 $PKG_DIR/DEBIAN/postinst
# Create prerm script
cat <<EOF > $PKG_DIR/DEBIAN/prerm
#!/bin/sh
set -e
systemctl stop polyos-client.service || true
systemctl disable polyos-client.service || true
EOF
chmod 755 $PKG_DIR/DEBIAN/prerm
dpkg-deb --build $PKG_DIR
# 5. Upload Assets and Create/Update Release
- name: Release Assets
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.tag_name }}
body_path: RELEASE_NOTES.md
files: |
dashboard/release/*.deb
polyos-client_${{ env.version_num }}_amd64.deb
RELEASE_NOTES.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}