Release 0.16.0 #43
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: Publish to AUR | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "Release version (e.g. 0.6.5)" | |
| required: true | |
| jobs: | |
| aur: | |
| runs-on: ubuntu-slim | |
| environment: | |
| name: aur | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install tools | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y git curl openssh-client | |
| - name: Determine release version | |
| id: version | |
| run: | | |
| if [ -n "${{ github.event.inputs.version }}" ]; then | |
| VERSION="${{ github.event.inputs.version }}" | |
| else | |
| TAG="${GITHUB_REF_NAME}" | |
| VERSION="${TAG#v}" | |
| fi | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| - name: Download release tarball | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| if [ "${{ github.event_name }}" = "release" ]; then | |
| TAG="${GITHUB_REF_NAME}" | |
| else | |
| TAG="${VERSION}" | |
| fi | |
| echo "Downloading tag: ${TAG}" | |
| curl -fL \ | |
| -o cai-${VERSION}.tar.gz \ | |
| https://github.com/thorstenfoltz/cai/archive/refs/tags/${TAG}.tar.gz | |
| - name: Compute sha256sum | |
| id: sha | |
| run: | | |
| SHA256=$(sha256sum cai-${{ steps.version.outputs.version }}.tar.gz | awk '{print $1}') | |
| echo "sha256=$SHA256" >> "$GITHUB_OUTPUT" | |
| - name: Configure SSH for AUR (RSA) | |
| run: | | |
| mkdir -p ~/.ssh | |
| echo "${{ secrets.AUR_SSH_PRIVATE_KEY }}" > ~/.ssh/aur | |
| chmod 600 ~/.ssh/aur | |
| cat >> ~/.ssh/config <<'EOF' | |
| Host aur.archlinux.org | |
| IdentityFile ~/.ssh/aur | |
| User aur | |
| EOF | |
| ssh-keyscan aur.archlinux.org >> ~/.ssh/known_hosts | |
| - name: Clone AUR repository (master branch) | |
| run: | | |
| git -c init.defaultBranch=master clone \ | |
| ssh://aur@aur.archlinux.org/cai.git aur | |
| - name: Copy PKGBUILD and .SRCINFO | |
| run: | | |
| cp .github/cd/PKGBUILD aur/PKGBUILD | |
| cp .github/cd/.SRCINFO aur/.SRCINFO | |
| - name: Update PKGBUILD and .SRCINFO | |
| run: | | |
| cd aur | |
| VERSION="${{ steps.version.outputs.version }}" | |
| SHA="${{ steps.sha.outputs.sha256 }}" | |
| # PKGBUILD | |
| sed -i \ | |
| -e "s/^pkgver=.*/pkgver=${VERSION}/" \ | |
| -e "/^sha256sums=/,/^)/c\sha256sums=(\n '${SHA}'\n)" \ | |
| PKGBUILD | |
| # .SRCINFO | |
| sed -i \ | |
| -e "s/^\tpkgver = .*/\tpkgver = ${VERSION}/" \ | |
| -e "s|^\tsource = .*|\tsource = cai-${VERSION}.tar.gz::https://github.com/thorstenfoltz/cai/archive/refs/tags/${VERSION}.tar.gz|" \ | |
| -e "s/^\tsha256sums = .*/\tsha256sums = ${SHA}/" \ | |
| .SRCINFO | |
| - name: Show updated files | |
| run: | | |
| cd aur | |
| cat PKGBUILD | |
| echo "-----" | |
| cat .SRCINFO | |
| - name: Verify PKGBUILD and .SRCINFO have changed | |
| run: | | |
| set -euo pipefail | |
| cd aur | |
| STATUS="$(git status --porcelain)" | |
| echo "$STATUS" | grep -q '^.*PKGBUILD$' | |
| echo "$STATUS" | grep -q '^.*\.SRCINFO$' | |
| - name: Commit and push | |
| run: | | |
| cd aur | |
| git config user.name "GitHub Actions" | |
| git config user.email "actions@github.com" | |
| git add PKGBUILD .SRCINFO | |
| git commit -m "release ${{ steps.version.outputs.version }}" | |
| git push |