Skip to content

Commit

Permalink
Update tiny-dfr.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
AdityaGarg8 authored Oct 12, 2024
1 parent f9fa8da commit a96d328
Showing 1 changed file with 179 additions and 1 deletion.
180 changes: 179 additions & 1 deletion .github/workflows/tiny-dfr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,185 @@ jobs:
gh release upload noble ${{ github.workspace }}/noble/* --clobber -R AdityaGarg8/t2-ubuntu-repo
env:
GH_TOKEN: ${{ secrets.PAT }}


Publish-Oracular:
runs-on: ubuntu-latest
steps:

- name: 'Checkout Repo'
uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
- name: Configure GPG Key
run: |
echo -n "$GPG_SIGNING_KEY" | base64 -di | gpg --import
echo -n "$GPG_SIGNING_KEY" | base64 -di > key
env:
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}

- name: Get the source code
id: publish
run: |
DOCKER_IMAGE=ubuntu:24.04
docker pull ${DOCKER_IMAGE}
docker run \
-e GH_TOKEN=${{ secrets.PAT }} \
-e GPG_SIGNING_EMAIL=${{ secrets.GPG_SIGNING_EMAIL }} \
-t \
-v "$(pwd)":/repo \
${DOCKER_IMAGE} \
/bin/bash -c 'apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" gir1.2-coglpango-1.0 gir1.2-pango-1.0 libcogl-pango-dev libghc-gi-pango-dev wget libxml2-dev \
libghc-pango-dev libghc-yi-frontend-pango-dev libpango1.0-dev libudev-dev libinput-dev curl git librsvg2-dev gpg apt-utils lsb-release && \
CODENAME=$(lsb_release -c | cut -d ":" -f 2 | xargs) && \
mkdir -p -m 755 /etc/apt/keyrings && wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg | tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
&& chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& curl -s --compressed "https://adityagarg8.github.io/t2-ubuntu-repo/KEY.gpg" | gpg --dearmor | tee /etc/apt/trusted.gpg.d/t2-ubuntu-repo.gpg >/dev/null \
&& curl -s --compressed -o /etc/apt/sources.list.d/t2.list "https://adityagarg8.github.io/t2-ubuntu-repo/t2.list" \
&& apt-get update \
&& apt-get install -y -qq -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" gh apple-touchbar && \
curl https://sh.rustup.rs -sSf | sh -s -- -y && \
REPO=https://github.com/AdityaGarg8/tiny-dfr.git && \
COMMIT_HASH=7317bb387765cf58aab46979db86fad2e512c404 && \
VERSION=0.3.0-1 && \
cat /repo/key | gpg --import && \
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" && \
git config --global user.name "github-actions[bot]" && \
git clone ${REPO} && \
cd tiny-dfr && \
git checkout ${COMMIT_HASH} && \
cp /repo/.github/patches/*.patch ./ && rm 0002* && \
git am ./*.patch && \
$HOME/.cargo/bin/cargo b --release && \
mkdir deb && \
cd deb && \
mkdir usr && \
cd usr && \
mkdir bin && \
mkdir src && \
cd .. && \
cd .. && \
mkdir -p ./etc/tiny-dfr && \
cp ./share/tiny-dfr/config.toml ./etc/tiny-dfr/config.toml && \
cp -r ./etc ./deb && \
cp -r ./share ./deb/usr && \
cp ./target/release/tiny-dfr ./deb/usr/bin && \
cp -r /usr/src/apple-touchbar-0.1 ./deb/usr/src && \
mv ./deb/etc/udev/rules.d/* ./deb/usr/share/tiny-dfr && \
mv ./deb/etc/systemd/system/* ./deb/usr/share/tiny-dfr && \
cp /repo/.github/scripts/touchbar ./deb/usr/bin && \
chmod a+x ./deb/usr/bin/tiny-dfr && \
chmod a+x ./deb/usr/bin/touchbar && \
cd deb && \
mkdir DEBIAN && \
cd DEBIAN && \
echo "Package: tiny-dfr" > control && \
echo "Version: ${VERSION}-${CODENAME}" >> control && \
echo "Maintainer: Aditya Garg" >> control && \
echo "Architecture: amd64" >> control && \
echo "Description: Function row daemon for touchbar on Macs" >> control && \
echo "Depends: systemd, dkms" >> control && \
echo "if [ -f /etc/tiny-dfr/config.toml ]" > preinst && \
echo "then" >> preinst && \
echo "cp /etc/tiny-dfr/config.toml /etc/tiny-dfr/config.toml.orj" >> preinst && \
echo "fi" >> preinst && \
echo "if [ -f /etc/tiny-dfr/config.toml.orj ]" > postinst && \
echo "then" >> postinst && \
echo "if [ -f /etc/modprobe.d/tiny-dfr.conf ]" >> postinst && \
echo "then" >> postinst && \
echo "mv /etc/modprobe.d/tiny-dfr.conf /tmp/tiny-dfr.conf" >> postinst && \
echo "fi" >> postinst && \
echo "touchbar --restore" >> postinst && \
echo "if [ -f /tmp/tiny-dfr.conf ]" >> postinst && \
echo "then" >> postinst && \
echo "mv /tmp/tiny-dfr.conf /etc/modprobe.d/tiny-dfr.conf" >> postinst && \
echo "fi" >> postinst && \
echo "fi" >> postinst && \
echo "if [ ! -f /etc/modprobe.d/tiny-dfr.conf ]" >> postinst && \
echo "then" >> postinst && \
echo "for rule in /usr/share/tiny-dfr/*.rules" >> postinst && \
echo "do" >> postinst && \
echo "rule_file=\$(echo \$rule | rev | cut -d \"/\" -f 1 | rev)" >> postinst && \
echo "cp -v /usr/share/tiny-dfr/\$rule_file /etc/udev/rules.d/\$rule_file" >> postinst && \
echo "done" >> postinst && \
echo "for service in /usr/share/tiny-dfr/*.service" >> postinst && \
echo "do" >> postinst && \
echo "service_file=\$(echo \$service | rev | cut -d \"/\" -f 1 | rev)" >> postinst && \
echo "cp -v /usr/share/tiny-dfr/\$service_file /etc/systemd/system/\$service_file" >> postinst && \
echo "done" >> postinst && \
echo "systemctl enable --now tiny-dfr.service" >> postinst && \
echo "else" >> postinst && \
echo "dkms add -m apple-touchbar -v 0.1" >> postinst && \
echo "dkms build -m apple-touchbar -v 0.1 && dkms install -m apple-touchbar -v 0.1 --force || true" >> postinst && \
echo "fi" >> postinst && \
echo "echo -e \"\\nYou may have to restart your Mac in case of a new installation\"" >> postinst && \
echo "if [ -f /etc/systemd/system/tiny-dfr.service ]" > prerm && \
echo "then" >> prerm && \
echo "systemctl disable --now tiny-dfr.service" >> prerm && \
echo "fi" >> prerm && \
echo "for rule in /usr/share/tiny-dfr/*.rules" >> prerm && \
echo "do" >> prerm && \
echo "rule_file=\$(echo \$rule | rev | cut -d \"/\" -f 1 | rev)" >> prerm && \
echo "if [ -f /etc/udev/rules.d/\$rule_file ]" >> prerm && \
echo "then" >> prerm && \
echo "rm -v /etc/udev/rules.d/\$rule_file" >> prerm && \
echo "fi" >> prerm && \
echo "done" >> prerm && \
echo "for service in /usr/share/tiny-dfr/*.service" >> prerm && \
echo "do" >> prerm && \
echo "service_file=\$(echo \$service | rev | cut -d \"/\" -f 1 | rev)" >> prerm && \
echo "if [ -f /etc/udev/rules.d/\$service_file ]" >> prerm && \
echo "then" >> prerm && \
echo "rm -v /etc/udev/rules.d/\$service_file" >> prerm && \
echo "fi" >> prerm && \
echo "done" >> prerm && \
echo "if [ -f /etc/modprobe.d/tiny-dfr.conf ]" >> prerm && \
echo "then" >> prerm && \
echo "dkms remove -m apple-touchbar -v 0.1 --all || true" >> prerm && \
echo "fi" >> prerm && \
chmod 755 ./preinst && \
chmod 755 ./postinst && \
chmod 755 ./prerm && \
cd .. && \
cd .. && \
dpkg-deb --build --root-owner-group -Zgzip deb && \
mv ./deb.deb /repo && \
cd /repo && \
gh release download oracular -D oracular -R AdityaGarg8/t2-ubuntu-repo && \
mv ./deb.deb ./oracular && cd oracular && \
dpkg-name ./deb.deb && \
dpkg-scanpackages --multiversion . > Packages && \
gzip -k -f Packages && \
apt-ftparchive release . > Release && \
gpg --default-key "${GPG_SIGNING_EMAIL}" -abs -o - Release > Release.gpg && \
gpg --default-key "${GPG_SIGNING_EMAIL}" --clearsign -o - Release > InRelease'
cd ${{ github.workspace }}
rm key
cd oracular
if [[ $(ls | grep deb.deb) == deb.deb ]]
then
echo "publish=no" >> $GITHUB_ENV
fi
- name: Release
if: env.publish != 'no'
run: |
gh release upload oracular ${{ github.workspace }}/oracular/* --clobber -R AdityaGarg8/t2-ubuntu-repo
env:
GH_TOKEN: ${{ secrets.PAT }}

Publish-Bookworm:
runs-on: ubuntu-latest
steps:
Expand Down

0 comments on commit a96d328

Please sign in to comment.