Update ReadCat #1331
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: Update ReadCat | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- '.github/workflows/**' | |
- '**/PKGBUILD' | |
- '**/*.desktop' | |
workflow_dispatch: | |
schedule: | |
- cron: "0 */1 * * *" | |
jobs: | |
prepare: | |
name: Get upstream release info | |
runs-on: ubuntu-latest | |
outputs: | |
release: ${{ steps.get-basic-info.outputs.release }} | |
pkgver: ${{ steps.get-basic-info.outputs.pkgver }} | |
subver: ${{ steps.get-basic-info.outputs.subver }} | |
source: ${{ steps.get-basic-info.outputs.source }} | |
sha256sums: ${{ steps.get-basic-info.outputs.sha256sums }} | |
steps: | |
- name: Install jq | |
run: sudo apt-get update && sudo apt-get install -y jq | |
- name: Get basic info | |
id: get-basic-info | |
run: | | |
RELEASE_INFO=$(curl -s https://api.github.com/repos/read-cat/read-cat/releases | jq -M '.[0].assets[] | select(.browser_download_url | test("linux-x64"))' | jq -cs '.') | |
TAG_INFO=$(curl -s https://api.github.com/repos/read-cat/read-cat/releases | jq -r '.[0].tag_name') | |
TAG_INFO=${TAG_INFO#v} | |
read MAJOR_VERSION SUB_VERSION <<< $(echo $TAG_INFO | awk -F '[-]' '{print $1,$2}') | |
echo "release=$RELEASE_INFO" >> "$GITHUB_OUTPUT" | |
echo "pkgver=$MAJOR_VERSION" >> "$GITHUB_OUTPUT" | |
echo "subver=$SUB_VERSION" >> "$GITHUB_OUTPUT" | |
DOWNLOAD_URLS=$(echo $RELEASE_INFO | jq -r '.[].browser_download_url') | |
for url in $DOWNLOAD_URLS; do | |
if [[ $url == *".sha256.txt" ]]; then | |
echo "sha256sums=$(curl -sL $url | grep -v '^$' | head -n 1)" >> "$GITHUB_OUTPUT" | |
else | |
echo "source=$url" >> "$GITHUB_OUTPUT" | |
fi | |
done | |
build-pkgbuild: | |
needs: prepare | |
name: Edit PKGBUILD and push | |
runs-on: ubuntu-latest | |
container: archlinux | |
env: | |
PKG_VER: ${{ needs.prepare.outputs.pkgver }} | |
PKG_SUB_VER: ${{ needs.prepare.outputs.subver }} | |
SOURCE: ${{ needs.prepare.outputs.source }} | |
SHA256: ${{ needs.prepare.outputs.sha256sums }} | |
ARCH_PKG_NAME: read-cat-insiders-${{ needs.prepare.outputs.pkgver }}-1-x86_64.pkg.tar.zst | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install dependencies and update | |
run: | |
pacman -Syu --noconfirm --noprogressbar --needed base-devel git pacman-contrib | |
- name: Update version | |
id: bump-version | |
working-directory: read-cat-insiders | |
run: | | |
sed -i "s/pkgver=.*$/pkgver=${PKG_VER}/" PKGBUILD | |
sed -i "s/_pkgsubver=.*$/_pkgsubver=${PKG_SUB_VER}/" PKGBUILD | |
sed -i "s|source_x86_64=.*|source_x86_64=('${SOURCE}')|" PKGBUILD | |
sed -i "s|sha256sums_x86_64=.*|sha256sums_x86_64=('${SHA256}')|" PKGBUILD | |
cat PKGBUILD | |
- name: Generate .SRCINFO | |
working-directory: read-cat-insiders | |
run: | | |
useradd builder -m | |
echo "builder ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers | |
chmod -R a+rw . | |
sudo -Eu builder makepkg --printsrcinfo > .SRCINFO | |
- name: Build package | |
uses: 2m/arch-pkgbuild-builder@main | |
with: | |
target: pkgbuild | |
pkgname: "read-cat-insiders" | |
- name: Generate package sha256sums | |
working-directory: read-cat-insiders | |
run: | | |
chmod -R a+rw . | |
sudo -Eu builder updpkgsums | |
- name: Upload PKGBUILD artefact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: PKGBUILD | |
path: read-cat-insiders/PKGBUILD | |
- name: Upload .SRCINFO artefact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: .SRCINFO | |
path: read-cat-insiders/.SRCINFO | |
- name: Upload package artefact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.ARCH_PKG_NAME}} | |
path: read-cat-insiders/${{ env.ARCH_PKG_NAME}} | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: gh-pages | |
path: dist | |
- name: Move to repo | |
run: | | |
mkdir -p dist/x86_64/ | |
mv -f read-cat-insiders/${{ env.ARCH_PKG_NAME}} dist/x86_64/ | |
- name: Deploy | |
uses: peaceiris/actions-gh-pages@v4 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./dist | |
user_name: "github-actions[bot]" | |
user_email: "41898282+github-actions[bot]@users.noreply.github.com" | |
commit_message: "🐎 ci(ReadCat): Update ${{ env.ARCH_PKG_NAME}}" | |
force_orphan: true | |
update-pkgbuild: | |
name: Update PKGBUILD | |
needs: [prepare, build-pkgbuild] | |
runs-on: ubuntu-latest | |
env: | |
PKG_VER: ${{ needs.prepare.outputs.pkgver }} | |
PKG_SUB_VER: ${{ needs.prepare.outputs.subver }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download PKGBUILD artefact | |
uses: actions/download-artifact@v4 | |
with: | |
name: PKGBUILD | |
path: read-cat-insiders/ | |
- name: Download .SRCINFO artefact | |
uses: actions/download-artifact@v4 | |
with: | |
name: .SRCINFO | |
path: read-cat-insiders/ | |
- name: Push update | |
working-directory: read-cat-insiders | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git add PKGBUILD .SRCINFO | |
if git diff --cached --quiet; then | |
echo "No changes detected. Skipping commit." | |
else | |
git commit -m "🐎 ci(ReadCat): Update to v${PKG_VER}_${PKG_SUB_VER}" | |
git push | |
fi | |
update-aur: | |
name: Update AUR | |
needs: [prepare, build-pkgbuild] | |
runs-on: ubuntu-latest | |
env: | |
PKG_VER: ${{ needs.prepare.outputs.pkgver }} | |
PKG_SUB_VER: ${{ needs.prepare.outputs.subver }} | |
steps: | |
- name: Prepare for AUR | |
run: | | |
git config --global user.name "easterNday" | |
git config --global user.email "[email protected]" | |
mkdir -p aur && cd aur | |
- name: Download PKGBUILD artefact | |
uses: actions/download-artifact@v4 | |
with: | |
name: PKGBUILD | |
path: aur/ | |
- name: Publish AUR package | |
uses: KSXGitHub/github-actions-deploy-aur@v2 | |
with: | |
pkgname: read-cat-insiders | |
pkgbuild: ./aur/PKGBUILD | |
commit_username: 'easterNday' | |
commit_email: '[email protected]' | |
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }} | |
commit_message: Update AUR package | |
ssh_keyscan_types: rsa,ecdsa,ed25519 |