Skip to content

Update Deb

Update Deb #483

Workflow file for this run

# This is a basic workflow to help you get started with Actions
name: Update Deb
# Controls when the workflow will run
on:
schedule:
- cron: '0 0 */2 * *'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
update:
# The type of runner that the job will run on
runs-on: ubuntu-latest
env:
PUSH: 1
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
- name: GPG user IDs
run: |
echo "fingerprint: ${{ steps.import_gpg.outputs.fingerprint }}"
echo "keyid: ${{ steps.import_gpg.outputs.keyid }}"
echo "name: ${{ steps.import_gpg.outputs.name }}"
echo "email: ${{ steps.import_gpg.outputs.email }}"
# Runs a set of commands using the runners shell
- name: Install dependencies
run: |
sudo apt install reprepro
- name: Check Update
run: |
function update_repo() {
ver=$(echo "$1" | tr -d 'v' | cut -d "-" -f 1)
reprepro --basedir "$(pwd)/meta" includedeb stable "./freetube_${ver}_amd64.deb" "./freetube_${ver}_arm64.deb" "./freetube_${ver}_armv7l.deb"
if [ -d dists ]; then rm -r dists; fi
if [ -d pool ]; then rm -r pool; fi
mv meta/dists ./
mv meta/pool ./
checksum_amd64=$(sha256sum pool/main/f/freetube/freetube_${ver}_amd64.deb)
checksum_arm64=$(sha256sum pool/main/f/freetube/freetube_${ver}_arm64.deb)
checksum_armhf=$(sha256sum pool/main/f/freetube/freetube_${ver}_armhf.deb)
sed -i -E "s,[a-f0-9]{64}[ ]+pool/main/f/freetube/freetube_[0-9]\.[0-9]+\.[0-9]_amd64.deb,$checksum_amd64," README.md
sed -i -E "s,[a-f0-9]{64}[ ]+pool/main/f/freetube/freetube_[0-9]\.[0-9]+\.[0-9]_arm64.deb,$checksum_arm64," README.md
sed -i -E "s,[a-f0-9]{64}[ ]+pool/main/f/freetube/freetube_[0-9]\.[0-9]+\.[0-9]_armhf.deb,$checksum_armhf," README.md
echo "PUSH=0" >> $GITHUB_ENV
}
function download_update() {
if [ -f /tmp/verify.log ]; then rm /tmp/verify.log; fi
ver=$(echo "$1" | tr -d 'v' | cut -d "-" -f 1)
wget -q "https://github.com/FreeTubeApp/FreeTube/releases/download/$1/freetube_${ver}_amd64.deb" --show-progress
if [ "$?" -eq "0" ]; then
echo 'amd64 downloaded'
wget -q "https://github.com/FreeTubeApp/FreeTube/releases/download/$1/freetube_${ver}_arm64.deb" --show-progress
if [ "$?" -eq "0" ]; then
echo 'arm64 downloaded'
wget -q "https://github.com/FreeTubeApp/FreeTube/releases/download/$1/freetube_${ver}_armv7l.deb" --show-progress
if [ "$?" -eq "0" ]; then
echo 'armv7l downloaded'
echo "$1" > last_update
return 0
fi
fi
fi
return 1
}
function compare (){
last_ver=$(echo "$1" | tr -d 'v')
latest_ver=$(echo "$2" | tr -d 'v')
last_big=$(echo "$last_ver" | cut -d "." -f 1)
last_medium=$(echo "$last_ver" | cut -d "." -f 2)
last_small=$(echo "$last_ver" | cut -d "." -f 3 | cut -d "-" -f 1)
latest_big=$(echo "$latest_ver" | cut -d "." -f 1)
latest_medium=$(echo "$latest_ver" | cut -d "." -f 2)
latest_small=$(echo "$latest_ver" | cut -d "." -f 3 | cut -d "-" -f 1)
if [ "$latest_big" -gt "$last_big" ]; then
return 0
else
if [ "$latest_medium" -gt "$last_medium" ]; then
return 0
else
if [ "$latest_small" -gt "$last_small" ]; then
return 0
fi
fi
fi
return 1
}
echo 'Checking update...'
releases=$(wget -qO- https://freetubeapp.io/#download | grep -o 'https://github.com/FreeTubeApp/FreeTube/releases/download/.*/freetube_.*_amd64.deb')
latest=$(echo "$releases" | egrep -o 'v[0-9]\.[0-9]+\.[0-9](-beta)?')
echo "PUSH=1" >> $GITHUB_ENV
if [ -f 'last_update' ]; then
last_update=$(cat last_update)
if compare "$last_update" "$latest"; then
echo 'Update available, downloading latest deb'
if download_update "$latest"; then
update_repo "$latest"
fi
else
echo 'No update available'
fi
else
echo 'No version file found, assuming update available'
if download_update "$latest" "$releases"; then
update_repo "$latest"
fi
fi
- name: Commit repo changes
if: ${{ env.PUSH == 0 }}
run: |
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ GITHUB.REPOSITORY }}
git status
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git add last_update dists pool README.md
git commit -m "Update packages"
git push