|
| 1 | +name: Update AUR Package |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + |
| 7 | +jobs: |
| 8 | + update-aur: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + |
| 11 | + steps: |
| 12 | + - name: Checkout main repo |
| 13 | + uses: actions/checkout@v4 |
| 14 | + with: |
| 15 | + repository: Matars/gitfetch |
| 16 | + path: gitfetch |
| 17 | + |
| 18 | + - name: Get version from pyproject.toml |
| 19 | + id: get_version |
| 20 | + run: | |
| 21 | + VERSION=$(grep '^version =' gitfetch/pyproject.toml | sed 's/version = "\(.*\)"/\1/') |
| 22 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 23 | +
|
| 24 | + - name: Download release tarball |
| 25 | + run: | |
| 26 | + curl -L -o release.tar.gz https://github.com/Matars/gitfetch/archive/refs/tags/v${{ steps.get_version.outputs.version }}.tar.gz |
| 27 | +
|
| 28 | + - name: Calculate SHA256 |
| 29 | + id: sha256 |
| 30 | + run: | |
| 31 | + SHA256=$(shasum -a 256 release.tar.gz | cut -d' ' -f1) |
| 32 | + echo "sha256=$SHA256" >> $GITHUB_OUTPUT |
| 33 | +
|
| 34 | + - name: Setup SSH |
| 35 | + run: | |
| 36 | + mkdir -p ~/.ssh |
| 37 | + echo "${{ secrets.AUR_TOKEN }}" > ~/.ssh/aur_key |
| 38 | + chmod 600 ~/.ssh/aur_key |
| 39 | + ssh-keyscan -H aur.archlinux.org >> ~/.ssh/known_hosts |
| 40 | +
|
| 41 | + - name: Clone AUR repo |
| 42 | + run: | |
| 43 | + git clone ssh://aur@aur.archlinux.org/gitfetch-python.git aur-repo |
| 44 | + cd aur-repo |
| 45 | + git config user.name "GitHub Actions" |
| 46 | + git config user.email "actions@github.com" |
| 47 | +
|
| 48 | + - name: Update PKGBUILD |
| 49 | + run: | |
| 50 | + cd aur-repo |
| 51 | + sed -i 's/pkgver=.*/pkgver=${{ steps.get_version.outputs.version }}/' PKGBUILD |
| 52 | + sed -i 's|source=.*|source=("$pkgname-$pkgver.tar.gz::https://github.com/Matars/gitfetch/archive/refs/tags/v$pkgver.tar.gz")|' PKGBUILD |
| 53 | + sed -i "s/sha256sums=.*/sha256sums=('${{ steps.sha256.outputs.sha256 }}')/" PKGBUILD |
| 54 | +
|
| 55 | + - name: Update .SRCINFO |
| 56 | + run: | |
| 57 | + cd aur-repo |
| 58 | + sed -i 's/pkgver = .*/pkgver = ${{ steps.get_version.outputs.version }}/' .SRCINFO |
| 59 | + sed -i 's|source = .*|source = gitfetch-python-${{ steps.get_version.outputs.version }}.tar.gz::https://github.com/Matars/gitfetch/archive/refs/tags/v${{ steps.get_version.outputs.version }}.tar.gz|' .SRCINFO |
| 60 | + sed -i "s/sha256sums = .*/sha256sums = ${{ steps.sha256.outputs.sha256 }}/" .SRCINFO |
| 61 | +
|
| 62 | + - name: Commit and push |
| 63 | + run: | |
| 64 | + cd aur-repo |
| 65 | + git add PKGBUILD .SRCINFO |
| 66 | + git commit -m "Update gitfetch-python to v${{ steps.get_version.outputs.version }}" |
| 67 | + GIT_SSH_COMMAND="ssh -i ~/.ssh/aur_key -o UserKnownHostsFile=~/.ssh/known_hosts" git push |
0 commit comments