Skip to content

Commit

Permalink
Use env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
ffried committed Oct 14, 2022
1 parent f8ae153 commit bd661e0
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 46 deletions.
70 changes: 40 additions & 30 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,24 @@ jobs:
release-context:
runs-on: ubuntu-latest
outputs:
version-name: ${{github.ref_name}}
is-latest: ${{steps.compare-tags.output.is-latest}}
version-name: ${{ github.ref_name }}
is-latest: ${{ steps.compare-tags.output.is-latest }}
steps:
- uses: joutvhu/[email protected]
id: latest-release
with:
latest: true
throwing: false
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
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 [ '${{github.ref_type}}' == 'tag' ] && [ '${{steps.latest-release.outputs.tag_name}}' == '${{github.ref_name}}' ]; then
if [ "${REF_TYPE}" == 'tag' ] && [ "${REF_NAME}" == "${LATEST_TAG}" ]; then
echo 'is-latest=true' >> "${GITHUB_OUTPUT}"
else
echo 'is-latest=false' >> "${GITHUB_OUTPUT}"
Expand All @@ -34,7 +38,7 @@ jobs:
spm-context:
runs-on: ubuntu-latest
outputs:
package-dump: ${{steps.dump-package.outputs.package-dump}}
package-dump: ${{ steps.dump-package.outputs.package-dump }}
steps:
- uses: swift-actions/[email protected]
id: swift-setup
Expand All @@ -60,7 +64,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
target: ${{fromJson(needs.spm-context.outputs.package-dump).products.*.targets.*}}
target: ${{ fromJson(needs.spm-context.outputs.package-dump).products.*.targets.* }}
steps:
- uses: swift-actions/[email protected]
id: swift-setup
Expand All @@ -73,27 +77,29 @@ jobs:
- uses: actions/[email protected]
with:
path: .build
key: ${{runner.os}}-${{steps.os-version.outputs.version}}-${{github.repository}}-spm-${{steps.swift-setup.outputs.version}}-${{hashFiles('**/Package.resolved')}}
key: ${{ runner.os }}-${{ steps.os-version.outputs.version }}-${{ github.repository }}-spm-${{ steps.swift-setup.outputs.version }}-${{ hashFiles('**/Package.resolved') }}
restore-keys: |
${{runner.os}}-${{steps.os-version.outputs.version}}-${{github.repository}}-spm-${{steps.swift-setup.outputs.version}}-
${{ runner.os }}-${{ steps.os-version.outputs.version }}-${{ github.repository }}-spm-${{ steps.swift-setup.outputs.version }}-
- uses: sersoft-gmbh/[email protected]
env:
ENABLE_DOCC_SUPPORT: '1'
DOCC_JSON_PRETTYPRINT: 'YES'
with:
package-version: ${{needs.release-context.outputs.version-name}}
targets: ${{matrix.target}}
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
hosting-base-path: ${{ github.event.repository.name }}/${{ needs.release-context.outputs.version-name }}
output: ${{ matrix.target }}-docs
- name: Package docs
run: tar -cvf '${{matrix.target}}-docs.tar' '${{matrix.target}}-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
name: ${{ matrix.target }}-docs
path: ${{ matrix.target }}-docs.tar

publish-docs:
needs:
Expand All @@ -113,8 +119,8 @@ jobs:
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}}
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
Expand All @@ -134,9 +140,10 @@ jobs:
- 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'
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=""
Expand All @@ -154,7 +161,7 @@ jobs:
<!DOCTYPE html>
<html>
<head>
<title>${{github.event.repository.name}} Documentation</title>
<title>${REPO_NAME} Documentation</title>
</head>
<body>
<ul>
Expand All @@ -169,7 +176,7 @@ jobs:
<!DOCTYPE html>
<html>
<head>
<title>${{github.event.repository.name}} Documentation</title>
<title>${REPO_NAME} Documentation</title>
<meta http-equiv="refresh" content="0; url=${BASE_URL}/${single_target_name}" />
</head>
<body>
Expand All @@ -181,13 +188,14 @@ jobs:
- name: Create root index
working-directory: repository
env:
REDIRECT_URL: 'https://${{github.repository_owner}}.github.io/${{github.event.repository.name}}/latest'
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>${{github.event.repository.name}} Documentation</title>
<title>${REPO_NAME} Documentation</title>
<meta http-equiv="refresh" content="0; url=${REDIRECT_URL}" />
</head>
<body>
Expand All @@ -196,11 +204,13 @@ jobs:
</html>
EOF
- name: Create latest symlink
if: ${{needs.release-context.outputs.is-latest}}
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 '${{needs.release-context.outputs.version-name}}' 'latest'
ln -s "${VERSION_NAME}" 'latest'
- name: Determine changes
id: check-changes
working-directory: repository
Expand All @@ -211,19 +221,19 @@ jobs:
echo 'has-changes=false' >> "${GITHUB_OUTPUT}"
fi
- uses: crazy-max/[email protected]
if: ${{steps.check-changes.outputs.has-changes}}
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}}'
commit_message: Deploy documentation for '${{ needs.release-context.outputs.version-name }}'
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

cleanup:
needs:
- generate-docs
- publish-docs
if: always()
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Cleanup Artifacts
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/enable-auto-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- name: Enable auto-merge
run: gh pr merge --auto --rebase "$PR_URL"
run: gh pr merge --auto --rebase "${PR_URL}"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26 changes: 13 additions & 13 deletions .github/workflows/swift-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,20 @@ jobs:
swift-version: 5.7
xcode-version: ''

runs-on: ${{matrix.os}}
runs-on: ${{ matrix.os }}

steps:
- if: runner.os == 'macOS'
- if: ${{ runner.os == 'macOS' }}
uses: maxim-lobanov/[email protected]
with:
xcode-version: ${{matrix.xcode-version}}
xcode-version: ${{ matrix.xcode-version }}
- name: Install Swift
if: runner.os == 'Linux'
if: ${{ runner.os == 'Linux' }}
uses: sersoft-gmbh/[email protected]
with:
release-version: ${{matrix.swift-version}}
platform: ${{matrix.os}}
github-token: ${{secrets.GITHUB_TOKEN}}
release-version: ${{ matrix.swift-version }}
platform: ${{ matrix.os }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Read OS Version
uses: sersoft-gmbh/[email protected]
id: os-version
Expand All @@ -54,9 +54,9 @@ jobs:
- uses: actions/[email protected]
with:
path: .build
key: ${{runner.os}}-${{steps.os-version.outputs.version}}-${{github.repository}}-spm-${{steps.swift-version.outputs.version}}-${{hashFiles('**/Package.resolved')}}
key: ${{ runner.os }}-${{ steps.os-version.outputs.version }}-${{ github.repository }}-spm-${{ steps.swift-version.outputs.version }}-${{ hashFiles('**/Package.resolved') }}
restore-keys: |
${{runner.os}}-${{steps.os-version.outputs.version}}-${{github.repository}}-spm-${{steps.swift-version.outputs.version}}-
${{ runner.os }}-${{ steps.os-version.outputs.version }}-${{ github.repository }}-spm-${{ steps.swift-version.outputs.version }}-
- name: Workaround Package.resolved format issues
if: ${{ startsWith(steps.swift-version.outputs.version, '5.5') }}
run: rm -rf Package.resolved
Expand All @@ -67,8 +67,8 @@ jobs:
id: coverage-files
- uses: codecov/[email protected]
with:
token: ${{secrets.CODECOV_TOKEN}}
files: ${{join(fromJSON(steps.coverage-files.outputs.files), ',')}}
token: ${{ secrets.CODECOV_TOKEN }}
files: ${{ join(fromJSON(steps.coverage-files.outputs.files), ',') }}
fail_ci_if_error: true

test-xcode:
Expand All @@ -90,6 +90,6 @@ jobs:
id: coverage-files
- uses: codecov/[email protected]
with:
token: ${{secrets.CODECOV_TOKEN}}
files: ${{join(fromJSON(steps.coverage-files.outputs.files), ',')}}
token: ${{ secrets.CODECOV_TOKEN }}
files: ${{ join(fromJSON(steps.coverage-files.outputs.files), ',') }}
fail_ci_if_error: true

0 comments on commit bd661e0

Please sign in to comment.