name: Publish to AUR on: push: branches: - main - master tags: - 'v*' workflow_dispatch: inputs: tag: description: 'Tag (v开头)' required: false type: string jobs: aur: runs-on: ubuntu-latest container: image: archlinux:latest if: | github.event_name == 'workflow_dispatch' && github.event.inputs.tag != '' || startsWith(github.ref, 'refs/tags/v') steps: - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up SSH for AUR run: | mkdir -p ~/.ssh echo "${{ secrets.AUR_SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519 chmod 600 ~/.ssh/id_ed25519 - name: Install dependencies run: pacman -Sy --noconfirm git openssh base-devel - name: Add AUR host to known_hosts run: ssh-keyscan -t ed25519 aur.archlinux.org >> ~/.ssh/known_hosts - name: Debug SSH setup run: | ls -l ~/.ssh cat ~/.ssh/id_ed25519 cat ~/.ssh/known_hosts - name: Clone AUR repository and update PKGBUILD run: | git clone ssh://aur@aur.archlinux.org/soon.git aur-repo cd aur-repo if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ "${{ github.event.inputs.tag }}" != "" ]; then TAG="${{ github.event.inputs.tag }}" else TAG="${GITHUB_REF##*/}" fi VERSION="${TAG#v}" sed -i "s/^pkgver=.*/pkgver=${VERSION}/" PKGBUILD makepkg --printsrcinfo > .SRCINFO git add PKGBUILD .SRCINFO if git diff --cached --quiet; then echo "No changes to commit" exit 0 fi git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" git commit -m "release: $TAG" git push origin master