Skip to content

Commit 878a68e

Browse files
authored
Add build workflow
* Create build.yml * Create .dockerignore * Create build.dockerfile * Create Makefile * Update .gitignore * Update README.md * Create PKGBUILD * Update PULL_REQUEST_TEMPLATE.md
1 parent ab5d7b8 commit 878a68e

File tree

8 files changed

+122
-2
lines changed

8 files changed

+122
-2
lines changed

.dockerignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*
2+
!src/
3+
!Cargo.lock
4+
!Cargo.toml

.github/PULL_REQUEST_TEMPLATE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
## Checklist
1818
- [ ] I have performed a self-review of my own code.
1919
- [ ] My changes generate no errors/warnings/merge conflicts.
20-
- [ ] I have read the CLA and accept it's terms: [Contributor License Agreement](../CLA.md).
20+
- [ ] I have read the CLA and accept it's terms: [Contributor License Agreement](https://raw.githubusercontent.com/RX0FA/raptor-cage/refs/heads/master/CLA.md).

.github/workflows/build.yml

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Rust
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
7+
env:
8+
CARGO_TERM_COLOR: always
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: write
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: Build
18+
run: |-
19+
make docker-build
20+
- name: Generate Tag
21+
id: tag_step
22+
run: |-
23+
program_version="$(echo 1.0.0)"
24+
tag_name="${program_version}-$(date +%y%m%d%H%M)-$(git rev-parse HEAD | head -c 7)"
25+
printf "tag_name=${tag_name}\nprogram_version=${program_version}\n" | tee -a "$GITHUB_OUTPUT"
26+
# https://github.com/ncipollo/release-action.
27+
- uses: ncipollo/release-action@v1
28+
id: release_step
29+
with:
30+
artifacts: "dist/raptor-cage.tgz,dist/raptor-cage.sha256"
31+
tag: ${{ steps.tag_step.outputs.tag_name }}
32+
makeLatest: true
33+
- name: Publish to the AUR
34+
env:
35+
AUR_PRIVATE_KEY: ${{ secrets.AUR_PRIVATE_KEY }}
36+
run: |-
37+
mkdir -p ~/.ssh
38+
echo "aur.archlinux.org ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEuBKrPzbawxA/k2g6NcyV5jmqwJ2s+zpgZGZ7tpLIcN" >> ~/.ssh/known_hosts
39+
git -c init.defaultBranch=master clone https://aur.archlinux.org/raptor-cage-bin.git
40+
pkgbuild_pkgver=$(grep "^pkgver=" raptor-cage-bin/PKGBUILD | cut -d'=' -f2)
41+
pkgbuild_pkgrel=$(grep "^pkgrel=" raptor-cage-bin/PKGBUILD | cut -d'=' -f2)
42+
current_version="${{ steps.tag_step.outputs.program_version }}"
43+
if [ "$current_version" == "$pkgbuild_pkgver" ]; then
44+
# Same version, so increase pkgbuild_pkgrel.
45+
((pkgbuild_pkgrel++))
46+
else
47+
# Different version, so reset pkgbuild_pkgrel.
48+
pkgbuild_pkgrel=1
49+
fi
50+
tag_name="${{ steps.tag_step.outputs.tag_name }}"
51+
tgz_sha256=$(cat dist/raptor-cage.sha256 | awk '{print $1}')
52+
sed -e "s/{{VERSION}}/${current_version}/" -e "s/{{RELEASE}}/${pkgbuild_pkgrel}/" \
53+
-e "s/{{TAG_NAME}}/${tag_name}/" -e "s/{{SHA256SUM}}/${tgz_sha256}/" \
54+
packaging/PKGBUILD > raptor-cage-bin/PKGBUILD
55+
cd raptor-cage-bin
56+
docker run --rm -v "`pwd`:/data" -w /data --env user_uid=$(id -u) --env user_gid=$(id -g) \
57+
archlinux:latest bash \
58+
-c 'groupadd -g $user_gid user && useradd -M -s /bin/bash -u $user_uid -g $user_gid user && su user -c "makepkg --printsrcinfo > .SRCINFO"'
59+
git remote add aur ssh://[email protected]/raptor-cage-bin.git
60+
git config user.name RX0FA
61+
git config user.email [email protected]
62+
git add .SRCINFO PKGBUILD
63+
git commit -m "Update build files ($tag_name)"
64+
key_file="${{ github.workspace }}/id_ed25519"
65+
echo "$AUR_PRIVATE_KEY" > "$key_file"
66+
chmod 600 "$key_file"
67+
GIT_SSH_COMMAND="ssh -i \"${key_file}\" -o IdentitiesOnly=yes" git push aur master
68+
69+

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
debug/
22
target/
33
dist/
4+
.SRCINFO

Makefile

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
SHELL := /bin/bash
2+
DIST_DIR := dist
3+
4+
help:
5+
@printf "Usage: make COMMAND [OPTIONS]\n\nCommands:\n"
6+
@grep -E '^[a-z].*:' Makefile | sed -r 's/^([^:]+):(.*)/ \1/g'
7+
8+
clean:
9+
rm -rf $(DIST_DIR)/*
10+
11+
docker-build: clean
12+
mkdir -p dist
13+
docker build -f build.dockerfile . -t raptor-cage
14+
docker run --rm raptor-cage cat /builder/target/release/raptor-cage > dist/raptor-cage
15+
tar czf dist/raptor-cage.tgz -C dist raptor-cage
16+
sh -c 'cd dist && sha256sum raptor-cage.tgz | tee raptor-cage.sha256'

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
raptor-cage
44
</h1>
55
<p>
6-
Run Linux games in a secure sandbox, various native and non-native titles are supported.
6+
Run games in a secure sandbox, various native and non-native titles are supported.
77
</p>
88
</div>
99

build.dockerfile

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM rust:1.83.0-slim-bullseye
2+
RUN useradd -m -d /builder -s /bin/bash builder
3+
USER builder
4+
WORKDIR /builder
5+
COPY --chown=builder:builder Cargo.toml Cargo.lock ./
6+
RUN mkdir src &&\
7+
echo "fn main() {}" > src/main.rs &&\
8+
cargo fetch &&\
9+
cargo build --release
10+
COPY --chown=builder:builder src src/
11+
RUN touch src/main.rs &&\
12+
cargo test &&\
13+
cargo build --release

packaging/PKGBUILD

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Maintainer: RX0FA <[email protected]>
2+
pkgname=raptor-cage-bin
3+
pkgver={{VERSION}}
4+
pkgrel={{RELEASE}}
5+
pkgdesc='Run games in a secure sandbox'
6+
url='https://github.com/RX0FA/raptor-cage'
7+
source_x86_64=("https://github.com/RX0FA/raptor-cage/releases/download/{{TAG_NAME}}/raptor-cage.tgz")
8+
arch=('x86_64')
9+
license=('CIL-1.0')
10+
depends=('steam-native-runtime')
11+
optdepends=('mangohud: vulkan overlay')
12+
sha256sums_x86_64=('{{SHA256SUM}}')
13+
14+
package() {
15+
cd "$srcdir/"
16+
install -Dm755 raptor-cage "${pkgdir}/usr/bin/raptor-cage"
17+
}

0 commit comments

Comments
 (0)