Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 105 additions & 0 deletions .github/DEPLOYMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Deployment Guide

This repository includes a GitHub Actions workflow for automated deployment to AUR and creating GitHub releases.

## Workflow: Deploy to AUR and Create Release

### Location
`.github/workflows/deploy.yml`

### Purpose
This workflow automates the process of:
1. Bumping the version in the `hyproled` script
2. Creating a Git tag
3. Creating a GitHub release
4. Deploying the update to the AUR (Arch User Repository)

### How to Use

1. Go to the **Actions** tab in the GitHub repository
2. Select the **Deploy to AUR and Create Release** workflow
3. Click **Run workflow**
4. Choose the version bump type:
- **patch**: Increment the patch version (e.g., X.Y.Z → X.Y.Z+1)
- **minor**: Increment the minor version (e.g., X.Y.Z → X.Y+1.0)
- **major**: Increment the major version (e.g., X.Y.Z → X+1.0.0)
5. Click **Run workflow** to start the deployment

### Required Secrets

For the workflow to function properly, you need to configure the following secret in your GitHub repository:

#### AUR_SSH_KEY

This is the SSH private key used to authenticate with the AUR repository.

**Setup Instructions:**

1. Generate an SSH key pair (if you don't have one):
```bash
ssh-keygen -t ed25519 -C "your-email@example.com" -f ~/.ssh/aur
```

2. Add the public key to your AUR account:
- Log in to https://aur.archlinux.org
- Go to **My Account** → **SSH Public Keys**
- Add the contents of `~/.ssh/aur.pub`

3. Add the private key as a GitHub secret:
- Go to your repository's **Settings** → **Secrets and variables** → **Actions**
- Click **New repository secret**
- Name: `AUR_SSH_KEY`
- Value: Paste the contents of `~/.ssh/aur` (the private key)

### What the Workflow Does

1. **Version Bump**: Updates the version number in the `hyproled` script based on your selection
2. **Git Tag**: Creates and pushes a new Git tag (e.g., `vX.Y.Z`)
3. **GitHub Release**: Creates a new GitHub release with:
- Release notes
- Installation instructions
- Links to AUR package
4. **AUR Deployment**:
- Clones the AUR repository
- Updates the `PKGBUILD` file (increments `pkgrel`)
- Updates `.SRCINFO`
- Pushes changes to AUR

### Manual Deployment (Alternative)

If you prefer to deploy manually:

1. Update version in `hyproled`:
```bash
# Example: update the version line in the script
sed -i 's/version: X.Y.Z/version: X.Y.ZNEW/' hyproled
git commit -am "Bump version to X.Y.ZNEW"
git tag -a vX.Y.ZNEW -m "Release vX.Y.ZNEW"
git push && git push --tags
```

2. Create GitHub release through the web interface

3. Deploy to AUR:
```bash
git clone ssh://aur@aur.archlinux.org/hyproled-git.git
cd hyproled-git
# Update PKGBUILD (increment pkgrel)
makepkg --printsrcinfo > .SRCINFO
git add PKGBUILD .SRCINFO
git commit -m "Update to version X.Y.ZNEW"
git push
```

### Troubleshooting

- **Workflow fails at AUR deployment**: Make sure the `AUR_SSH_KEY` secret is correctly configured
- **Version not updating**: Check that the version format in `hyproled` follows `version: X.Y.Z`
- **Push fails**: Ensure the GitHub Actions bot has permission to push to the repository (this should be enabled by default)

### Notes

- The workflow uses `workflow_dispatch`, meaning it only runs when manually triggered
- The AUR package is `hyproled-git`, which tracks the Git repository
- For `-git` AUR packages, we increment `pkgrel` rather than changing `pkgver`
- The workflow requires `makepkg` to be available for generating `.SRCINFO`
175 changes: 175 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
name: Deploy to AUR and Create Release

on:
workflow_dispatch:
inputs:
version_bump:
description: 'Version bump type'
required: true
type: choice
options:
- patch
- minor
- major
default: 'patch'

jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: write # Required for creating tags, committing, and creating releases

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

- name: Get current version
id: get_version
run: |
CURRENT_VERSION=$(grep -oP 'version: \K[0-9]+\.[0-9]+\.[0-9]+' hyproled)
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
echo "Current version: $CURRENT_VERSION"

- name: Calculate new version
id: calc_version
run: |
VERSION="${{ steps.get_version.outputs.current_version }}"
IFS='.' read -r major minor patch <<< "$VERSION"

case "${{ github.event.inputs.version_bump }}" in
major)
major=$((major + 1))
minor=0
patch=0
;;
minor)
minor=$((minor + 1))
patch=0
;;
patch)
patch=$((patch + 1))
;;
esac

NEW_VERSION="${major}.${minor}.${patch}"
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "New version: $NEW_VERSION"

- name: Update version in hyproled script
run: |
sed -i "s/version: [0-9]\+\.[0-9]\+\.[0-9]\+/version: ${{ steps.calc_version.outputs.new_version }}/" hyproled
git add hyproled
git commit -m "Bump version to ${{ steps.calc_version.outputs.new_version }}"
git push

- name: Create Git tag
run: |
git tag -a "v${{ steps.calc_version.outputs.new_version }}" -m "Release v${{ steps.calc_version.outputs.new_version }}"
git push origin "v${{ steps.calc_version.outputs.new_version }}"

- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ steps.calc_version.outputs.new_version }}
name: Release v${{ steps.calc_version.outputs.new_version }}
body: |
## Release v${{ steps.calc_version.outputs.new_version }}

### Changes
This is a ${{ github.event.inputs.version_bump }} version release.

### Installation

#### AUR (Arch Linux)
```bash
yay -S hyproled-git
```

#### Manual Installation
```bash
sudo cp hyproled /usr/bin/hyproled
```
draft: false
prerelease: false
token: ${{ secrets.GITHUB_TOKEN }}

- name: Deploy to AUR
if: secrets.AUR_SSH_KEY
env:
AUR_SSH_KEY: ${{ secrets.AUR_SSH_KEY }}
run: |
# Install minimal makepkg wrapper for .SRCINFO generation
echo "Installing makepkg wrapper..."
sudo mkdir -p /usr/local/bin
cat << 'MAKEPKG_SCRIPT' | sudo tee /usr/local/bin/makepkg > /dev/null
#!/bin/bash
# Minimal makepkg --printsrcinfo implementation for CI
# Note: This sources PKGBUILD which is necessary but should only be used with trusted PKGBUILDs
if [[ "$1" == "--printsrcinfo" ]]; then
source PKGBUILD
echo "pkgbase = ${pkgbase:-$pkgname}"
echo " pkgdesc = $pkgdesc"
echo " pkgver = $pkgver"
echo " pkgrel = $pkgrel"
echo " url = $url"
[[ -n "$arch" ]] && for a in "${arch[@]}"; do echo " arch = $a"; done
[[ -n "$license" ]] && for l in "${license[@]}"; do echo " license = $l"; done
[[ -n "$depends" ]] && for dep in "${depends[@]}"; do echo " depends = $dep"; done
[[ -n "$makedepends" ]] && for dep in "${makedepends[@]}"; do echo " makedepends = $dep"; done
[[ -n "$source" ]] && for src in "${source[@]}"; do echo " source = $src"; done
echo ""
echo "pkgname = ${pkgname}"
fi
MAKEPKG_SCRIPT
sudo chmod +x /usr/local/bin/makepkg

# Setup SSH for AUR
mkdir -p ~/.ssh
printf '%s\n' "$AUR_SSH_KEY" > ~/.ssh/aur
chmod 600 ~/.ssh/aur

# Add AUR host key to known_hosts for security
ssh-keyscan -t ed25519 aur.archlinux.org >> ~/.ssh/known_hosts 2>/dev/null

# Configure SSH to use the key for AUR
cat >> ~/.ssh/config <<EOF
Host aur.archlinux.org
IdentityFile ~/.ssh/aur
User aur
EOF

# Clone AUR repository
if git clone ssh://aur@aur.archlinux.org/hyproled-git.git aur-repo; then
cd aur-repo

# Update pkgver in PKGBUILD (for -git packages, we update pkgrel)
# Get the latest commit hash
COMMIT_HASH=$(git -C .. rev-parse HEAD)

# Update PKGBUILD with new information
# Increment pkgrel
CURRENT_PKGREL=$(grep -oP 'pkgrel=\K[0-9]+' PKGBUILD || echo "0")
NEW_PKGREL=$((CURRENT_PKGREL + 1))
sed -i "s/pkgrel=[0-9]\+/pkgrel=${NEW_PKGREL}/" PKGBUILD

# Update .SRCINFO
makepkg --printsrcinfo > .SRCINFO

# Commit and push to AUR
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add PKGBUILD .SRCINFO
git commit -m "Update to version ${{ steps.calc_version.outputs.new_version }}" || echo "No changes to commit"
git push
else
echo "Warning: Could not clone AUR repository. Skipping AUR deployment."
exit 0
fi
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ function handle {
socat -U - UNIX-CONNECT:$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock | while read -r line; do handle "$line"; done
```

## Development & Deployment

For maintainers: This repository includes an automated deployment workflow for releasing new versions.

See [`.github/DEPLOYMENT.md`](.github/DEPLOYMENT.md) for detailed instructions on:
- Using the GitHub Actions workflow to create releases
- Deploying to AUR (Arch User Repository)
- Setting up required secrets and permissions

## Backlog

- Multiple areas
Expand Down