Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically build and publish development packages (deb/rpm) on merge #7

Merged
merged 43 commits into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
aa19f3b
First attempt at building a deb with actions
swelljoe Jul 1, 2023
ec26c40
Typo
swelljoe Jul 1, 2023
99ba1e3
mkdir tmp?
swelljoe Jul 1, 2023
c87df6b
try to set path for checkout
swelljoe Jul 1, 2023
f00bee8
Trying again
swelljoe Jul 1, 2023
fb0364c
Where is the danged thing?
swelljoe Jul 1, 2023
e07a706
Add tests, maybe
swelljoe Jul 1, 2023
a87f603
Need deps for tests
swelljoe Jul 1, 2023
f67a6c6
Try it without pbuilder
swelljoe Jul 1, 2023
914f1c6
Let's build and publish with a shell script
swelljoe Jul 2, 2023
00b1076
Maybe get path right
swelljoe Jul 2, 2023
5ddaf86
Wait, no.
swelljoe Jul 2, 2023
94f6167
Fingers crossed...
swelljoe Jul 2, 2023
adb31b6
Deb versions are weird
swelljoe Jul 2, 2023
d2211e8
Agh.
swelljoe Jul 2, 2023
dee52ef
Gotta put secrets in env
swelljoe Jul 2, 2023
6974795
I can never figure out aptly publish syntax
swelljoe Jul 2, 2023
4bf713e
Echo every line to help troubleshoot aptly problem
swelljoe Jul 2, 2023
60de63f
Finally works?
swelljoe Jul 2, 2023
533198a
Rename
swelljoe Jul 2, 2023
55312ef
Call renamed script
swelljoe Jul 2, 2023
c9cfba9
First poke at RPM build
swelljoe Jul 2, 2023
881792f
Copypasta error
swelljoe Jul 2, 2023
d2b2ae9
Where are the danged single quotes coming from?
swelljoe Jul 2, 2023
7884ad1
Make redhat dir
swelljoe Jul 3, 2023
3f80680
Make redhat dirs
swelljoe Jul 3, 2023
b709906
Maybe we aren't running as root?
swelljoe Jul 3, 2023
12b46e9
Running as 'runner', but need noarch dir, too
swelljoe Jul 3, 2023
1cdfaae
What in the world?
swelljoe Jul 3, 2023
1ca2692
Agh dumb quotes
swelljoe Jul 3, 2023
dc699c4
Maybe fix package copy
swelljoe Jul 3, 2023
9c4d742
One day this will work
swelljoe Jul 3, 2023
7ab3a2b
Move tests into their own tiny workflow
swelljoe Jul 3, 2023
cc7a9f8
Remove tests from build jobs
swelljoe Jul 3, 2023
7c3242d
Try to setup an ssh key
swelljoe Jul 3, 2023
13b8738
Trying again with the ssh
swelljoe Jul 3, 2023
8734c12
oops, wrong name
swelljoe Jul 3, 2023
e9450df
Still wrong
swelljoe Jul 3, 2023
6bc176e
For real?
swelljoe Jul 3, 2023
0486f1d
WTH? Why isn't this variable working?
swelljoe Jul 3, 2023
7a3a176
Jebus.
swelljoe Jul 3, 2023
5013ec2
Once more with feeling
swelljoe Jul 3, 2023
a49c7ae
Queue for publishing
swelljoe Jul 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/build-devel-deb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: "build-devel-deb"

on:
push:
branches:
- master

jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
path: 'jailkit'

- name: Install dependencies
run: |-
sudo apt-get -y update
sudo apt-get -y install perl build-essential gnupg curl
curl -O https://raw.githubusercontent.com/webmin/webmin/master/mod_def_list.txt
curl -O https://raw.githubusercontent.com/webmin/webmin/master/makemoduledeb.pl
- name: Build package
env:
APTLY_USER: ${{ secrets.APTLY_USER }}
APTLY_PASSWD: ${{ secrets.APTLY_PASSWD }}
run: |-
jailkit/build-devel-deb.sh
34 changes: 34 additions & 0 deletions .github/workflows/build-devel-rpm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: "build-devel-rpm"

on:
push:
branches:
- master

jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
path: 'jailkit'

- name: Install dependencies
run: |-
sudo apt-get -y update
sudo apt-get -y install rpm perl build-essential gnupg curl
curl -O https://raw.githubusercontent.com/webmin/webmin/master/mod_def_list.txt
curl -O https://raw.githubusercontent.com/webmin/webmin/master/makemodulerpm.pl
- name: Setup ssh
env:
BUILD_SSH_PRIVATE_KEY: ${{ secrets.BUILD_SSH_PRIVATE_KEY }}
BUILD_SSH_KNOWN_HOSTS: ${{ secrets.BUILD_SSH_KNOWN_HOSTS }}
run: |-
install -m 600 -D /dev/null ~/.ssh/id_ed25519
echo "${{ secrets.BUILD_SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519
echo "${{ secrets.BUILD_SSH_KNOWN_HOSTS }}" > ~/.ssh/known_hosts
- name: Build package
env:
BUILD_SSH_USER: ${{ secrets.BUILD_SSH_USER }}
run: |-
jailkit/build-devel-rpm.sh
21 changes: 21 additions & 0 deletions .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: "run-tests"

on:
push:

jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
path: 'jailkit'

- name: Install dependencies
run: |-
sudo apt-get -y update
sudo apt-get -y install perl libconfig-inifiles-perl libtest-strict-perl
- name: Run tests
run: |-
cd jailkit
prove
24 changes: 24 additions & 0 deletions build-devel-deb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
# Build and publish a package, called by github actions

# echo, exit on error/undefined vars
set -xeu

MOD='jailkit'
NAME="webmin-$MOD"

# Always increasing. Also a human-readable datetime.
BUILD=$(date +'%Y%m%d%H%M')

# Load module.info to get version
version=$(grep version $MOD/module.info | cut -d'=' -f2)
VERSION="${version}.devel.${BUILD}"

mkdir tmp
perl makemoduledeb.pl --deb-depends --licence 'GPLv3' --email 'joe@virtualmin.com' --allow-overwrite --target-dir tmp "$MOD" "$VERSION"
mv "tmp/${NAME}_${VERSION}_all.deb" .

# Publish to aptly
curl --user $APTLY_USER:$APTLY_PASSWD -X POST -F file=@${NAME}_${VERSION}_all.deb https://aptly.virtualmin.com/api/files/${NAME}_${VERSION}
curl --user $APTLY_USER:$APTLY_PASSWD -X POST https://aptly.virtualmin.com/api/repos/virtualmin-7-gpl-devel/file/${NAME}_${VERSION}
curl -i --user $APTLY_USER:$APTLY_PASSWD -X PUT -H 'Content-Type: application/json' --data '{}' https://aptly.virtualmin.com/api/publish/filesystem:7-gpl:./virtualmin-devel
35 changes: 35 additions & 0 deletions build-devel-rpm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
# Build and publish a package, called by github actions

# echo, exit on error/undefined vars
set -xeu

MOD='jailkit'
NAME="wbm-$MOD"

# Always increasing. Also a human-readable datetime.
BUILD=$(date +'%Y%m%d%H%M')

# Load module.info to get version
version=$(grep version $MOD/module.info | cut -d'=' -f2)
VERSION="${version}.devel.${BUILD}"

if [ -f epoch ]; then
epoch="--epoch $(cat epoch)"
else
epoch=""
fi

# FIXME after PR is merged to Webmin
mkdir -p ${HOME}/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
mkdir -p "${HOME}/rpmbuild/RPMS/noarch"
ls "${HOME}/rpmbuild/RPMS/noarch"
ls "${HOME}/rpmbuild/SOURCES"
ls "${HOME}/rpmbuild/SPECS"
perl makemodulerpm.pl --rpm-depends --licence 'GPLv3' --allow-overwrite $epoch "$MOD" "$VERSION"

# Copy to build/deploy server
scp -i "${HOME}/.ssh/id_ed25519" "${HOME}/rpmbuild/RPMS/noarch/${NAME}-${VERSION}-1.noarch.rpm" "$BUILD_SSH_USER@build.virtualmin.com:/home/build/result/vm/7/gpl-devel/rpm/noarch"
# Add it to the publish queue
ssh -i "${HOME}/.ssh/id_ed25519" "$BUILD_SSH_USER@build.virtualmin.com" "flock /home/build/rpm-publish-queue.lock echo 'vm/7/gpl-devel/rpm/noarch' >> /home/build/rpm-publish-queue"

4 changes: 3 additions & 1 deletion jailkit-lib.pl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ =head1 jailkit-lib.pl
=cut

BEGIN { push(@INC, ".."); }
use WebminCore;
if (eval {require WebminCore;1;} ne 1) {
exit 1;
}
init_config();

=head2 get_jk_init_ini()
Expand Down