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
91 changes: 59 additions & 32 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
on:
push:
branches:
- main
- release/*
paths:
- 'Cargo.toml'
- '.github/workflows/publish.yml'

name: Publish
jobs:
Expand Down Expand Up @@ -56,9 +57,9 @@ jobs:

# Optional variables (will use defaults if not set)
echo "📋 Checking optional variables..."
echo "CRATES_IO_INITIAL_WAIT: ${{ vars.CRATES_IO_INITIAL_WAIT || 'not set (will use default: 180)' }}"
echo "CRATES_IO_RETRY_WAIT: ${{ vars.CRATES_IO_RETRY_WAIT || 'not set (will use default: 60)' }}"
echo "PUBLISH_INITIAL_WAIT: ${{ vars.PUBLISH_INITIAL_WAIT || 'not set (will use default: 180)' }}"
echo "PUBLISH_RETRY_WAIT: ${{ vars.PUBLISH_RETRY_WAIT || 'not set (will use default: 60)' }}"

echo "✅ All required context tokens are present!"

audit:
Expand All @@ -85,11 +86,12 @@ jobs:
- name: 'Build'
run: cargo build --release --all-features

add_version_tag:
version:
name: Add Version Tag
needs:
- check_context_tokens
- build_linux
- audit

runs-on: ubuntu-latest
timeout-minutes: 10
Expand All @@ -99,28 +101,44 @@ jobs:
id: version
run: |
VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/' | sed 's/-.*//')
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "::set-output name=version::$VERSION"
echo "::set-output name=release::$RELEASE_SUFFIX"
echo "Version detected: $VERSION"
echo "Release suffix detected: $RELEASE_SUFFIX"
echo "Full version detected: $FULL_VERSION"

- name: Create Git Tag
run: |
git config --global user.name " github-actions[bot]"
# Check if tag already exists
if git rev-parse "v${{ steps.version.outputs.version }}" >/dev/null 2>&1; then
echo "Tag v${{ steps.version.outputs.version }} already exists, skipping tag creation"
exit 0
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"

TAG="v${{ steps.version.outputs.version }}"

# Fetch all tags from remote to ensure we have the latest
git fetch --tags --force

# Check if tag already exists (locally or remotely)
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "Tag $TAG already exists, moving it to the latest commit"
# Delete the tag locally
git tag -d "$TAG"
# Delete the tag remotely (force push to delete)
git push --force origin ":refs/tags/$TAG" || true
else
echo "Tag $TAG does not exist yet, creating new tag"
fi

git config --global user.email "github-actions[bot]@users.noreply.github.com"
git tag "v${{ steps.version.outputs.version }}"
git push origin "v${{ steps.version.outputs.version }}"
# Create and push the new tag
git tag "$TAG"
git push origin "$TAG"

crates_io_publish:
name: Publish (crates.io)
needs:
- check_context_tokens
- audit
- build_linux
- version

runs-on: ubuntu-latest
timeout-minutes: 10
Expand Down Expand Up @@ -149,7 +167,7 @@ jobs:
publish \
--workspace \
--all-features \
--allow-branch main \
--allow-branch ${{ github.ref_name }} \
--no-confirm \
--execute

Expand All @@ -158,6 +176,7 @@ jobs:
needs:
- audit
- build_linux
- version

runs-on: ubuntu-latest
timeout-minutes: 15
Expand All @@ -170,19 +189,27 @@ jobs:
FULL_VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')
VERSION=$(echo "$FULL_VERSION" | sed 's/-.*//')
RELEASE_SUFFIX=$(echo "$FULL_VERSION" | grep -oP '(?<=-).*$' || echo "1")
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "release=$RELEASE_SUFFIX" >> $GITHUB_OUTPUT
echo "::set-output name=version::$VERSION"
echo "::set-output name=release::$RELEASE_SUFFIX"
echo "Version detected: $VERSION"
echo "Release suffix detected: $RELEASE_SUFFIX"

- name: Get SHA256 checksum from repository
- name: Get SHA256 checksum from GitHub release
id: checksum
run: |
# Create a temporary tarball from the repository
git archive --format=tar.gz --prefix=hyprsession-${{ steps.version.outputs.version }}/ HEAD > hyprsession-${{ steps.version.outputs.version }}.tar.gz
SHA256=$(sha256sum hyprsession-${{ steps.version.outputs.version }}.tar.gz | cut -d' ' -f1)
echo "checksum=$SHA256" >> $GITHUB_OUTPUT
VERSION="${{ steps.version.outputs.version }}"
URL="https://github.com/joshurtree/hyprsession/archive/refs/tags/v${VERSION}.tar.gz"

echo "Downloading release tarball from: $URL"
curl -L -o "hyprsession-${VERSION}.tar.gz" "$URL"

SHA256=$(sha256sum "hyprsession-${VERSION}.tar.gz" | cut -d' ' -f1)
echo "::set-output name=checksum::$SHA256"
echo "SHA256: $SHA256"

# Verify the tarball can be extracted
tar -tzf "hyprsession-${VERSION}.tar.gz" >/dev/null
echo "✓ Tarball verified successfully"

- name: Generate PKGBUILD file
run: |-
Expand All @@ -197,27 +224,27 @@ jobs:
license=('GPL-3.0-or-later')
depends=()
makedepends=('rust' 'cargo')
source=("$pkgname-$pkgver.tar.gz::https://github.com/joshurtree/hyprsession/archive/refs/tags/v$pkgver.tar.gz")
source=("\$pkgname-\$pkgver.tar.gz::https://github.com/joshurtree/hyprsession/archive/refs/tags/v\$pkgver.tar.gz")
sha256sums=('${{ steps.checksum.outputs.checksum }}')

build() {
cd "$pkgname-$pkgver"
cd "\$pkgname-\$pkgver"
export RUSTUP_TOOLCHAIN=stable
export CARGO_TARGET_DIR=target
cargo build --frozen --release --all-features
cargo build --release --all-features
}

check() {
cd "$pkgname-$pkgver"
cd "\$pkgname-\$pkgver"
export RUSTUP_TOOLCHAIN=stable
cargo test --frozen --all-features
cargo test --release --all-features
}

package() {
cd "$pkgname-$pkgver"
install -Dm755 "target/release/$pkgname" "$pkgdir/usr/bin/$pkgname"
install -Dm644 "README.md" "$pkgdir/usr/share/doc/$pkgname/README.md"
install -Dm644 "LICENSE" "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
cd "\$pkgname-\$pkgver"
install -Dm755 "target/release/\$pkgname" "\$pkgdir/usr/bin/\$pkgname"
install -Dm644 "README.md" "\$pkgdir/usr/share/doc/\$pkgname/README.md"
install -Dm644 "LICENSE" "\$pkgdir/usr/share/licenses/\$pkgname/LICENSE"
}
EOF

Expand All @@ -230,4 +257,4 @@ jobs:
commit_email: ${{ secrets.AUR_EMAIL }}
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
commit_message: "Update to version ${{ steps.version.outputs.version }}"
ssh_keyscan_types: rsa,ecdsa,ed25519
ssh_keyscan_types: rsa,ecdsa,ed25519
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hyprsession"
version = "0.2.0-4"
version = "0.2.0-7"
edition = "2021"
authors = [ "Josh Andrews" ]
license = "GPL-3.0"
Expand All @@ -25,4 +25,4 @@ path = "src/main.rs"

[lib]
name = "hyprsession"
path = "src/lib.rs"
path = "src/lib.rs"
48 changes: 48 additions & 0 deletions tests/test-aur.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env bash

# Quick Arch Linux container for testing AUR packages
# Run with: nix-shell arch-container.nix --run ./test-aur.sh

set -e

echo "Starting Arch Linux container for AUR testing..."

# Run an Arch container with necessary tools
docker run -it --rm \
-v "$(pwd):/workspace:ro" \
archlinux:latest \
bash -c '
# Update system and install build tools
pacman -Syu --noconfirm
pacman -S --noconfirm base-devel git sudo

# Create a build user (AUR packages cannot be built as root)
useradd -m builder
echo "builder ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

# Switch to builder user
su - builder -c "
# Clone and build the AUR package
cd /tmp
git clone https://aur.archlinux.org/hyprsession.git
cd hyprsession

echo \"\"
echo \"=== PKGBUILD Contents ===\"
cat PKGBUILD
echo \"\"
echo \"=== Building package ===\"
makepkg -si --noconfirm

echo \"\"
echo \"=== Testing installation ===\"
hyprsession --version || echo \"Package installed but hyprsession command not found\"

echo \"\"
echo \"=== Package info ===\"
pacman -Qi hyprsession
"
'

echo ""
echo "AUR package test complete!"
Loading