forked from funilrys/aur-python-box
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduction of the automatic update through GHA.
- Loading branch information
Showing
2 changed files
with
174 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
name: AUR package update Workflow | ||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
env: | ||
AUR_PKG_NAME: "python-box" | ||
|
||
jobs: | ||
update: | ||
name: "Update repository" | ||
runs-on: ubuntu-latest | ||
container: | ||
image: archlinux/archlinux:latest | ||
|
||
steps: | ||
- name: Store the SSH key | ||
run: | | ||
echo "${{ secrets.MY_SSH_KEY }}" | install -Dm600 /dev/stdin /root/.ssh/id_rsa | ||
- name: Get time for cache | ||
id: cache_time | ||
run: echo "::set-output name=time::$(date +%F-%T)" | ||
|
||
- name: Set up cache | ||
uses: actions/cache@master | ||
with: | ||
path: /var/cache/pacman/pkg | ||
key: pacman-cache-x86_64-${{ steps.cache_time.outputs.time }} | ||
restore-keys: pacman-cache-x86_64- | ||
|
||
- name: Install dependencies | ||
run: | | ||
curl -LO "https://repo.archlinuxcn.org/x86_64/${patched_glibc}" && \ | ||
bsdtar -C / -xvf "$patched_glibc" && \ | ||
rm ${patched_glibc} && \ | ||
pacman -Syu --needed --noconfirm && \ | ||
pacman -S --needed --noconfirm git binutils pacman-contrib openssh rsync | ||
env: | ||
patched_glibc: glibc-linux4-2.33-4-x86_64.pkg.tar.zst | ||
|
||
- name: Checkout Repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Update if necessary | ||
env: | ||
GIT_SSH_COMMAND: "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" | ||
run: | | ||
aurRepoDir=/tmp/${AUR_PKG_NAME} | ||
githubRepoDir="${PWD}" | ||
buildDir="/tmp/build" | ||
aurCommitMessage="$(git log -1 --pretty=format:%B)" | ||
git config --global user.name ${{ secrets.MY_GIT_NAME }} | ||
git config --global user.email ${{ secrets.MY_GIT_EMAIL }} | ||
git clone ssh://[email protected]/${AUR_PKG_NAME}.git ${aurRepoDir} | ||
rsync --progress --delete -r --exclude={'*.gz','*.xz','.github','pkg','src','.git'} ${githubRepoDir}/ ${buildDir}/ | ||
cd ${buildDir} | ||
useradd makepkg | ||
chown makepkg:root . -R | ||
su makepkg -c "updpkgsums" | ||
su makepkg -c "makepkg --printsrcinfo" > .SRCINFO | ||
rsync --progress --delete -r --exclude={'*.gz','*.xz','*.tar','.github','pkg','src','.git'} ${buildDir}/ ${githubRepoDir}/ | ||
rsync --progress --delete -r --exclude={'*.gz','*.xz','*.tar','.github','pkg','src','.git'} ${buildDir}/ ${aurRepoDir}/ | ||
cd ${aurRepoDir} | ||
git add . | ||
git diff --quiet --exit-code --cached || git commit -m "${aurCommitMessage}" | ||
git push origin master | ||
cd ${githubRepoDir} | ||
git add . | ||
git diff --quiet --exit-code --cached || git commit -m "Update .SRCINFO" | ||
git push origin master |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
name: Scheduled AUR package update Workflow | ||
on: | ||
schedule: | ||
- cron: "00 14 * * *" | ||
|
||
env: | ||
AUR_PKG_NAME: "python-box" | ||
|
||
jobs: | ||
update: | ||
name: "Update repository" | ||
runs-on: ubuntu-latest | ||
container: | ||
image: archlinux/archlinux:latest | ||
|
||
steps: | ||
- name: Store the SSH key | ||
run: | | ||
echo "${{ secrets.MY_SSH_KEY }}" | install -Dm600 /dev/stdin /root/.ssh/id_rsa | ||
- name: Get time for cache | ||
id: cache_time | ||
run: echo "::set-output name=time::$(date +%F-%T)" | ||
|
||
- name: Set up cache | ||
uses: actions/cache@master | ||
with: | ||
path: /var/cache/pacman/pkg | ||
key: pacman-cache-x86_64-${{ steps.cache_time.outputs.time }} | ||
restore-keys: pacman-cache-x86_64- | ||
|
||
- name: Install dependencies | ||
run: | | ||
curl -LO "https://repo.archlinuxcn.org/x86_64/${patched_glibc}" && \ | ||
bsdtar -C / -xvf "$patched_glibc" && \ | ||
rm ${patched_glibc} && \ | ||
pacman -Syu --needed --noconfirm && \ | ||
pacman -S --needed --noconfirm git binutils pacman-contrib openssh rsync jq | ||
env: | ||
patched_glibc: glibc-linux4-2.33-4-x86_64.pkg.tar.zst | ||
|
||
- name: Checkout Repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Update if necessary | ||
env: | ||
GIT_SSH_COMMAND: "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" | ||
run: | | ||
current=$(grep -P "^pkgver" PKGBUILD | cut -d= -f2) | ||
latest=$(curl --silent "https://pypi.org/pypi/python-box/json" | jq -r .info.version) | ||
aurRepoDir=/tmp/${AUR_PKG_NAME} | ||
githubRepoDir="${PWD}" | ||
buildDir="/tmp/build" | ||
echo "Previous version: ${current}" | ||
echo "New version: ${latest}" | ||
[[ "${current}" == "${latest}" ]] && exit 0 | ||
git config --global user.name ${{ secrets.MY_GIT_NAME }} | ||
git config --global user.email ${{ secrets.MY_GIT_EMAIL }} | ||
git clone ssh://[email protected]/${AUR_PKG_NAME}.git ${aurRepoDir} | ||
rsync --progress --delete -r --exclude={'*.gz','*.xz','.github','pkg','src','.git'} ${githubRepoDir}/ ${buildDir}/ | ||
cd ${buildDir} | ||
useradd makepkg | ||
chown makepkg:root . -R | ||
sed "/^pkgver=/s/.*/pkgver=${latest}/" -i PKGBUILD | ||
sed "/^pkgrel=/s/.*/pkgrel=1/" -i PKGBUILD | ||
su makepkg -c "updpkgsums" | ||
su makepkg -c "makepkg --printsrcinfo" > .SRCINFO | ||
rsync --progress --delete -r --exclude={'*.gz','*.xz','*.tar','.github','pkg','src','.git'} ${buildDir}/ ${githubRepoDir}/ | ||
rsync --progress --delete -r --exclude={'*.gz','*.xz','*.tar','.github','pkg','src','.git'} ${buildDir}/ ${aurRepoDir}/ | ||
cd ${aurRepoDir} | ||
git add . | ||
git commit -m "Update ${AUR_PKG_NAME} to v${latest}" | ||
git push origin master | ||
cd ${githubRepoDir} | ||
git add . | ||
git commit -m "Update ${AUR_PKG_NAME} to v${latest}" | ||
git push origin master |