chore(package): initial package config and files #24
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 | |
| env: | |
| SWIFT_VERSION: "6.2" | |
| jobs: | |
| test: | |
| name: Build & Test (${{ matrix.os }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| platform: linux | |
| - os: macos-latest | |
| platform: macos | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| with: | |
| fetch-depth: 0 | |
| - name: Cache Swiftly | |
| id: cache-swiftly | |
| uses: actions/cache@8b402f58fbc84540c8b491a91e594a4576fec3d7 # v5.0.2 | |
| with: | |
| path: | | |
| ~/.swiftly | |
| ~/.local/share/swiftly | |
| ~/Library/Developer/Toolchains | |
| key: swiftly-${{ matrix.platform }}-swift-${{ env.SWIFT_VERSION }} | |
| restore-keys: | | |
| swiftly-${{ matrix.platform }}- | |
| # ------------------------------------------------- | |
| # Linux — Swiftly (official prebuilt binary) | |
| # ------------------------------------------------- | |
| - name: Install Swift (Linux via Swiftly) | |
| if: matrix.platform == 'linux' && steps.cache-swiftly.outputs.cache-hit != 'true' | |
| run: | | |
| set -euxo pipefail | |
| 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 | |
| - name: Configure Swiftly PATH (Linux) | |
| if: matrix.platform == 'linux' | |
| run: | | |
| echo "$HOME/.local/share/swiftly/bin" >> "$GITHUB_PATH" | |
| # ------------------------------------------------- | |
| # macOS — Swiftly (official pkg installer) | |
| # ------------------------------------------------- | |
| - name: Install Swift (macOS via Swiftly pkg) | |
| if: matrix.platform == 'macos' && steps.cache-swiftly.outputs.cache-hit != 'true' | |
| 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/swiftly init --quiet-shell-followup -o -y | |
| . "${SWIFTLY_HOME_DIR:-$HOME/.swiftly}/env.sh" | |
| hash -r | |
| cat ${SWIFTLY_HOME_DIR:-$HOME/.swiftly}/env.sh | |
| - name: Configure Swiftly PATH (macOS) | |
| if: matrix.platform == 'macos' | |
| run: | | |
| set -euxo pipefail | |
| export SWIFTLY_HOME_DIR=/Users/runner/.swiftly | |
| export SWIFTLY_BIN_DIR=/Users/runner/.swiftly/bin | |
| export SWIFTLY_TOOLCHAINS_DIR=/Users/runner/Library/Developer/Toolchains | |
| echo "$SWIFTLY_HOME_DIR" >> "$GITHUB_PATH" | |
| echo "$SWIFTLY_BIN_DIR" >> "$GITHUB_PATH" | |
| echo "$SWIFTLY_TOOLCHAINS_DIR" >> "$GITHUB_PATH" | |
| # ------------------------------------------------- | |
| # Select Swift toolchain (Swiftly) | |
| # ------------------------------------------------- | |
| - name: Select Swift toolchain | |
| run: | | |
| swiftly install $SWIFT_VERSION || true | |
| swiftly use $SWIFT_VERSION -g -y | |
| # ------------------------------------------------- | |
| # Core CI steps | |
| # ------------------------------------------------- | |
| - name: Verify Swift toolchain | |
| run: swift --version | |
| - name: Cache SwiftPM | |
| uses: actions/cache@8b402f58fbc84540c8b491a91e594a4576fec3d7 # v5.0.2 | |
| with: | |
| path: .build | |
| key: spm-${{ matrix.platform }}-${{ hashFiles('Package.swift') }} | |
| restore-keys: | | |
| spm-${{ matrix.platform }}- | |
| - 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/ |