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
61 changes: 61 additions & 0 deletions .github/workflows/homebrew-releaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Homebrew Release

on:
release:
types: [published]

jobs:
homebrew:
runs-on: ubuntu-latest
steps:
- name: Checkout cardpool
uses: actions/checkout@v6
with:
path: cardpool

- name: Checkout tap
uses: actions/checkout@v6
with:
repository: piers-sinclair/homebrew-cpool
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
path: tap

- name: Sync formula and update hashes
env:
VERSION: ${{ github.ref_name }}
run: |
set -euo pipefail
VERSION="${VERSION#v}"
BASE="https://github.com/piers-sinclair/cardpool/releases/download/v${VERSION}"

get_sha256() { curl -fsSL "$1" | sha256sum | awk '{print $1}'; }

SHA_OSX_ARM64=$(get_sha256 "${BASE}/cpool-osx-arm64.zip")
SHA_OSX_X64=$( get_sha256 "${BASE}/cpool-osx-x64.zip")
SHA_LINUX_X64=$(get_sha256 "${BASE}/cpool-linux-x64.zip")

cp cardpool/packaging/homebrew/cpool.rb tap/Formula/cpool.rb

sed -i "s/version \"[0-9.]*\"/version \"${VERSION}\"/" tap/Formula/cpool.rb

awk \
-v osx_arm64="${SHA_OSX_ARM64}" \
-v osx_x64="${SHA_OSX_X64}" \
-v linux_x64="${SHA_LINUX_X64}" '
/cpool-osx-arm64\.zip/ { print; getline; sub(/sha256 "[0-9a-f]+"/, "sha256 \"" osx_arm64 "\""); print; next }
/cpool-osx-x64\.zip/ { print; getline; sub(/sha256 "[0-9a-f]+"/, "sha256 \"" osx_x64 "\""); print; next }
/cpool-linux-x64\.zip/ { print; getline; sub(/sha256 "[0-9a-f]+"/, "sha256 \"" linux_x64 "\""); print; next }
{ print }
' tap/Formula/cpool.rb > tap/Formula/cpool.rb.tmp
mv tap/Formula/cpool.rb.tmp tap/Formula/cpool.rb

- name: Commit and push
env:
VERSION: ${{ github.ref_name }}
working-directory: tap
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Formula/cpool.rb
git commit -m "cpool ${VERSION}"
git push
31 changes: 0 additions & 31 deletions .github/workflows/publish.yml

This file was deleted.

81 changes: 81 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Release

on:
push:
branches:
- main
paths:
- 'src/CardPool.Cli/CardPool.Cli.csproj'
workflow_dispatch:

permissions:
contents: write

jobs:
check:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.ver.outputs.version }}
tag: ${{ steps.ver.outputs.tag }}
should-release: ${{ steps.ver.outputs.should-release }}
steps:
- name: Checkout
uses: actions/checkout@v6

- name: Check version
id: ver
env:
GH_TOKEN: ${{ github.token }}
run: |
VERSION=$(grep -oP '(?<=<Version>)[^<]+' src/CardPool.Cli/CardPool.Cli.csproj)
TAG="v${VERSION}"
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "tag=${TAG}" >> $GITHUB_OUTPUT
if gh release view "${TAG}" &>/dev/null; then
echo "should-release=false" >> $GITHUB_OUTPUT
else
echo "should-release=true" >> $GITHUB_OUTPUT
fi

release:
needs: check
if: needs.check.outputs.should-release == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6

- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: '10.x'

- name: Restore dependencies
run: dotnet restore

- name: Publish all platforms
run: |
for rid in win-x64 win-arm64 osx-arm64 osx-x64 linux-x64; do
dotnet publish src/CardPool.Cli -p:PublishProfile=$rid -o dist/$rid --no-restore
done

- name: Create archives
run: |
zip -j cpool-win-x64.zip dist/win-x64/cpool.exe
zip -j cpool-win-arm64.zip dist/win-arm64/cpool.exe
zip -j cpool-osx-arm64.zip dist/osx-arm64/cpool
zip -j cpool-osx-x64.zip dist/osx-x64/cpool
zip -j cpool-linux-x64.zip dist/linux-x64/cpool

- name: Pack NuGet
run: dotnet pack src/CardPool.Cli --configuration Release --no-restore --output ./nupkg

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.check.outputs.tag }}
files: cpool-*.zip
generate_release_notes: true

- name: Push to NuGet
run: dotnet nuget push ./nupkg/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
65 changes: 65 additions & 0 deletions .github/workflows/smoke-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Package Manager Smoke Test

on:
workflow_run:
workflows: ["Homebrew Release"]
types: [completed]
workflow_dispatch:
inputs:
test_winget:
description: 'Test winget install (run after winget-pkgs PR is merged)'
type: boolean
default: false

jobs:
homebrew-macos:
if: >
(github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') ||
github.event_name == 'workflow_dispatch'
runs-on: macos-latest
steps:
- name: Install from tap
run: |
brew tap piers-sinclair/cpool
brew install cpool

- name: Verify version
run: |
VERSION=$(cpool --version)
echo "Installed version: $VERSION"
[[ -n "$VERSION" ]] || { echo "cpool --version returned empty output"; exit 1; }

homebrew-linux:
if: >
(github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') ||
github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- name: Install Homebrew
run: |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo "/home/linuxbrew/.linuxbrew/bin" >> "$GITHUB_PATH"

- name: Install from tap
run: |
brew tap piers-sinclair/cpool
brew install cpool

- name: Verify version
run: |
VERSION=$(cpool --version)
echo "Installed version: $VERSION"
[[ -n "$VERSION" ]] || { echo "cpool --version returned empty output"; exit 1; }

winget:
if: github.event_name == 'workflow_dispatch' && inputs.test_winget
runs-on: windows-latest
steps:
- name: Install via winget
run: winget install PiersSinclair.CardPool --accept-source-agreements --accept-package-agreements

- name: Verify version
run: |
$version = cpool --version
Write-Output "Installed version: $version"
if (-not $version) { Write-Error "cpool --version returned empty output"; exit 1 }
50 changes: 50 additions & 0 deletions .github/workflows/validate-packaging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Validate Packaging

on:
push:
branches:
- main
paths:
- 'packaging/**'
- '.github/workflows/validate-packaging.yml'
pull_request:
paths:
- 'packaging/**'
- '.github/workflows/validate-packaging.yml'
workflow_dispatch:

jobs:
winget:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v6

- name: Resolve manifest version
id: ver
shell: pwsh
run: |
$version = (Select-String -Path src/CardPool.Cli/CardPool.Cli.csproj -Pattern '<Version>(.*?)</Version>').Matches[0].Groups[1].Value
"version=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Append

- name: Validate winget manifest
shell: pwsh
run: winget validate --manifest packaging/winget/manifests/p/PiersSinclair/CardPool/${{ steps.ver.outputs.version }}

homebrew:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v6

- name: Create temporary tap
run: |
mkdir -p /tmp/homebrew-cpool/Formula
cp packaging/homebrew/cpool.rb /tmp/homebrew-cpool/Formula/cpool.rb
git -C /tmp/homebrew-cpool init
git -C /tmp/homebrew-cpool -c user.email="ci@ci" -c user.name="CI" add Formula
git -C /tmp/homebrew-cpool -c user.email="ci@ci" -c user.name="CI" commit -m "init"
brew tap local/cpool /tmp/homebrew-cpool

- name: Check formula style
run: brew style local/cpool/cpool
15 changes: 15 additions & 0 deletions .github/workflows/winget-releaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Winget Release

on:
release:
types: [published]

jobs:
winget:
runs-on: windows-latest
steps:
- uses: vedantmgoyal9/winget-releaser@v2
with:
identifier: PiersSinclair.CardPool
installers-regex: 'cpool-win-(x64|arm64)\.zip$'
token: ${{ secrets.WINGET_TOKEN }}
Loading
Loading