Skip to content

APFS driver update script #596

APFS driver update script

APFS driver update script #596

Workflow file for this run

---
name: APFS driver update script
on:
schedule:
- cron: '30 18 * * *'
workflow_dispatch:
jobs:
Publish:
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 --decode | gpg --import
env:
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
- name: Get the latest driver
id: publish
run: |
source ${{ github.workspace }}/apt-repo/apfs_ver.txt
echo "currenthash=${CURRENT_HASH}" >> $GITHUB_ENV
echo "releasever=${RELEASE_VER}" >> $GITHUB_ENV
git clone --depth 1 https://github.com/linux-apfs/linux-apfs-rw.git
cd linux-apfs-rw
LATEST_HASH=$(git rev-parse HEAD)
echo "latesthash=${LATEST_HASH}" >> $GITHUB_ENV
DKMS_VER=$(cat ./dkms.conf | grep PACKAGE_VERSION | cut -d "\"" -f 2)
DKMS_NAME=$(cat ./dkms.conf | grep PACKAGE_NAME | cut -d "\"" -f 2)
rm -r .git
rm .gitignore
rm README.rst
if [[ ${CURRENT_HASH} = ${LATEST_HASH} ]]
then
echo "publish=no" >> $GITHUB_ENV
exit 0
else
echo "publish=yes" >> $GITHUB_ENV
RELEASE_VER_MAIN=$(echo ${RELEASE_VER} | cut -d "." -f 1,2,3)
if [[ ${RELEASE_VER_MAIN} != ${DKMS_VER} ]]
then
NEW_RELEASE_VER=${DKMS_VER}.0
else
RELEASE_VER_SUB=$(echo ${RELEASE_VER} | cut -d "." -f 4)
NEW_RELEASE_VER_SUB=$((${RELEASE_VER_SUB} + 1))
NEW_RELEASE_VER=${DKMS_VER}.${NEW_RELEASE_VER_SUB}
fi
echo "ver=${NEW_RELEASE_VER}" >> $GITHUB_ENV
cd ${{ github.workspace }}
mkdir linux-apfs
cd linux-apfs
mkdir usr
cd usr
mkdir src
cd src
mkdir ${DKMS_NAME}-${DKMS_VER}
cp -r ${{ github.workspace }}/linux-apfs-rw/* ${{ github.workspace }}/linux-apfs/usr/src/${DKMS_NAME}-${DKMS_VER}
cd ${{ github.workspace }}/linux-apfs
mkdir DEBIAN
cd DEBIAN
echo "Package: linux-apfs" > control
echo "Version: ${NEW_RELEASE_VER}" >> control
echo "Maintainer: Aditya Garg" >> control
echo "Architecture: amd64" >> control
echo "Description: Apple File System driver for Linux" >> control
echo "Depends: dkms" >> control
echo "dkms add -m linux-apfs-rw -v ${DKMS_VER}" > postinst
echo "dkms build -m linux-apfs-rw -v ${DKMS_VER} && dkms install -m linux-apfs-rw -v ${DKMS_VER} || true" >> postinst
echo "dkms remove -m linux-apfs-rw -v ${DKMS_VER} --all || true" > prerm
chmod 755 ./postinst
chmod 755 ./prerm
cd ${{ github.workspace }}
dpkg-deb --build --root-owner-group linux-apfs
git clone https://github.com/AdityaGarg8/t2-ubuntu-repo.git
mv ${{ github.workspace }}/linux-apfs.deb ${{ github.workspace }}/t2-ubuntu-repo
cd ${{ github.workspace }}/t2-ubuntu-repo
# Packages & Packages.gz
dpkg-name ./linux-apfs.deb
dpkg-scanpackages --multiversion . > Packages
gzip -k -f Packages
# Release, Release.gpg & InRelease
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 }}
fi
env:
GPG_SIGNING_EMAIL: ${{ secrets.GPG_SIGNING_EMAIL }}
- name: Publish
if: env.publish == 'yes'
uses: cpina/github-action-push-to-another-repository@main
env:
SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }}
with:
source-directory: 't2-ubuntu-repo'
destination-github-username: 'AdityaGarg8'
destination-repository-name: 't2-ubuntu-repo'
user-email: github-actions[bot]@users.noreply.github.com
user-name: github-actions[bot]
target-branch: main
commit-message: Update APFS driver to v${{ env.ver }}
- name: Cleanup and update the repo
if: env.publish == 'yes'
id: clean
run: |
cd ${{ github.workspace }}
rm -r linux-apfs-rw
rm -r linux-apfs
rm -r t2-ubuntu-repo
sed -i "s/${{ env.releasever }}/${{ env.ver }}/g" ${{ github.workspace }}/apt-repo/apfs_ver.txt
sed -i "s/${{ env.currenthash }}/${{ env.latesthash }}/g" ${{ github.workspace }}/apt-repo/apfs_ver.txt
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git commit -m "Update APFS driver to v${{ env.ver }}" -a
- name: Push changes to the repo
if: env.publish == 'yes'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.PAT }}
branch: ${{ github.ref }}