chore(package): initial package config and files #12
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: CI — digipin-swift | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - "Sources/**" | |
| - "Tests/**" | |
| - "Package.swift" | |
| - ".github/workflows/ci.yml" | |
| pull_request: | |
| branches: [main] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| test: | |
| name: Build & Test (${{ matrix.os }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: | |
| - ubuntu-latest | |
| - macos-latest | |
| - windows-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| with: | |
| fetch-depth: 0 | |
| - name: Cache Swiftly | |
| uses: actions/cache@8b402f58fbc84540c8b491a91e594a4576fec3d7 # v5.0.2 | |
| with: | |
| path: | | |
| ~/.swiftly | |
| ~/.local/share/swiftly | |
| ${{ env.LOCALAPPDATA }}\swiftly | |
| key: swiftly-${{ runner.os }}-swift-6.2 | |
| # ------------------------------------------------- | |
| # Linux — Swiftly (official prebuilt binary) | |
| # ------------------------------------------------- | |
| - name: Install Swift (Linux via Swiftly) | |
| if: runner.os == 'Linux' | |
| run: | | |
| curl --proto '=https' -fsSL \ | |
| https://download.swift.org/swiftly/linux/swiftly-$(uname -m).tar.gz \ | |
| -o swiftly.tar.gz | |
| tar zxf swiftly.tar.gz | |
| ./swiftly init --quiet-shell-followup -o -y | |
| . "${SWIFTLY_HOME_DIR:-$HOME/.local/share/swiftly}/env.sh" | |
| hash -r | |
| echo "$HOME/.local/bin" >> $GITHUB_PATH | |
| swiftly install 6.2 | |
| swiftly use 6.2 | |
| # ------------------------------------------------- | |
| # macOS — Swiftly (official pkg installer) | |
| # ------------------------------------------------- | |
| - name: Install Swift (macOS via Swiftly pkg) | |
| if: runner.os == 'macOS' | |
| run: | | |
| set -euxo pipefail | |
| curl --proto '=https' -fsSL https://download.swift.org/swiftly/darwin/swiftly.pkg -o swiftly.pkg | |
| installer -pkg swiftly.pkg -target CurrentUserHomeDirectory | |
| SWIFTLY_BIN="$(command -v swiftly)" | |
| echo "Swiftly found at: $SWIFTLY_BIN" | |
| swiftly init --quiet-shell-followup -o -y | |
| . "${SWIFTLY_HOME_DIR:-$HOME/.swiftly}/env.sh" | |
| hash -r | |
| swiftly --version | |
| swiftly install 6.2 | |
| swiftly use 6.2 --global-default --yes | |
| echo "$HOME/.swiftly/bin" >> $GITHUB_PATH | |
| # ------------------------------------------------- | |
| # Windows — Swift + MSVC via WinGet (official) | |
| # ------------------------------------------------- | |
| - name: Install Swift (Windows via winget) | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| winget install --id Microsoft.VisualStudio.2022.Community ` | |
| --exact --force ` | |
| --custom "--add Microsoft.VisualStudio.Component.Windows11SDK.22621 ` | |
| --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 ` | |
| --add Microsoft.VisualStudio.Component.VC.Tools.ARM64" | |
| winget install --id Swift.Toolchain -e ` | |
| --accept-source-agreements ` | |
| --accept-package-agreements | |
| - name: Locate swift.exe (Windows) | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| Get-ChildItem "$env:LOCALAPPDATA\Microsoft\WindowsApps" -Filter swift* | |
| - name: Add Swift to PATH (Windows) | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| echo "$env:LOCALAPPDATA\Microsoft\WindowsApps" Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append | |
| # ------------------------------------------------- | |
| # Core CI steps | |
| # ------------------------------------------------- | |
| - name: Verify Swift toolchain | |
| run: swift --version | |
| - name: Cache SwiftPM | |
| uses: actions/cache@v4 | |
| with: | |
| path: .build | |
| key: spm-${{ runner.os }}-${{ hashFiles('Package.swift') }} | |
| restore-keys: | | |
| spm-${{ runner.os }}- | |
| - name: Build (debug) | |
| run: swift build --configuration debug | |
| - name: Test | |
| run: swift test --enable-test-discovery | |
| - name: Upload build artifacts (on failure) | |
| if: failure() | |
| uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # 6.0.0 | |
| with: | |
| name: swift-build-${{ matrix.os }} | |
| path: | | |
| .build/ |