forked from RamanujanMachine/LIReC
-
Notifications
You must be signed in to change notification settings - Fork 0
149 lines (146 loc) · 6.21 KB
/
bundle_app.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
name: 'Prepare Deployment Bundle'
on:
workflow_dispatch:
workflow_call:
inputs:
new_version:
description: 'The target version for this bundle, based on what is currently deployed on the BOINC server'
type: string
required: true
platform:
description: 'User friendly platform name used to distinctly name artifacts across platforms'
type: string
required: true
boinc_platform:
description: 'Must match one of the platforms in the BOINC server project.xml and https://boinc.berkeley.edu/trac/wiki/BoincPlatforms'
type: string
required: true
wrapper:
description: 'Name of the wrapper to use - these get updated every so often and can be found here https://boinc.berkeley.edu/dl/?C=M;O=D'
type: string
required: true
executable:
description: 'Executable name as used in naming cxFreeze output binary'
type: string
required: true
app_dir:
description: 'Short name of the app as defined in the BOINC server, also the name of the directory where the binaries are deposited'
type: string
required: true
jobs:
bundle:
runs-on: ubuntu-latest
env:
NEW_VERSION: ${{ inputs.new_version }}
PLATFORM: ${{ inputs.platform }}
BOINC_PLATFORM: ${{ inputs.boinc_platform }}
WRAPPER: ${{ inputs.wrapper }}
EXECUTABLE: ${{ inputs.executable }}
APP_DIR: ${{ inputs.app_dir }}
steps:
- name: "Checkout repository"
# https://github.com/actions/checkout
uses: actions/checkout@v4
- name: "Download BOINC wrapper"
# wrapper documentation is outdated, latest wrapper version can be found here https://boinc.berkeley.edu/dl/?C=M;O=D
run: |
curl -O https://boinc.berkeley.edu/dl/$WRAPPER.zip
- name: "Unzip wrapper"
run: |
unzip $WRAPPER.zip
if [[ -d "$WRAPPER" ]]; then
mv $WRAPPER/* .
fi
- name: "Create job.xml (Windows)"
if: ${{ inputs.platform == 'win' }}
run: |
sed -e "s/{{EXECUTABLE}}/$EXECUTABLE.exe/g" boinc/job_template.xml > job.$NEW_VERSION-$PLATFORM.xml
- name: "Create job.xml (non-Windows)"
if: ${{ inputs.platform != 'win' }}
run: |
sed -e "s/{{EXECUTABLE}}/$EXECUTABLE/g" boinc/job_template.xml > job.$NEW_VERSION-$PLATFORM.xml
- name: "Create version.xml"
run: |
sed -e "s/{{WRAPPER}}/$WRAPPER/g" -e "s/{{VERSION}}/$NEW_VERSION/g" -e "s/{{PLATFORM}}/$PLATFORM/g" boinc/version_template.xml > version.xml
- name: "Create directory for previously created binaries"
run: |
mkdir app.$NEW_VERSION-$PLATFORM
- name: "Download previously compiled binaries"
uses: actions/download-artifact@v4
with:
name: ${{ env.PLATFORM }}
path: app.${{ env.NEW_VERSION }}-${{ env.PLATFORM }}
- name: "Zip build output"
run: |
zip -r app.$NEW_VERSION-$PLATFORM.zip app.$NEW_VERSION-$PLATFORM
- name: "Sign files"
env:
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
run: |
echo "$SIGNING_KEY" > key
./boinc/sign_executable job.$NEW_VERSION-$PLATFORM.xml key > job.$NEW_VERSION-$PLATFORM.xml.sig
./boinc/sign_executable app.$NEW_VERSION-$PLATFORM.zip key > app.$NEW_VERSION-$PLATFORM.zip.sig
- name: "Sign executables (Windows)"
if: ${{ inputs.platform == 'win' }}
env:
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
run: |
./boinc/sign_executable $WRAPPER.exe key > $WRAPPER.exe.sig
- name: "Sign executables (non-Windows)"
if: ${{ inputs.platform != 'win' }}
env:
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
run: |
./boinc/sign_executable $WRAPPER key > $WRAPPER.sig
- name: "Create app bundle (Windows)"
if: ${{ inputs.platform == 'win' }}
run: |
zip -r --junk-paths $BOINC_PLATFORM.zip . -i version.xml job.$NEW_VERSION-$PLATFORM.xml job.$NEW_VERSION-$PLATFORM.xml.sig $WRAPPER.exe $WRAPPER.exe.sig app.$NEW_VERSION-$PLATFORM.zip app.$NEW_VERSION-$PLATFORM.zip.sig
- name: "Create app bundle (non-Windows)"
if: ${{ inputs.platform != 'win' }}
run: |
zip -r --junk-paths $BOINC_PLATFORM.zip . -i version.xml job.$NEW_VERSION-$PLATFORM.xml job.$NEW_VERSION-$PLATFORM.xml.sig $WRAPPER $WRAPPER.sig app.$NEW_VERSION-$PLATFORM.zip app.$NEW_VERSION-$PLATFORM.zip.sig
- name: "Upload binary to GitHub"
uses: actions/upload-artifact@v4
with:
name: ${{ env.BOINC_PLATFORM }}.zip
path: ${{ env.BOINC_PLATFORM }}.zip
overwrite: true
- name: 'Prepare BOINC server access'
run: |
mkdir -pv ~/.ssh/
- name: 'Write key'
env:
SSH_KEY: ${{ secrets.SSH_KEY }}
run: |
echo "$SSH_KEY" > ~/.ssh/actions.key
chmod 600 ~/.ssh/actions.key
- name: 'Write ssh config'
run: |
cat >>~/.ssh/config <<END
Host boinc
HostName 172.105.4.251
User root
IdentityFile ~/.ssh/actions.key
StrictHostKeyChecking=no
ServerAliveCountMax=10
ServerAliveInterval=60
END
- name: 'Make target directory'
if: ${{ ! vars.DO_NOT_DEPLOY }}
run: |
ssh boinc 'sudo su - boincadm -c "mkdir -p /home/boincadm/projects/boinc/apps/${{env.APP_DIR}}/${{env.NEW_VERSION}}"'
- name: 'Copy binaries to server'
if: ${{ ! vars.DO_NOT_DEPLOY }}
run: |
scp $BOINC_PLATFORM.zip boinc:/home/boincadm/projects/boinc/apps/${{env.APP_DIR}}/${{env.NEW_VERSION}}
ssh boinc 'sudo su - boincadm -c "chown boincadm /home/boincadm/projects/boinc/apps/${{env.APP_DIR}}/${{env.NEW_VERSION}}"'
ssh boinc 'sudo su - boincadm -c "chgrp boincadm /home/boincadm/projects/boinc/apps/${{env.APP_DIR}}/${{env.NEW_VERSION}}"'
- name: 'Unpack binaries'
if: ${{ ! vars.DO_NOT_DEPLOY }}
run: |
ssh boinc 'sudo su - boincadm -c "cd /home/boincadm/projects/boinc/apps/${{env.APP_DIR}}/${{env.NEW_VERSION}} && unzip -o -q -d ${{env.BOINC_PLATFORM}} ${{env.BOINC_PLATFORM}}.zip"'
- name: 'Run BOINC update versions'
if: ${{ ! vars.DO_NOT_DEPLOY }}
run: |
ssh boinc 'sudo su - boincadm -c "cd /home/boincadm/projects/boinc && ./bin/update_versions"'