Check for new Releases #183
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Check for new Releases | |
on: | |
push: | |
branches: | |
- main | |
schedule: | |
- cron: '0 0,6,12,18 * * *' | |
workflow_dispatch: | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
release_check: | |
name: Release Check | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
outputs: | |
list: ${{ steps.releases.outputs.list_updates }} | |
steps: | |
- name: Install dependencies | |
run: | | |
sudo apt install -y fd-find jq | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: '0' | |
- name: Check for new releases | |
id: releases | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
updates=() | |
for dir in $(fd --type d) | |
do | |
pushd ${dir%/} | |
author_repo= | |
author_repo=($(sed -nr "s|\s*source[^ ]* =.*https://github.com/([^/]+)/([^\.\/\#]*).*|\1 \2|p" .SRCINFO)) | |
if ! [[ -z "${author_repo+x}" ]]; then | |
author= | |
repo= | |
author=${author_repo[0]} | |
repo=${author_repo[1]} | |
curl \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer ${GITHUB_TOKEN}" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
https://api.github.com/repos/${author}/${repo}/releases -o /tmp/releases.json | |
echo release_latest=$(jq -r '.[0]["tag_name"]|ltrimstr("v")' < /tmp/releases.json) >> $GITHUB_ENV | |
echo pb_pkgver=$(sed -nr "s/^pkgver=(\S+)/\1/p" PKGBUILD) >> $GITHUB_ENV | |
if [[ $release_latest == $pb_pkgver ]]; | |
then | |
updates+=("${dir%/}") | |
fi | |
else | |
echo "source is not github" | |
author_repo= | |
author_repo=($(sed -nr "s|\s*source[^ ]* =.*https://github.com/([^/]+)/([^\.\/\#]*).*|\1 \2|p" .SRCINFO)) | |
fi | |
popd | |
done | |
echo "list_updates=$(jq -cn '$ARGS.positional' --args "${updates[@]}")" >> $GITHUB_OUTPUT | |
now_build: | |
needs: release_check | |
runs-on: ubuntu-latest | |
container: archlinux:base-devel | |
if: needs.release_check.outputs.list != '[]' | |
strategy: | |
matrix: | |
package: ${{ fromJson(needs.release_check.outputs.list) }} | |
steps: | |
- name: Test | |
run: | | |
echo ${{ matrix.package }} | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: '0' | |
- name: Update system and install dependencies | |
run: | | |
pacman -Syu --noconfirm | |
pacman -S --noconfirm --needed fd jq namcap | |
- name: Create user to run makepkg | |
run: | | |
useradd -m dev | |
echo "dev ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/01_dev | |
- name: chown for dev | |
run: | | |
chown -R dev: . | |
- name: Install yay | |
run: | | |
runuser -u dev -- git clone https://aur.archlinux.org/yay.git | |
cd yay | |
runuser -u dev -- makepkg -csri --noconfirm | |
- name: Test -- Build and install package | |
run: | | |
runuser -u dev -- makepkg -si --noconfirm |