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
Binary file modified .github/256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
87 changes: 87 additions & 0 deletions .github/workflows/containers-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Publish containers release

permissions:
contents: write

# App Store Connect can't notify GitHub directly, so this polls the public
# App Store lookup and publishes a release once a version is live. A relay for
# App Store Connect webhooks can send the app-store-release dispatch instead.
on:
schedule:
- cron: '17 */6 * * *'
workflow_dispatch:
repository_dispatch:
types: [app-store-release]

concurrency:
group: app-store-release

jobs:
release:
name: Publish release
if: github.repository == 'try-containers/Containers'
runs-on: ubuntu-latest
env:
BUNDLE_ID: app.containers.Containers
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ github.token }}

steps:
- name: Look up the App Store version
id: store
run: |
LOOKUP_PATH="${RUNNER_TEMP}/lookup.json"
curl --fail --silent --show-error --output "${LOOKUP_PATH}" "https://itunes.apple.com/lookup?bundleId=${BUNDLE_ID}"

VERSION=$(jq -r '.results[0].version // empty' "${LOOKUP_PATH}")
STORE_URL=$(jq -r '.results[0].trackViewUrl // empty' "${LOOKUP_PATH}" | sed 's/[?].*//')

if [ -z "${VERSION}" ] || [ -z "${STORE_URL}" ] ; then
echo "::error::The App Store has no app with bundle ID ${BUNDLE_ID}."
false
fi

echo "Version ${VERSION} is live at ${STORE_URL}"
echo "version=${VERSION}" >> "${GITHUB_OUTPUT}"
echo "url=${STORE_URL}" >> "${GITHUB_OUTPUT}"

- name: Check for a 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."
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."
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})"
} > "${RUNNER_TEMP}/notes.md"

gh release create "${VERSION}" \
--verify-tag \
--latest \
--title "Containers ${VERSION}" \
--notes-file "${RUNNER_TEMP}/notes.md"
175 changes: 175 additions & 0 deletions .github/workflows/containers-testflight.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
name: Deploy containers 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.
on:
push:
tags:
- '[0-9]+.[0-9]+'
- '[0-9]+.[0-9]+.[0-9]+'

concurrency:
group: testflight

jobs:
validate:
name: Validate tag
if: github.repository == 'try-containers/Containers'
runs-on: ubuntu-latest
env:
VERSION: ${{ github.ref_name }}

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

- name: Check that the tag is on main
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

deploy:
name: Upload to TestFlight
needs: containers
timeout-minutes: 60
runs-on: macos-26
env:
DEVELOPER_DIR: "/Applications/Xcode_26.6.app/Contents/Developer"
VERSION: ${{ github.ref_name }}
DEVELOPMENT_TEAM: ${{ vars.DEVELOPMENT_TEAM }}

steps:
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6

# The runner context isn't available to job-level env, so the paths
# under the runner's temporary directory are set here.
- name: Set paths
run: |
echo "KEYCHAIN_PATH=${RUNNER_TEMP}/signing.keychain-db" >> "${GITHUB_ENV}"
echo "API_KEY_PATH=${RUNNER_TEMP}/AuthKey.p8" >> "${GITHUB_ENV}"
echo "ARCHIVE_PATH=${RUNNER_TEMP}/Containers.xcarchive" >> "${GITHUB_ENV}"

- name: Show Xcode version
run: xcodebuild -version

- name: Install signing certificates
env:
SIGNING_CERTIFICATES_P12: ${{ secrets.SIGNING_CERTIFICATES_P12 }}
SIGNING_CERTIFICATES_PASSWORD: ${{ secrets.SIGNING_CERTIFICATES_PASSWORD }}
run: |
CERTIFICATES_PATH="${RUNNER_TEMP}/certificates.p12"
KEYCHAIN_PASSWORD="$(uuidgen)"
echo -n "${SIGNING_CERTIFICATES_P12}" | base64 --decode > "${CERTIFICATES_PATH}"

security create-keychain -p "${KEYCHAIN_PASSWORD}" "${KEYCHAIN_PATH}"
security set-keychain-settings -lut 21600 "${KEYCHAIN_PATH}"
security unlock-keychain -p "${KEYCHAIN_PASSWORD}" "${KEYCHAIN_PATH}"
security import "${CERTIFICATES_PATH}" -P "${SIGNING_CERTIFICATES_PASSWORD}" -A -t cert -f pkcs12 -k "${KEYCHAIN_PATH}"
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "${KEYCHAIN_PASSWORD}" "${KEYCHAIN_PATH}"
security list-keychains -d user -s "${KEYCHAIN_PATH}" $(security list-keychains -d user | tr -d '"')
rm "${CERTIFICATES_PATH}"

- name: Install App Store Connect API key
env:
APP_STORE_CONNECT_PRIVATE_KEY: ${{ secrets.APP_STORE_CONNECT_PRIVATE_KEY }}
run: printf '%s\n' "${APP_STORE_CONNECT_PRIVATE_KEY}" > "${API_KEY_PATH}"

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

- name: Check the version
run: |
PROJECT_VERSION=$(
xcodebuild -showBuildSettings -json \
-project Containers.xcodeproj \
-scheme "Containers (macOS)" \
-configuration Release \
| jq -r '.[] | select(.target == "Containers") | .buildSettings.MARKETING_VERSION'
)

if [ "${PROJECT_VERSION}" != "${VERSION}" ] ; then
echo "::error::Tag ${VERSION} doesn't match MARKETING_VERSION ${PROJECT_VERSION}."
false
fi

# macOS requires every upload's build number to be higher than the last,
# across versions; a UTC timestamp always is, even when a run is retried.
- name: Archive
env:
APP_STORE_CONNECT_KEY_ID: ${{ secrets.APP_STORE_CONNECT_KEY_ID }}
APP_STORE_CONNECT_ISSUER_ID: ${{ secrets.APP_STORE_CONNECT_ISSUER_ID }}
run: |
set -o pipefail
xcodebuild archive \
-project Containers.xcodeproj \
-scheme "Containers (macOS)" \
-configuration Release \
-destination 'generic/platform=macOS' \
-archivePath "${ARCHIVE_PATH}" \
-allowProvisioningUpdates \
-authenticationKeyPath "${API_KEY_PATH}" \
-authenticationKeyID "${APP_STORE_CONNECT_KEY_ID}" \
-authenticationKeyIssuerID "${APP_STORE_CONNECT_ISSUER_ID}" \
DEVELOPMENT_TEAM="${DEVELOPMENT_TEAM}" \
CURRENT_PROJECT_VERSION="$(date -u +%Y%m%d%H%M)"

- name: Upload
env:
APP_STORE_CONNECT_KEY_ID: ${{ secrets.APP_STORE_CONNECT_KEY_ID }}
APP_STORE_CONNECT_ISSUER_ID: ${{ secrets.APP_STORE_CONNECT_ISSUER_ID }}
run: |
EXPORT_OPTIONS_PATH="${RUNNER_TEMP}/ExportOptions.plist"
cat > "${EXPORT_OPTIONS_PATH}" <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>method</key>
<string>app-store-connect</string>
<key>destination</key>
<string>upload</string>
<key>teamID</key>
<string>${DEVELOPMENT_TEAM}</string>
<key>signingStyle</key>
<string>automatic</string>
<key>manageAppVersionAndBuildNumber</key>
<false/>
<key>uploadSymbols</key>
<true/>
</dict>
</plist>
EOF

set -o pipefail
xcodebuild -exportArchive \
-archivePath "${ARCHIVE_PATH}" \
-exportOptionsPlist "${EXPORT_OPTIONS_PATH}" \
-exportPath "${RUNNER_TEMP}/Export" \
-allowProvisioningUpdates \
-authenticationKeyPath "${API_KEY_PATH}" \
-authenticationKeyID "${APP_STORE_CONNECT_KEY_ID}" \
-authenticationKeyIssuerID "${APP_STORE_CONNECT_ISSUER_ID}"

- name: Remove signing credentials
if: always()
run: |
security delete-keychain "${KEYCHAIN_PATH}" || true
rm -f "${API_KEY_PATH}"
5 changes: 5 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ Rules for where logic goes:
- Tests read `@Test("Short sentence-case phrase") func camelCaseName()`, with no `test` prefix.
- Each test works in its own `TemporaryDirectory` (`ContainerSystemTests/Support`) and removes it with `defer`. Tests that need managers use `MockContainerRuntime` (`ContainerSystemTests/Mocks`); service tests build the service directly over a temporary folder.

## Releases

- To release, set `MARKETING_VERSION` (such as `0.2`), then push a tag with that number on `main`. `containers-testflight.yml` checks that the tag is on `main` and matches the version, then uploads the build to TestFlight.
- Release notes are the What's New text in App Store Connect; the repository keeps no changelog. `containers-release.yml` polls the App Store and, once a version is live, publishes a GitHub release for its tag with those notes and a Mac App Store link.

## Requirements

- macOS 26 or later on Apple silicon.
Expand Down
Loading
Loading