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 package Debian packages on release #235

Merged
merged 5 commits into from Jan 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
58 changes: 50 additions & 8 deletions .github/workflows/release.yml
Expand Up @@ -72,12 +72,25 @@ jobs:
TARGET: ${{ matrix.rust }}
ARTIFACT: ${{ matrix.artifact }}
VERSION: ${{ steps.get_version.outputs.VERSION }}
- name: Upload assets

- name: Build Linux packages
run: |
make deb
mv *.deb skytable-${{ steps.get_version.outputs.VERSION }}-${{ matrix.artifact }}.deb
if: runner.os == 'Linux'

- name: Upload assets (bundles)
uses: actions/upload-artifact@v2
with:
name: sky-bundle-${{ steps.get_version.outputs.VERSION }}-${{ matrix.artifact }}.zip
path: sky-bundle-${{ steps.get_version.outputs.VERSION }}-${{ matrix.artifact }}.zip

- name: Upload assets (Linux packages)
uses: actions/upload-artifact@v2
with:
name: skytable-${{ steps.get_version.outputs.VERSION }}-${{ matrix.artifact }}.deb
if: runner.os == 'Linux'

build_32bit:
name: Build artifacts (32-bit)
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -142,12 +155,25 @@ jobs:
TARGET: ${{ matrix.rust }}
ARTIFACT: ${{ matrix.artifact }}
VERSION: ${{ steps.get_version.outputs.VERSION }}
- name: Upload assets

- name: Build Linux packages
run: |
make deb
mv *.deb skytable-${{ steps.get_version.outputs.VERSION }}-${{ matrix.artifact }}.deb
if: runner.os == 'Linux'

- name: Upload assets (binaries)
uses: actions/upload-artifact@v2
with:
name: sky-bundle-${{ steps.get_version.outputs.VERSION }}-${{ matrix.artifact }}.zip
path: sky-bundle-${{ steps.get_version.outputs.VERSION }}-${{ matrix.artifact }}.zip

- name: Upload assets (Linux packages)
uses: actions/upload-artifact@v2
with:
name: skytable-${{ steps.get_version.outputs.VERSION }}-${{ matrix.artifact }}.deb
if: runner.os == 'Linux'

build_musl:
name: Build Linux x86_64-musl (Tier 2)
runs-on: ubuntu-latest
Expand Down Expand Up @@ -191,8 +217,11 @@ jobs:
- name: Install Rust
run: rustup target add x86_64-unknown-linux-musl

- name: Make bundle
run: make bundle
- name: Make bundle and packages
run: |
make bundle
make deb
mv *.deb skytable-${{ steps.get_version.outputs.VERSION }}-x86_64-linux-musl.deb
env:
RUST_BACKTRACE: 1
TARGET: x86_64-unknown-linux-musl
Expand All @@ -203,6 +232,12 @@ jobs:
with:
name: sky-bundle-${{ steps.get_version.outputs.VERSION }}-x86_64-linux-musl.zip
path: sky-bundle-${{ steps.get_version.outputs.VERSION }}-x86_64-linux-musl.zip

- name: Upload assets (Linux packages)
uses: actions/upload-artifact@v2
with:
name: skytable-${{ steps.get_version.outputs.VERSION }}-x86_64-linux-musl.deb

build-arm64:
name: Build artifacts (self-hosted-arm64-native)
runs-on: self-hosted
Expand All @@ -227,15 +262,19 @@ jobs:
run: |
echo "using version tag ${GITHUB_REF:10}"
echo ::set-output name=version::"${GITHUB_REF:10}"
- name: Make bundle
- name: Make bundle and packages
env:
TARGET: aarch64-unknown-linux-gnu
VERSION: ${{ steps.get_version.outputs.VERSION }}
ARTIFACT: aarch64-linux-gnu
run: make bundle
- name: Upload bundle
run: |
make bundle
make deb
mv *.deb skytable-${{ steps.get_version.outputs.VERSION }}-aarch64-linux-gnu.deb
- name: Upload bundle and packages
run: |
aws --endpoint-url ${{ secrets.STORAGE_ACCESS_URL }} s3 cp sky-bundle-${{ steps.get_version.outputs.VERSION }}-aarch64-linux-gnu.zip s3://releases/${{ steps.get_version.outputs.VERSION }}/
aws --endpoint-url ${{ secrets.STORAGE_ACCESS_URL }} s3 cp skytable-${{ steps.get_version.outputs.VERSION }}-aarch64-linux-gnu.deb s3://releases/${{ steps.get_version.outputs.VERSION }}/

release:
name: Release
Expand All @@ -260,9 +299,12 @@ jobs:
- name: Download ARM64 bundle
run: |
wget https://releases.skytable.io/release/${{ steps.get_version.outputs.VERSION }}/sky-bundle-${{ steps.get_version.outputs.VERSION }}-aarch64-linux-gnu.zip
wget https://releases.skytable.io/release/${{ steps.get_version.outputs.VERSION }}/skytable-${{ steps.get_version.outputs.VERSION }}-aarch64-linux-gnu.deb
working-directory: artifacts
- name: Upload release binaries
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG_NAME: ${{ steps.get_version.outputs.VERSION }}
run: hub release edit $(find . -type f -name "*.zip" -printf "-a %p ") -m "" "$TAG_NAME"
run: |
hub release edit $(find . -type f -name "*.zip" -printf "-a %p ") -m "" "$TAG_NAME"
hub release edit $(find . -type f -name "*.deb" -printf "-a %p ") -m "" "$TAG_NAME"
4 changes: 3 additions & 1 deletion .gitignore
Expand Up @@ -9,4 +9,6 @@ snapstore.partmap
/.idea
.DS_Store
.sky_history
.sky_pid
.sky_pid
.devcontainer
*.deb
6 changes: 6 additions & 0 deletions Makefile
Expand Up @@ -101,6 +101,12 @@ endif
@echo "Installing any additional dependencies"
@echo "===================================================================="
@$(ADDITIONAL_SOFTWARE)
deb: release
@echo "===================================================================="
@echo "Building Debian package (optimized)"
@echo "===================================================================="
@cargo $(TARGET_ARG) install cargo-deb
@cargo deb $(TARGET_ARG) --manifest-path=server/Cargo.toml --output .
build: .pre
@echo "===================================================================="
@echo "Building all binaries in debug mode (unoptimized)"
Expand Down
1 change: 1 addition & 0 deletions pkg/README
@@ -0,0 +1 @@
This directory contains files used for packaging Skytable for Linux distributions.
15 changes: 15 additions & 0 deletions pkg/common/skyd.service
@@ -0,0 +1,15 @@
[Unit]
Description=Skytable database server daemon
After=Network.target
StartLimitIntervalSec=0

[Service]
Type=simple
Restart=always
RestartSec=1
User=skytable
ExecStart=/usr/bin/skyd --noart
WorkingDirectory=/var/lib/skytable

[Install]
WantedBy=multi-user.target
5 changes: 5 additions & 0 deletions pkg/debian/description.txt
@@ -0,0 +1,5 @@
Skytable is a free and open-source NoSQL database that aims
to provide flexibility in data modeling at scale.
The `skytable` package contains the database server (`skyd`),
an interactive command-line client (`skysh`), a benchmarking
tool (`sky-bench`) and a migration tool (`sky-migrate`).
15 changes: 15 additions & 0 deletions pkg/debian/postinst
@@ -0,0 +1,15 @@
#!/bin/sh -e

systemctl daemon-reload

if [ $1 = "install" ]; then
systemctl enable skyd
fi

if [ $1 = "upgrade" ]; then
systemctl stop skyd
fi

systemctl start skyd

#DEBHELPER#
20 changes: 20 additions & 0 deletions pkg/debian/preinst
@@ -0,0 +1,20 @@
#!/bin/sh -e

SKY_DIR=/var/lib/skytable

# create the data directory
if [ ! -e $SKY_DIR ]; then
mkdir $SKY_DIR
elif [ ! -d $SKY_DIR ]; then
echo "ERROR: /var/lib/skytable exists but it is not a directory" 1>&2
return 1
fi

if [ $1 = "install" ]; then
# add the `skytable` user
adduser --system --group skytable
# change ownership
chown skytable:skytable /var/lib/skytable
fi

#DEBHELPER#
33 changes: 33 additions & 0 deletions server/Cargo.toml
Expand Up @@ -55,3 +55,36 @@ libc = "0.2.112"

[features]
nightly = []

[package.metadata.deb]
name = "skytable"
maintainer = "Sayan Nandan <nandansayan@outlook.com>"
copyright = "2020, Sayan Nandan <nandansayan@outlook.com>"
license-file = ["../LICENSE", "0"]
maintainer-scripts = "../pkg/debian/"
extended-description-file = "pkg/debian/description.txt"
depends = "$auto"
section = "database"
priority = "optional"
assets = [
[
"target/release/skyd",
"usr/bin/",
"755",
],
[
"target/release/skysh",
"usr/bin/",
"755",
],
[
"target/release/sky-bench",
"usr/bin/",
"755",
],
[
"../pkg/common/skyd.service",
"/etc/systemd/system/skyd.service",
"644",
],
]