Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 0 additions & 98 deletions .github/workflows/containers-build-template.yml

This file was deleted.

105 changes: 102 additions & 3 deletions .github/workflows/containers-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,106 @@ on:
- main
- release/*

env:
DEVELOPER_DIR: "/Applications/Xcode_26.6.app/Contents/Developer"

jobs:
containers:
uses: ./.github/workflows/containers-build-template.yml
secrets: inherit
build:
name: Build
if: github.repository == 'try-containers/Containers'
timeout-minutes: 60
runs-on: macos-26

steps:
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
with:
fetch-depth: 0

- name: Show Xcode version
run: xcodebuild -version

- name: Check formatting
run: |
swift format --recursive --configuration .swift-format -i $(find . -type f -name '*.swift' -not -path "*/.*")
git diff
if ! git diff --quiet ; then echo the following files require formatting: ; git diff --name-only ; false ; fi

- name: Lint
run: |
swift format lint --strict --recursive --configuration .swift-format $(find . -type f -name '*.swift' -not -path "*/.*")

- name: Resolve packages
run: |
xcodebuild -resolvePackageDependencies \
-project Containers.xcodeproj \
-scheme "Containers (macOS)"

# Builds the app and every test target in the scheme's test action, and
# writes the .xctestrun file that lists them for the Test job.
- name: Build
run: |
set -o pipefail
xcodebuild build-for-testing \
-project Containers.xcodeproj \
-scheme "Containers (macOS)" \
-configuration Debug \
-destination 'platform=macOS' \
-derivedDataPath DerivedData \
CODE_SIGNING_ALLOWED=NO

# The archive keeps the executable permissions and symbolic links that an
# artifact loses. Intermediate files the tests don't run are left out.
- name: Archive build products
run: |
tar -C DerivedData/Build/Products \
--exclude '*.o' \
--exclude '*.swiftmodule' \
--exclude '*.dSYM' \
--exclude '*.modulemap' \
--exclude 'include' \
-czf BuildProducts.tar.gz .

- name: Save build products artifact
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: build-products
path: BuildProducts.tar.gz
retention-days: 1

test:
name: Test
needs: build
timeout-minutes: 60
runs-on: macos-26

steps:
- name: Show Xcode version
run: xcodebuild -version

- name: Download build products artifact
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: build-products

- name: Extract build products
run: |
mkdir BuildProducts
tar -C BuildProducts -xzf BuildProducts.tar.gz

# Runs the Build job's products, with every test target in its .xctestrun file.
- name: Test
run: |
set -o pipefail
xcodebuild test-without-building \
-xctestrun BuildProducts/*.xctestrun \
-destination 'platform=macOS' \
-resultBundlePath TestResults.xcresult

- name: Save test results artifact
if: failure()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: test-results
path: TestResults.xcresult
retention-days: 14
38 changes: 17 additions & 21 deletions .github/workflows/containers-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ permissions:
contents: write

# App Store Connect can't notify GitHub directly, so this runs by hand once a
# version is live, and publishes a release from the public App Store lookup. A
# relay for App Store Connect webhooks can send the app-store-release dispatch.
# version is live. It publishes the version's draft release with a Mac App Store
# link. A relay for App Store Connect webhooks can send the app-store-release dispatch.
on:
workflow_dispatch:
repository_dispatch:
Expand Down Expand Up @@ -43,43 +43,39 @@ jobs:
echo "version=${VERSION}" >> "${GITHUB_OUTPUT}"
echo "url=${STORE_URL}" >> "${GITHUB_OUTPUT}"

- name: Check for a release
# Pushing a version tag creates the version's draft release, whose notes
# are written by hand.
- name: Check for a draft release
id: check
env:
VERSION: ${{ steps.store.outputs.version }}
run: |
if gh release view "${VERSION}" > /dev/null 2>&1 ; then
echo "Release ${VERSION} already exists."
if ! RELEASE=$(gh release view "${VERSION}" --json isDraft,body 2> /dev/null) ; then
echo "::warning::Version ${VERSION} is live, but there's no release for it. Pushing tag ${VERSION} creates its draft."
echo "publish=false" >> "${GITHUB_OUTPUT}"
elif ! gh api "repos/${GH_REPO}/git/ref/tags/${VERSION}" > /dev/null 2>&1 ; then
echo "::warning::Version ${VERSION} is live, but there's no tag ${VERSION} to release."
elif [ "$(jq -r '.isDraft' <<< "${RELEASE}")" != "true" ] ; then
echo "Release ${VERSION} is already published."
echo "publish=false" >> "${GITHUB_OUTPUT}"
elif [ -z "$(jq -r '.body // empty' <<< "${RELEASE}")" ] ; then
echo "::warning::The draft release for ${VERSION} has no notes yet."
echo "publish=false" >> "${GITHUB_OUTPUT}"
else
echo "publish=true" >> "${GITHUB_OUTPUT}"
fi

# The notes are the version's What's New text from App Store Connect.
# A first version can't have any; its release is written by hand.
- name: Publish release
if: steps.check.outputs.publish == 'true'
env:
VERSION: ${{ steps.store.outputs.version }}
STORE_URL: ${{ steps.store.outputs.url }}
run: |
NOTES=$(jq -r '.results[0].releaseNotes // empty' "${RUNNER_TEMP}/lookup.json")

if [ -z "${NOTES}" ] ; then
echo "::warning::Version ${VERSION} has no What's New text, so its release needs writing by hand."
exit 0
fi

{
printf '%s\n\n' "${NOTES}"
echo "[Download Containers ${VERSION} on the Mac App Store](${STORE_URL})"
gh release view "${VERSION}" --json body --jq '.body'
echo
echo "[Download Containers on the Mac App Store](${STORE_URL})"
} > "${RUNNER_TEMP}/notes.md"

gh release create "${VERSION}" \
--verify-tag \
gh release edit "${VERSION}" \
--draft=false \
--latest \
--title "Containers ${VERSION}" \
--notes-file "${RUNNER_TEMP}/notes.md"
65 changes: 56 additions & 9 deletions .github/workflows/containers-testflight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ name: Deploy to TestFlight
permissions:
contents: read

# Version tags, such as 0.2 or 0.2.1. A tag push can't be filtered by branch,
# so the validate job checks that the tag is on main.
# Version tags, such as 0.2 or 0.2.1, upload the version's final build and
# create its draft release. A tag push can't be filtered by branch, so the
# validate job checks that the tag is on main. Running the workflow by hand
# uploads a test build of the chosen branch, with no tag or release.
on:
push:
tags:
- '[0-9]+.[0-9]+'
- '[0-9]+.[0-9]+.[0-9]+'
workflow_dispatch:

concurrency:
group: testflight
Expand All @@ -19,8 +22,13 @@ jobs:
name: Validate tag
if: github.repository == 'try-containers/Containers'
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
env:
VERSION: ${{ github.ref_name }}
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ github.token }}

steps:
- name: Checkout repository
Expand All @@ -29,22 +37,32 @@ jobs:
fetch-depth: 0

- name: Check that the tag is on main
if: github.ref_type == 'tag'
run: |
if ! git merge-base --is-ancestor "${GITHUB_SHA}" origin/main ; then
echo "::error::Tag ${VERSION} points to a commit that isn't on main."
false
fi

containers:
needs: validate
uses: ./.github/workflows/containers-build-template.yml
secrets: inherit
with:
release: true
# Build & Test runs on the commit when it's pushed to main. Re-run this
# workflow once that run passes.
- name: Check that Build & Test passed
if: github.ref_type == 'tag'
run: |
CONCLUSION=$(
gh api "repos/${GH_REPO}/actions/workflows/containers-build.yml/runs?head_sha=${GITHUB_SHA}&status=completed" \
--jq '.workflow_runs[0].conclusion // empty'
)

if [ "${CONCLUSION}" != "success" ] ; then
echo "::error::Build & Test hasn't passed on ${GITHUB_SHA}, the commit for tag ${VERSION}."
false
fi

# Formatting, lint and tests run on every pull request; the archive builds the app.
deploy:
name: Upload to TestFlight
needs: containers
needs: validate
timeout-minutes: 60
runs-on: macos-26
env:
Expand Down Expand Up @@ -96,6 +114,7 @@ jobs:
-scheme "Containers (macOS)"

- name: Check the version
if: github.ref_type == 'tag'
run: |
PROJECT_VERSION=$(
xcodebuild -showBuildSettings -json \
Expand Down Expand Up @@ -173,3 +192,31 @@ jobs:
run: |
security delete-keychain "${KEYCHAIN_PATH}" || true
rm -f "${API_KEY_PATH}"

# The notes are written by hand in the draft, with the pull requests for each
# change. Publish Release publishes it once the version is live.
draft:
name: Create draft release
needs: deploy
if: github.ref_type == 'tag'
runs-on: ubuntu-latest
permissions:
contents: write
env:
VERSION: ${{ github.ref_name }}
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ github.token }}

steps:
- name: Create draft release
run: |
if gh release view "${VERSION}" > /dev/null 2>&1 ; then
echo "Release ${VERSION} already exists."
exit 0
fi

gh release create "${VERSION}" \
--draft \
--verify-tag \
--title "Containers ${VERSION}" \
--notes ""
Loading
Loading