From 5e4d4c10b8f4c272c93720455b0c162ba133c07b Mon Sep 17 00:00:00 2001 From: Anton Pauli <1565397+TUNER88@users.noreply.github.com> Date: Sun, 18 Oct 2026 21:45:54 +0200 Subject: [PATCH] feat: publish SystemSoundsLibrary as a versioned Swift package Add release-please automation (release-type simple). It opens a release PR from Conventional Commits and creates SemVer tags and GitHub Releases. README and DocC install snippets now use from: "2.0.0". Release-As: 2.0.0 --- .github/RELEASING.md | 24 ++++++++++ .github/workflows/release-please.yml | 44 +++++++++++++++++++ .release-please-manifest.json | 1 + README.md | 20 +++++++++ .../GettingStarted.md | 2 +- release-please-config.json | 13 ++++++ 6 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 .github/RELEASING.md create mode 100644 .github/workflows/release-please.yml create mode 100644 .release-please-manifest.json create mode 100644 release-please-config.json diff --git a/.github/RELEASING.md b/.github/RELEASING.md new file mode 100644 index 0000000..04bb2d3 --- /dev/null +++ b/.github/RELEASING.md @@ -0,0 +1,24 @@ +# Releasing + +Releases are automated with [release-please](https://github.com/googleapis/release-please). + +1. Use [Conventional Commits](https://www.conventionalcommits.org/) for commit messages or squash-merge PR titles: + - `fix: …` creates a patch release (2.0.1) + - `feat: …` creates a minor release (2.1.0) + - `feat!: …`, or a `BREAKING CHANGE:` footer, creates a major release (3.0.0) + - `docs:`, `ci:`, `chore:`, `test:` and `refactor:` don't create a release +2. After each push to `master`, the **Release** workflow opens or updates a PR titled `chore(master): release X.Y.Z`. It updates `CHANGELOG.md` and `version.txt`. +3. Merging that PR creates the tag `X.Y.Z` (no `v` prefix, as Swift Package Manager expects) and a GitHub Release. + +The first release is **2.0.0**. It's set by `initial-version` in `release-please-config.json` and by the `Release-As: 2.0.0` footer of the commit that added this automation. + +To force a specific version, add a `Release-As: X.Y.Z` footer to a commit message. + +## Required CI on release PRs + +`master` requires status checks. GitHub doesn't run workflows for PRs that are created or updated with the default `GITHUB_TOKEN`. To have CI run automatically on release PRs, add a repository secret named `RELEASE_PLEASE_TOKEN`. It can be either: + +- A fine-grained personal access token for this repository with **Contents: Read and write** and **Pull requests: Read and write** (add **Issues: Read and write** for labels). +- A GitHub App installation token with the same permissions. + +Without the secret, the workflow falls back to `GITHUB_TOKEN`. The release PR is still created, but you have to start CI by hand: close and reopen the release PR. diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 0000000..a8911bb --- /dev/null +++ b/.github/workflows/release-please.yml @@ -0,0 +1,44 @@ +name: Release + +# Opens and updates a release PR from Conventional Commits merged into master. +# Merging that PR creates the SemVer tag (for example 2.0.0) and the GitHub Release. +# See .github/RELEASING.md. + +on: + push: + branches: [master] + workflow_dispatch: + +permissions: + contents: write + pull-requests: write + issues: write + +concurrency: + group: release-please + cancel-in-progress: false + +jobs: + release-please: + name: release-please + runs-on: ubuntu-latest + steps: + - uses: googleapis/release-please-action@45996ed1f6d02564a971a2fa1b5860e934307cf7 # v5.0.0 + id: release + with: + # A PAT or GitHub App token is needed so the release PR triggers the required CI checks. + # Without it, the GITHUB_TOKEN fallback still works, but CI must be started by hand. + token: ${{ secrets.RELEASE_PLEASE_TOKEN || secrets.GITHUB_TOKEN }} + config-file: release-please-config.json + manifest-file: .release-please-manifest.json + + - name: Warn if the release PR won't trigger CI + if: steps.release.outputs.prs_created == 'true' && env.HAS_TOKEN != 'true' + env: + HAS_TOKEN: ${{ secrets.RELEASE_PLEASE_TOKEN != '' }} + run: | + echo "::warning::The release PR was created with GITHUB_TOKEN, so CI doesn't run on it. Add a RELEASE_PLEASE_TOKEN secret, or close and reopen the release PR to start CI. See .github/RELEASING.md." + + - name: Summary + if: steps.release.outputs.release_created == 'true' + run: echo "Released ${{ steps.release.outputs.tag_name }}" >> "$GITHUB_STEP_SUMMARY" diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1 @@ +{} diff --git a/README.md b/README.md index 5786fe5..956d74a 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ A reference list of the system sounds built into iOS, plus a small demo app that ## Contents - [Usage](#usage) + - [Swift Package Manager](#swift-package-manager) - [Swift](#swift) - [SwiftUI](#swiftui) - [Objective-C](#objective-c) @@ -30,6 +31,25 @@ A reference list of the system sounds built into iOS, plus a small demo app that All examples use the `AudioToolbox` framework (System Sound Services). It is linked automatically when you import it in a modern Xcode project. +### Swift Package Manager + +The `SystemSoundsLibrary` package wraps these sounds in a typed Swift 6 API with availability information (iOS 15+, tvOS, visionOS, Mac Catalyst). Add it in Xcode with **File > Add Package Dependencies…**, or in `Package.swift`: + +```swift +dependencies: [ + .package(url: "https://github.com/TUNER88/iOSSystemSoundsLibrary", from: "2.0.0"), +], +``` + +```swift +import SystemSoundsLibrary + +SystemSoundPlayer.play(.smsReceived) // 1003 +await SystemSoundPlayer.playAndWait(.mailReceived) +``` + +See [`Examples/SoundBrowser`](Examples/SoundBrowser) for a SwiftUI app that browses and plays every sound. + ### Swift Play a sound by its SystemSoundID: diff --git a/Sources/SystemSoundsLibrary/SystemSoundsLibrary.docc/GettingStarted.md b/Sources/SystemSoundsLibrary/SystemSoundsLibrary.docc/GettingStarted.md index 62941cc..46e8983 100644 --- a/Sources/SystemSoundsLibrary/SystemSoundsLibrary.docc/GettingStarted.md +++ b/Sources/SystemSoundsLibrary/SystemSoundsLibrary.docc/GettingStarted.md @@ -9,7 +9,7 @@ In Xcode, choose **File > Add Package Dependencies…** and enter ```swift dependencies: [ - .package(url: "https://github.com/TUNER88/iOSSystemSoundsLibrary", branch: "master"), + .package(url: "https://github.com/TUNER88/iOSSystemSoundsLibrary", from: "2.0.0"), ], targets: [ .target(name: "MyApp", dependencies: [ diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 0000000..28f8ac4 --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,13 @@ +{ + "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", + "release-type": "simple", + "include-v-in-tag": false, + "include-component-in-tag": false, + "packages": { + ".": { + "package-name": "SystemSoundsLibrary", + "initial-version": "2.0.0", + "changelog-path": "CHANGELOG.md" + } + } +}