Skip to content

Commit

Permalink
Add support for Swift 5.9, drop support for previous versions of Swift
Browse files Browse the repository at this point in the history
  • Loading branch information
ffried committed Oct 2, 2023
1 parent 16279a1 commit 52de0cf
Show file tree
Hide file tree
Showing 25 changed files with 202 additions and 530 deletions.
5 changes: 2 additions & 3 deletions CODEOWNERS → .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
* @ffried

# Workflow & Deployment related files
.github/* @ffried
.jazzy.yaml @ffried
.codecov.yml @ffried
.github/* @ffried
.codecov.yml @ffried

# Project & Source files
*.swift @ffried
Expand Down
21 changes: 16 additions & 5 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
version: 2

updates:
- package-ecosystem: "github-actions"
directory: "/"
- package-ecosystem: github-actions
directory: /
open-pull-requests-limit: 10
schedule:
interval: "daily"
time: "08:00"
timezone: "Europe/Berlin"
interval: daily
time: 08:00
timezone: Europe/Berlin
assignees:
- ffried
reviewers:
- ffried
- package-ecosystem: swift
directory: /
open-pull-requests-limit: 10
schedule:
interval: daily
time: 08:00
timezone: Europe/Berlin
assignees:
- ffried
reviewers:
Expand Down
238 changes: 14 additions & 224 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,229 +8,19 @@ on:
push:
branches: [ main ]

jobs:
release-context:
runs-on: ubuntu-latest
outputs:
version-name: ${{ github.ref_name }}
is-latest: ${{ steps.compare-tags.outputs.is-latest }}
steps:
- uses: joutvhu/get-release@v1
id: latest-release
with:
latest: true
throwing: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Compare tags
id: compare-tags
env:
REF_TYPE: ${{ github.ref_type }}
REF_NAME: ${{ github.ref_name }}
LATEST_TAG: ${{ steps.latest-release.outputs.tag_name }}
run: |
if [ "${REF_TYPE}" == 'tag' ] && [ "${REF_NAME}" == "${LATEST_TAG}" ]; then
echo 'is-latest=true' >> "${GITHUB_OUTPUT}"
else
echo 'is-latest=false' >> "${GITHUB_OUTPUT}"
fi
spm-context:
runs-on: ubuntu-latest
outputs:
package-dump: ${{ steps.dump-package.outputs.package-dump }}
steps:
- uses: swift-actions/[email protected]
with:
swift-version: '5.7'
- uses: actions/checkout@v4
# We don't use a cache here, because SPM doesn't resolve dependencies when dumping packages.
- name: Dump package
id: dump-package
run: |
delimiter="$(openssl rand -hex 8)"
echo "package-dump<<${delimiter}" >> "${GITHUB_OUTPUT}"
swift package dump-package >> "${GITHUB_OUTPUT}"
echo "${delimiter}" >> "${GITHUB_OUTPUT}"
permissions:
contents: write

generate-docs:
needs:
- release-context
- spm-context
runs-on: ubuntu-latest
strategy:
matrix:
target: ${{ fromJson(needs.spm-context.outputs.package-dump).products.*.targets.* }}
steps:
- uses: swift-actions/[email protected]
id: swift-setup
with:
swift-version: '5.7'
- name: Read OS Version
uses: sersoft-gmbh/os-version-action@v3
id: os-version
- uses: actions/checkout@v4
- uses: actions/cache@v3
with:
path: .build
key: ${{ runner.os }}-${{ steps.os-version.outputs.version }}-spm-${{ steps.swift-setup.outputs.version }}-${{ hashFiles('**/Package.resolved') }}
restore-keys: |
${{ runner.os }}-${{ steps.os-version.outputs.version }}-spm-${{ steps.swift-setup.outputs.version }}-
- uses: sersoft-gmbh/swifty-docs-action@v3
env:
ENABLE_DOCC_SUPPORT: '1'
DOCC_JSON_PRETTYPRINT: 'YES'
with:
package-version: ${{ needs.release-context.outputs.version-name }}
targets: ${{ matrix.target }}
enable-inherited-docs: true
enable-index-building: false
transform-for-static-hosting: true
hosting-base-path: ${{ github.event.repository.name }}/${{ needs.release-context.outputs.version-name }}
output: ${{ matrix.target }}-docs
- name: Package docs
env:
TARGET: ${{ matrix.target }}
run: tar -cvf "${TARGET}-docs.tar" "${TARGET}-docs"
- uses: actions/upload-artifact@v3
with:
name: ${{ matrix.target }}-docs
path: ${{ matrix.target }}-docs.tar
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

publish-docs:
needs:
- release-context
- spm-context
- generate-docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: gh-pages
path: repository
- uses: actions/download-artifact@v3
with:
path: artifacts
- name: Extract tars
run: find artifacts -name '*.tar' -execdir tar -xvf '{}' --strip-components 1 \; -delete
- name: Merge documentations
env:
TARGETS: ${{ join(fromJson(needs.spm-context.outputs.package-dump).products.*.targets.*, ' ') }}
DOCS_BASE_DIR: repository/${{ needs.release-context.outputs.version-name }}
run: |
rm -rf "${DOCS_BASE_DIR}"
is_first=1
for target in $TARGETS; do
if [ $is_first -eq 1 ]; then
echo "Copying initial documentation for ${target}"
cp -R "artifacts/${target}-docs" "${DOCS_BASE_DIR}"
is_first=0
else
echo "Merging documentation for ${target}"
cp -R "artifacts/${target}-docs/data/documentation/"* "${DOCS_BASE_DIR}/data/documentation/"
cp -R "artifacts/${target}-docs/documentation/"* "${DOCS_BASE_DIR}/documentation/"
fi
done
echo "Deleting non-mergable metadata.json"
rm -f "${DOCS_BASE_DIR}/metadata.json"
- name: Create version index
working-directory: repository
env:
TARGET_DOCS_DIR: ${{ needs.release-context.outputs.version-name }}/documentation
INDEX_FILE: ${{ needs.release-context.outputs.version-name }}/index.html
BASE_URL: 'https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/${{ needs.release-context.outputs.version-name }}/documentation'
REPO_NAME: ${{ github.event.repository.name }}
run: |
target_count=0
target_list=""
single_target_name=""
for target in $(ls "${TARGET_DOCS_DIR}"); do
if [ -d "${TARGET_DOCS_DIR}/${target}" ]; then
single_target_name="${target}"
target_count=$((target_count+1))
target_list="${target_list}<li><a href=\"${BASE_URL}/${target}\"><code>${target}</code> Documentation</a></li>"
fi
done
if [ ${target_count} -gt 1 ]; then
echo "Found ${target_count} targets. Generating list..."
cat > "${INDEX_FILE}" <<EOF
<!DOCTYPE html>
<html>
<head>
<title>${REPO_NAME} Documentation</title>
</head>
<body>
<ul>
${target_list}
</ul>
</body>
</html>
EOF
else
echo "Found one target. Generating redirect file to target ${single_target_name}"
cat > "${INDEX_FILE}" <<EOF
<!DOCTYPE html>
<html>
<head>
<title>${REPO_NAME} Documentation</title>
<meta http-equiv="refresh" content="0; url=${BASE_URL}/${single_target_name}" />
</head>
<body>
<p>Redirecting...</p>
</body>
</html>
EOF
fi
- name: Create root index
working-directory: repository
env:
REDIRECT_URL: 'https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/latest'
REPO_NAME: ${{ github.event.repository.name }}
run: |
cat > 'index.html' <<EOF
<!DOCTYPE html>
<html>
<head>
<title>${REPO_NAME} Documentation</title>
<meta http-equiv="refresh" content="0; url=${REDIRECT_URL}" />
</head>
<body>
<p>Redirecting...</p>
</body>
</html>
EOF
- name: Create latest symlink
if: ${{ needs.release-context.outputs.is-latest }}
working-directory: repository
env:
VERSION_NAME: ${{ needs.release-context.outputs.version-name }}
run: |
rm -f 'latest'
ln -s "${VERSION_NAME}" 'latest'
- name: Determine changes
id: check-changes
working-directory: repository
run: |
if [ -n "$(git status --porcelain)" ]; then
echo 'has-changes=true' >> "${GITHUB_OUTPUT}"
else
echo 'has-changes=false' >> "${GITHUB_OUTPUT}"
fi
- uses: crazy-max/ghaction-github-pages@v4
if: ${{ steps.check-changes.outputs.has-changes }}
with:
keep_history: true
build_dir: repository
commit_message: Deploy documentation for '${{ needs.release-context.outputs.version-name }}'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

cleanup:
needs:
- generate-docs
- publish-docs
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Cleanup Artifacts
uses: joutvhu/delete-artifact@v1
jobs:
generate-and-publish-docs:
uses: sersoft-gmbh/oss-common-actions/.github/workflows/swift-generate-and-publish-docs.yml@main
with:
os: ubuntu
swift-version: '5.9'
organisation: ${{ github.repository_owner }}
repository: ${{ github.event.repository.name }}
pages-branch: gh-pages
4 changes: 3 additions & 1 deletion .github/workflows/enable-auto-merge.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Auto-merge for Dependabot PRs

on: pull_request
on:
pull_request:
branches: [ main ]

permissions:
contents: write
Expand Down
Loading

0 comments on commit 52de0cf

Please sign in to comment.