-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create go.yml * Test * Allow to change output file name * Optionally compress output * Add utsname_arm64.go * Add build script * Cleanup * Test * Pass down whole environment * Keep binary file and parallelize build * Sequential build due to no noticeable improvement * Add suffix * Ignore .http files * Debian build script * Minors * Add md5sums * Automatically detect installation size * Write config files * Add util-linux as dependency * Improve uninstall command * Build dynamically linked binary on Arch * Make executable * Debian package building * Minor * Get rid of multiprocessing and cleanup * Reusable env parser * Refactor yml file and pass env to install command * Minor fix * Update go.yml * Update go.yml * Fix tag parsing * Cleanup * Test * Undo test * Rename * Add test trigger * Simplify * Minor * Fake tag * Change prefix name so it appears on ls * Rename final deb file * Correct target directory * Remove prefix directory after creating deb * Write target architectures to file * Add upload script * Call upload script with the correct env * Set Content-Type header * Validate curl response status code * cleanup
- Loading branch information
1 parent
e284959
commit 5ebbc60
Showing
10 changed files
with
516 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Release | ||
|
||
on: | ||
create: | ||
# GitHub Action will not get triggered for '*', so use 'v*' instead | ||
tags: | ||
- v* | ||
# Only used for testing | ||
# push: | ||
# branches-ignore: [ master ] | ||
|
||
jobs: | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.16 | ||
- name: Test | ||
run: make test | ||
- name: Set environment variables | ||
run: echo "CURRENT_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | ||
# run: |- | ||
# echo "WARNING: using test tag" | ||
# echo "CURRENT_TAG=v0.8.5" >> $GITHUB_ENV | ||
- name: Build | ||
run: ./scripts/build.py | ||
- name: Create release and upload assets | ||
run: ./scripts/upload.py $(cat targets.txt) | ||
env: | ||
REPO_OWNER: maximumadmin | ||
REPO_NAME: zramd | ||
GH_RELEASE_TOKEN: ${{ secrets.GH_RELEASE_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
.python/ | ||
.vscode/ | ||
zramd.bin | ||
dist/ | ||
*.http |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
"version": "0.1", | ||
"words": [ | ||
"deinitialize", | ||
"itertools", | ||
"lsmod", | ||
"mkswap", | ||
"zram", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
control: | ||
Package: zramd | ||
Version: ${VERSION}-${RELEASE} | ||
Architecture: ${ARCH} | ||
Maintainer: maximumadmin | ||
Priority: extra | ||
Section: admin | ||
Installed-Size: ${SIZE_KB} | ||
Depends: util-linux | ||
Suggests: earlyoom | ||
Description: Automatically setup swap on zram ✨ | ||
|
||
# https://wiki.debian.org/MaintainerScripts | ||
scripts: | ||
postinst: |- | ||
#!/bin/sh | ||
if [ -d /run/systemd/system ]; then | ||
deb-systemd-invoke enable --now zramd.service >/dev/null || true | ||
fi | ||
prerm: |- | ||
#!/bin/sh | ||
if [ -d /run/systemd/system ] && [ "$1" = remove ]; then | ||
deb-systemd-invoke disable --now zramd.service >/dev/null || true | ||
fi | ||
postrm: |- | ||
if [ -d /run/systemd/system ] && [ "$1" = remove ]; then | ||
systemctl --system daemon-reload >/dev/null || true | ||
fi | ||
build: | ||
install: | ||
cmd: [make, install] | ||
env: | ||
PREFIX: ${PREFIX} | ||
output: ${BIN_FILE} | ||
# Additional arguments passed to dpkg-deb, see also | ||
# https://manpages.debian.org/jessie/dpkg/dpkg-deb.1.en.html | ||
args: [-Zgzip, -z9] | ||
# Used to rename the final deb file so it does not end up with the same name | ||
# as the root directory (PREFIX), env variables can be used here | ||
rename: zramd_${ARCH}.deb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/usr/bin/python3 -u | ||
|
||
import os | ||
import subprocess | ||
import sys | ||
from typing import Optional, Tuple | ||
|
||
TARGETS = ( | ||
('arm', '6', 'armel'), | ||
('arm', '7', 'armhf'), | ||
('arm64', None, 'arm64'), | ||
('amd64', None, 'amd64'), | ||
) | ||
|
||
# Parse tag names like v0.8.5 or v0.8.5-1 | ||
def parse_tag(tag: str) -> Tuple[str, str]: | ||
version, release, *_ = [*tag.split('-'), ''] | ||
# Remove the leading 'v' from version | ||
return (version[1:], release or '1') | ||
|
||
def build(goarch: str, goarm: Optional[str], friendly_arch: str) -> int: | ||
out_file = f"dist/zramd_{friendly_arch}" | ||
prefix = f"dist/zramd_{friendly_arch}_root" | ||
version, release = parse_tag(os.environ['CURRENT_TAG']) | ||
proc = subprocess.run( | ||
['make', f"output={out_file}", 'make_tgz=1', 'make_deb=1', 'skip_clean=1'], | ||
env={ | ||
# Pass all environment variables, contains some Go variables | ||
**os.environ, | ||
# Set Go build-specific variables | ||
'GOOS': 'linux', | ||
'GOARCH': goarch, | ||
**({'GOARM': goarm} if goarch == 'arm' else {}), | ||
# Required to create a Debian package | ||
'DEB_ARCH': friendly_arch, | ||
'VERSION': version, | ||
'RELEASE': release, | ||
'PREFIX': prefix, | ||
'BIN_FILE': out_file | ||
} | ||
) | ||
return proc.returncode | ||
|
||
def clean() -> int: | ||
return subprocess.run(['make', 'clean'], env=os.environ).returncode | ||
|
||
def main() -> int: | ||
if (ret := clean()) != 0: | ||
return ret | ||
|
||
# Build all targets sequentially, building in parallel will have minimal or no | ||
# benefit and would make logging messy | ||
for target in TARGETS: | ||
if (ret := build(*target)) != 0: | ||
return ret | ||
|
||
# Finally write the used architectures so we can use them at later steps | ||
with open('targets.txt', 'w') as f: | ||
f.write(','.join(row[2] for row in TARGETS)) | ||
|
||
return 0 | ||
|
||
if __name__ == '__main__': | ||
sys.exit(main()) |
Oops, something went wrong.