Feature/swift testing #34
This file contains 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
# This workflow will build a Swift project | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-swift | |
name: Swift | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build: | |
runs-on: macos-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
repository: getargv/getargv | |
path: getargv | |
token: ${{ secrets.GH_PAT }} | |
- name: Build libgetargv | |
run: make dylib | |
working-directory: getargv | |
- name: Install libgetargv | |
run: sudo make install_dylib | |
working-directory: getargv | |
- uses: actions/checkout@v4 | |
with: | |
path: getargv-swift | |
fetch-tags: true | |
fetch-depth: 0 # until https://github.com/actions/checkout/issues/1471 fixed | |
- uses: swift-actions/setup-swift@v2 | |
with: | |
swift-version: '6.0' | |
# https://www.swift.org/download/ | |
- name: Build | |
run: swift build -v | |
working-directory: getargv-swift | |
- name: Run tests | |
run: swift test -v | |
working-directory: getargv-swift | |
- name: Build docs | |
run: | | |
swift package generate-documentation | |
tar -cf .build/plugins/Swift-DocC/outputs/SwiftGetargv.doccarchive.tar .build/plugins/Swift-DocC/outputs/SwiftGetargv.doccarchive | |
gzip -9 .build/plugins/Swift-DocC/outputs/SwiftGetargv.doccarchive.tar | |
working-directory: getargv-swift | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: docs | |
path: getargv-swift/.build/plugins/Swift-DocC/outputs/SwiftGetargv.doccarchive.tar.gz | |
if-no-files-found: error | |
- name: Bump Version | |
id: bump_version | |
run: git tag | sort -V | tail -1 | awk -F. 'BEGIN { OFS = "." } {$NF+=1; print $0}' | xargs -I {} echo "new_version={}" >> $GITHUB_OUTPUT | |
working-directory: getargv-swift | |
- name: create && push tag | |
run: | | |
git tag '${{ steps.bump_version.outputs.new_version }}' | |
git push origin tag '${{ steps.bump_version.outputs.new_version }}' | |
git push origin HEAD:main | |
working-directory: getargv-swift | |
- uses: softprops/action-gh-release@v2 | |
with: | |
files: getargv-swift/.build/plugins/Swift-DocC/outputs/SwiftGetargv.doccarchive.tar.gz | |
name: ${{ steps.bump_version.outputs.new_version }} | |
tag_name: ${{ steps.bump_version.outputs.new_version }} |