Merge pull request #125 from OWASP/dependabot/github_actions/actions/… #293
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: "Compile Swift" | |
| on: | |
| workflow_dispatch: | |
| push: | |
| paths: | |
| - 'swift/**' | |
| - ".github/**" | |
| pull_request: | |
| permissions: | |
| contents: read | |
| jobs: | |
| build-non-musl: | |
| name: Swift ${{ matrix.swift }} on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| swift: ["6.2.0"] | |
| steps: | |
| - uses: SwiftyLab/setup-swift@v1.12.0 | |
| with: | |
| swift-version: ${{ matrix.swift }} | |
| visual-studio-components: Microsoft.VisualStudio.Component.Windows11SDK.26100 | |
| - uses: actions/checkout@v6 | |
| - name: Get swift version | |
| run: swift --version | |
| - name: Build a Swift package on windows/linux | |
| run: | | |
| cd swift && swift build -v -c release --static-swift-stdlib | |
| - name: Build CTF Swift package on windows/linux | |
| if: matrix.os != 'windows-latest' | |
| run: | | |
| echo "Generating CTF secrets..." | |
| ./generate_ctf_secrets.sh generate | |
| cd swift && swift build -v -c release --static-swift-stdlib | |
| cp .build/release/swift ../wrongsecrets-swift-ctf | |
| cd .. | |
| # Restore original files | |
| ./generate_ctf_secrets.sh restore | |
| - name: Build CTF Swift package on Windows (skip CTF for now) | |
| if: matrix.os == 'windows-latest' | |
| run: | | |
| echo "CTF generation not supported on Windows yet" | |
| cd swift && swift build -v -c release --static-swift-stdlib | |
| cp .build/release/swift.exe ../wrongsecrets-swift-ctf.exe | |
| - name: Build a Swift package on Macos | |
| if: matrix.os == 'macos-latest' | |
| run: | | |
| cd swift | |
| swift build -c release --triple x86_64-apple-macosx --static-swift-stdlib | |
| swift build -c release --triple arm64-apple-macosx --static-swift-stdlib | |
| lipo .build/arm64-apple-macosx/release/swift .build/x86_64-apple-macosx/release/swift -create -output wrongsecrets-swift.universal | |
| - name: Build CTF Swift package on Macos | |
| if: matrix.os == 'macos-latest' | |
| run: | | |
| echo "Generating CTF secrets..." | |
| ./generate_ctf_secrets.sh generate | |
| cd swift | |
| swift build -c release --triple x86_64-apple-macosx --static-swift-stdlib | |
| swift build -c release --triple arm64-apple-macosx --static-swift-stdlib | |
| lipo .build/arm64-apple-macosx/release/swift .build/x86_64-apple-macosx/release/swift -create -output wrongsecrets-swift-ctf.universal | |
| cd .. | |
| # Restore original files | |
| ./generate_ctf_secrets.sh restore | |
| - name: Uploading macos Swift executables | |
| uses: actions/upload-artifact@v7 | |
| if: matrix.os == 'macos-latest' | |
| with: | |
| name: wrongsecrets-swift | |
| path: | | |
| swift/wrongsecrets-swift.universal | |
| swift/wrongsecrets-swift-ctf.universal | |
| - name: Uploading linux Swift executable (no arm yet, run this all locally please) | |
| uses: actions/upload-artifact@v7 | |
| if: matrix.os == 'ubuntu-latest' | |
| with: | |
| name: wrongsecrets-swift-linux | |
| path: | | |
| swift/.build/x86_64-unknown-linux-gnu/release/swift | |
| wrongsecrets-swift-ctf | |
| - name: Uploading Windows Swift executable (no arm yet, run this all locally please) | |
| uses: actions/upload-artifact@v7 | |
| if: matrix.os == 'windows-latest' | |
| with: | |
| name: wrongsecrets-swift-windows | |
| path: | | |
| swift\.build\x86_64-unknown-windows-msvc\release\swift.exe | |
| wrongsecrets-swift-ctf.exe | |
| build-musl: | |
| name: Swift with Musl | |
| runs-on: macos-latest | |
| steps: | |
| - uses: SwiftyLab/setup-swift@v1.12.0 | |
| with: | |
| swift-version: "6.0.3" | |
| prefer-oss-toolchain: true | |
| - uses: actions/checkout@v6 | |
| - name: Get swift version | |
| run: swift --version | |
| - name: Install Swift Musl SDK | |
| run: | | |
| swift sdk install https://download.swift.org/swift-6.0.3-release/static-sdk/swift-6.0.3-RELEASE/swift-6.0.3-RELEASE_static-linux-0.0.1.artifactbundle.tar.gz --checksum 67f765e0030e661a7450f7e4877cfe008db4f57f177d5a08a6e26fd661cdd0bd | |
| - name: Build and test a Swift package | |
| run: | | |
| cd swift | |
| # echo "ls /Library/Developer/Toolchains/swift-6.0.3-RELEASE.xctoolchain/usr/bin does not work: we need to install the sdk toolcahin?" | |
| swift build -c release --swift-sdk x86_64-swift-linux-musl --static-swift-stdlib | |
| swift build -c release --swift-sdk aarch64-swift-linux-musl --static-swift-stdlib | |
| - name: Build CTF Swift package | |
| run: | | |
| echo "Generating CTF secrets..." | |
| ./generate_ctf_secrets.sh generate | |
| cd swift | |
| swift build -c release --swift-sdk x86_64-swift-linux-musl --static-swift-stdlib | |
| swift build -c release --swift-sdk aarch64-swift-linux-musl --static-swift-stdlib | |
| cp .build/x86_64-swift-linux-musl/release/swift ../wrongsecrets-swift-linux-musl-ctf | |
| cp .build/aarch64-swift-linux-musl/release/swift ../wrongsecrets-swift-linux-musl-arm-ctf | |
| cd .. | |
| # Restore original files | |
| ./generate_ctf_secrets.sh restore | |
| - name: Uploading linux arm musl Swift executable | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: wrongsecrets-swift-linux-musl-arm | |
| path: | | |
| swift/.build/aarch64-swift-linux-musl/release/swift | |
| wrongsecrets-swift-linux-musl-arm-ctf | |
| - name: Uploading linux x86 musl Swift executable | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: wrongsecrets-swift-linux-musl | |
| path: | | |
| swift/.build/x86_64-swift-linux-musl/release/swift | |
| wrongsecrets-swift-linux-musl-ctf | |