name: Update AUR Package on: release: types: [published] workflow_dispatch: inputs: tag_name: description: 'Release tag name (e.g., v1.2.3)' required: true type: string jobs: update-aur: runs-on: ubuntu-latest if: github.repository == 'Wraient/curd' steps: - name: Checkout main repository uses: actions/checkout@v4 - name: Extract version from tag id: version run: | if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then TAG_NAME="${{ github.event.inputs.tag_name }}" else TAG_NAME="${{ github.event.release.tag_name }}" fi VERSION=$(echo "$TAG_NAME" | sed 's/^v//') echo "version=$VERSION" >> $GITHUB_OUTPUT echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT echo "Extracted version: $VERSION" - name: Install dependencies run: | sudo apt-get update sudo apt-get install -y expect git sshpass - name: Set up SSH for AUR run: | mkdir -p ~/.ssh echo "${{ secrets.AUR_SSH_KEY }}" > ~/.ssh/aur_rsa chmod 600 ~/.ssh/aur_rsa # Create SSH config for AUR cat > ~/.ssh/config << EOF Host aur.archlinux.org HostName aur.archlinux.org User aur IdentityFile ~/.ssh/aur_rsa StrictHostKeyChecking no EOF # Start SSH agent and add key with passphrase eval $(ssh-agent -s) echo "SSH_AUTH_SOCK=$SSH_AUTH_SOCK" >> $GITHUB_ENV echo "SSH_AGENT_PID=$SSH_AGENT_PID" >> $GITHUB_ENV # Use expect to add the key with passphrase expect -c " spawn ssh-add ~/.ssh/aur_rsa expect \"Enter passphrase\" send \"sex\r\" expect eof " - name: Clone AUR repository run: | # The SSH agent should still be running with the key loaded git clone ssh://aur@aur.archlinux.org/curd.git aur-curd - name: Update PKGBUILD working-directory: aur-curd run: | # Configure git git config user.name "Wraient" git config user.email "rushikeshwastaken@gmail.com" # Update pkgver in PKGBUILD sed -i "s/^pkgver=.*/pkgver=${{ steps.version.outputs.version }}/" PKGBUILD # Reset pkgrel to 1 for new version sed -i "s/^pkgrel=.*/pkgrel=1/" PKGBUILD # Update .SRCINFO makepkg --printsrcinfo > .SRCINFO echo "Updated PKGBUILD:" cat PKGBUILD - name: Verify release exists run: | # Check if the release and binary exist curl -f -L -I "https://github.com/Wraient/curd/releases/download/${{ steps.version.outputs.tag_name }}/curd-linux-x86_64" || { echo "Error: Release binary not found!" echo "Expected URL: https://github.com/Wraient/curd/releases/download/${{ steps.version.outputs.tag_name }}/curd-linux-x86_64" exit 1 } - name: Commit and push to AUR working-directory: aur-curd run: | # Check if there are changes to commit if git diff --quiet && git diff --cached --quiet; then echo "No changes to commit" exit 0 fi # Add and commit changes git add PKGBUILD .SRCINFO git commit -m "Update to version ${{ steps.version.outputs.version }}" # Push changes (SSH agent should still have the key loaded) git push origin master - name: Cleanup if: always() run: | # Clean up SSH keys and kill SSH agent rm -f ~/.ssh/aur_rsa if [ -n "$SSH_AGENT_PID" ]; then kill $SSH_AGENT_PID 2>/dev/null || true fi