Auto-update AUR Package #4
Workflow file for this run
This file contains hidden or 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: Auto-update AUR Package | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| jobs: | |
| update-aur: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Get upstream latest release | |
| id: upstream | |
| run: | | |
| LATEST=$(curl -s https://api.github.com/repos/Moonfin-Client/Mobile-Desktop/releases/latest | jq -r '.tag_name') | |
| echo "version=$LATEST" >> "$GITHUB_OUTPUT" | |
| echo "Upstream latest version: $LATEST" | |
| - name: Setup SSH for AUR | |
| run: | | |
| mkdir -p ~/.ssh | |
| echo "${{ secrets.AUR_SSH_PRIVATE_KEY }}" > ~/.ssh/aur_key | |
| chmod 600 ~/.ssh/aur_key | |
| cat > ~/.ssh/config << EOF | |
| Host aur.archlinux.org | |
| IdentityFile ~/.ssh/aur_key | |
| User aur | |
| StrictHostKeyChecking accept-new | |
| EOF | |
| chmod 600 ~/.ssh/config | |
| - name: Clone AUR package | |
| run: | | |
| git clone ssh://aur@aur.archlinux.org/moonfin-bin.git /tmp/aur-package | |
| cd /tmp/aur-package | |
| CURRENT_VERSION=$(grep '^pkgver=' PKGBUILD | cut -d'=' -f2) | |
| echo "current_version=$CURRENT_VERSION" >> "$GITHUB_ENV" | |
| echo "AUR current version: $CURRENT_VERSION" | |
| - name: Check if update needed | |
| id: check | |
| run: | | |
| VERSION="${{ steps.upstream.outputs.version }}" | |
| if [ -z "$VERSION" ] || [ "$VERSION" = "null" ]; then | |
| echo "Upstream returned null, skipping update" | |
| echo "needed=false" >> "$GITHUB_OUTPUT" | |
| elif [ "$VERSION" != "$current_version" ]; then | |
| echo "Update needed: $current_version -> $VERSION" | |
| echo "needed=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "No update needed (version: $current_version)" | |
| echo "needed=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Download release and calculate checksum | |
| if: steps.check.outputs.needed == 'true' | |
| id: download | |
| run: | | |
| VERSION="${{ steps.upstream.outputs.version }}" | |
| URL="https://github.com/Moonfin-Client/Mobile-Desktop/releases/download/${VERSION}/Moonfin_Linux_v${VERSION}.tar.gz" | |
| curl -L -o /tmp/moonfin-linux.tar.gz "$URL" | |
| SHA256=$(sha256sum /tmp/moonfin-linux.tar.gz | cut -d' ' -f1) | |
| echo "sha256=$SHA256" >> "$GITHUB_OUTPUT" | |
| echo "Downloaded release, SHA256: $SHA256" | |
| - name: Update AUR package | |
| if: steps.check.outputs.needed == 'true' | |
| run: | | |
| VERSION="${{ steps.upstream.outputs.version }}" | |
| SHA256="${{ steps.download.outputs.sha256 }}" | |
| cd /tmp/aur-package | |
| git config user.name "${{ vars.GIT_USER_NAME }}" | |
| git config user.email "${{ vars.GIT_USER_EMAIL }}" | |
| # Update PKGBUILD | |
| sed -i "s/^pkgver=.*/pkgver=${VERSION}/" PKGBUILD | |
| sed -i "s/^pkgrel=.*/pkgrel=1/" PKGBUILD | |
| sed -i "s/^sha256sums=.*/sha256sums=('${SHA256}')/" PKGBUILD | |
| # Update .SRCINFO (makepkg not available on ubuntu runner) | |
| sed -i "s/^\tpkgver = .*/\tpkgver = ${VERSION}/" .SRCINFO | |
| sed -i "s/^\tpkgrel = .*/\tpkgrel = 1/" .SRCINFO | |
| sed -i "s|^\tsource = .*|\tsource = moonfin-bin-${VERSION}.tar.gz::https://github.com/Moonfin-Client/Mobile-Desktop/releases/download/${VERSION}/Moonfin_Linux_v${VERSION}.tar.gz|" .SRCINFO | |
| sed -i "s/^\tsha256sums = .*/\tsha256sums = ${SHA256}/" .SRCINFO | |
| git add PKGBUILD .SRCINFO | |
| git commit -m "Update to ${VERSION}" | |
| git push origin master |