Skip to content

Commit

Permalink
Refactored release scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
fkorotkov committed Oct 19, 2024
1 parent 9a16028 commit 37c7784
Show file tree
Hide file tree
Showing 9 changed files with 165 additions and 150 deletions.
19 changes: 19 additions & 0 deletions .ci/cirrus.base.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
task:
name: "Update Base Images ($MACOS_VERSION)"
alias: update-base
matrix:
- env:
MACOS_VERSION: sonoma
- env:
MACOS_VERSION: sequoia
<<: *defaults
pull_vanilla_script:
- tart pull ghcr.io/cirruslabs/macos-$MACOS_VERSION-vanilla:latest
build_base_script:
- packer init templates/base.pkr.hcl
- packer build -var macos_version="$MACOS_VERSION" templates/base.pkr.hcl
push_base_script:
- tart push $MACOS_VERSION-base ghcr.io/cirruslabs/macos-$MACOS_VERSION-base:latest
always:
cleanup_script:
- tart delete $MACOS_VERSION-base
23 changes: 23 additions & 0 deletions .ci/cirrus.release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
task:
name: "Release Xcode $CIRRUS_TAG ($MACOS_VERSION)"
matrix:
- env:
MACOS_VERSION: sonoma
- env:
MACOS_VERSION: sequoia
<<: *defaults
pull_base_script:
- tart pull ghcr.io/cirruslabs/macos-$MACOS_VERSION-base:latest
build_script:
- packer init templates/xcode.pkr.hcl
- packer build -var macos_version="$MACOS_VERSION" -var xcode_version="[\"$CIRRUS_TAG\"]" templates/xcode.pkr.hcl
push_script: |
if [[ $CIRRUS_TAG == *"beta"* ]]
then
tart push $MACOS_VERSION-xcode:$CIRRUS_TAG ghcr.io/cirruslabs/macos-$MACOS_VERSION-xcode:$CIRRUS_TAG
else
tart push $MACOS_VERSION-xcode:$CIRRUS_TAG ghcr.io/cirruslabs/macos-$MACOS_VERSION-xcode:$CIRRUS_TAG ghcr.io/cirruslabs/macos-$MACOS_VERSION-xcode:latest
fi
always:
cleanup_script:
- tart delete $MACOS_VERSION-xcode:$CIRRUS_TAG || true
20 changes: 20 additions & 0 deletions .ci/cirrus.runner.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
task:
name: "Update Runner Image ($MACOS_VERSION)"
env:
matrix:
- MACOS_VERSION: sonoma
XCODE_VERSIONS: 15.2,15.3,15.4,16
- MACOS_VERSION: sequoia
XCODE_VERSIONS: "\"16.1-beta-3\",15.4,16"
only_if: $CIRRUS_CRON == "weekly" # Every Sunday at 14 UTC
<<: *defaults
pull_base_script:
- tart pull ghcr.io/cirruslabs/macos-$MACOS_VERSION-base:latest
build_xcode_script:
- packer init templates/xcode.pkr.hcl
- packer build -var tag=runner -var disk_size=300 -var disk_free_mb=100000 -var macos_version="$MACOS_VERSION" -var xcode_version="[$XCODE_VERSIONS]" templates/xcode.pkr.hcl
push_script: |
tart push "$MACOS_VERSION-xcode:runner" ghcr.io/cirruslabs/macos-runner:$MACOS_VERSION
always:
cleanup_script:
- tart delete "$MACOS_VERSION-xcode:runner"
44 changes: 44 additions & 0 deletions .ci/cirrus.vanilla.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
task:
name: "Update Vanilla Sonoma Image"
only_if: $CIRRUS_BRANCH == $CIRRUS_DEFAULT_BRANCH && changesInclude("templates/vanilla-sonoma.pkr.hcl")
<<: *defaults
build_script:
- packer init templates/vanilla-sonoma.pkr.hcl
- packer build templates/vanilla-sonoma.pkr.hcl
disable_sip_script:
- packer build -var vm_name=sonoma-vanilla templates/disable-sip.pkr.hcl
push_script:
- tart push sonoma-vanilla ghcr.io/cirruslabs/macos-sonoma-vanilla:latest ghcr.io/cirruslabs/macos-sonoma-vanilla:14.6
always:
cleanup_script:
- tart delete sonoma-vanilla

task:
name: "Update Vanilla Sequoia Image"
only_if: $CIRRUS_BRANCH == $CIRRUS_DEFAULT_BRANCH && changesInclude("templates/vanilla-sequoia.pkr.hcl")
<<: *defaults
build_script:
- packer init templates/vanilla-sequoia.pkr.hcl
- packer build templates/vanilla-sequoia.pkr.hcl
disable_sip_script:
- packer build -var vm_name=sequoia-vanilla templates/disable-sip.pkr.hcl
push_script:
- tart push sequoia-vanilla ghcr.io/cirruslabs/macos-sequoia-vanilla:latest ghcr.io/cirruslabs/macos-sequoia-vanilla:15.0.1
always:
cleanup_script:
- tart delete sequoia-vanilla

task:
name: "Update Vanilla Sequoia Beta Image"
only_if: $CIRRUS_BRANCH == $CIRRUS_DEFAULT_BRANCH && changesInclude("templates/vanilla-sequoia-beta.pkr.hcl")
<<: *defaults
build_script:
- packer init templates/vanilla-sequoia-beta.pkr.hcl
- packer build templates/vanilla-sequoia-beta.pkr.hcl
disable_sip_script:
- packer build -var vm_name=sequoia-vanilla templates/disable-sip.pkr.hcl
push_script:
- tart push sequoia-vanilla ghcr.io/cirruslabs/macos-sequoia-vanilla:15.1-beta-6
always:
cleanup_script:
- tart delete sequoia-vanilla
35 changes: 35 additions & 0 deletions .ci/cirrus.xcode.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
task:
name: "Update Xcode Images ($MACOS_VERSION $XCODE_VERSION)"
depends_on: update-base
env:
matrix:
- MACOS_VERSION: sequoia
XCODE_VERSION: 16.1-beta-3
- MACOS_VERSION: sequoia
XCODE_VERSION: 16
LATEST: true
- MACOS_VERSION: sonoma
XCODE_VERSION: 16
LATEST: true
- MACOS_VERSION: sonoma
XCODE_VERSION: 15.4
- MACOS_VERSION: sonoma
XCODE_VERSION: 15.3
- MACOS_VERSION: sonoma
XCODE_VERSION: 15.2
<<: *defaults
pull_base_script:
- tart pull ghcr.io/cirruslabs/macos-$MACOS_VERSION-base:latest
build_xcode_script:
- packer init templates/xcode.pkr.hcl
- packer build -var macos_version="$MACOS_VERSION" -var xcode_version="[\"$XCODE_VERSION\"]" templates/xcode.pkr.hcl
push_script: |
if [[ -z "$LATEST" ]]
then
tart push "$MACOS_VERSION-xcode:$XCODE_VERSION" ghcr.io/cirruslabs/macos-$MACOS_VERSION-xcode:$XCODE_VERSION
else
tart push "$MACOS_VERSION-xcode:$XCODE_VERSION" ghcr.io/cirruslabs/macos-$MACOS_VERSION-xcode:$XCODE_VERSION ghcr.io/cirruslabs/macos-$MACOS_VERSION-xcode:latest
fi
always:
cleanup_script:
- tart delete "$MACOS_VERSION-xcode:$XCODE_VERSION"
28 changes: 22 additions & 6 deletions .cirrus.star
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
load("cirrus", "env", "http")
load("cirrus", "env", "http", "fs")
load("github.com/cirrus-modules/graphql", "rerun_task_if_issue_in_logs")


def on_task_failed(ctx):
if ctx.payload.data.task.automaticReRun:
print("Task is already an automatic re-run! Won't even try to re-run it...")
return
rerun_task_if_issue_in_logs(ctx.payload.data.task.id, "The network connection was lost")
if ctx.payload.data.task.automaticReRun:
print("Task is already an automatic re-run! Won't even try to re-run it...")
return
rerun_task_if_issue_in_logs(ctx.payload.data.task.id, "The network connection was lost")


def on_build_failed(ctx):
# Only send Slack notifications for failed cron builds[1]
Expand All @@ -19,7 +21,9 @@ def on_build_failed(ctx):
"Authorization": "Bearer " + env.get("SLACK_TOKEN"),
}, json_body={
"channel": "#image-updates",
"text": "Build <https://cirrus-ci.com/build/{build_id}|{build_id} (\"{change_message_title}\")> failed on branch \"{branch_name}\" in repository \"{repository_name}\".".format(build_id=ctx.payload.data.build.id, change_message_title=ctx.payload.data.build.changeMessageTitle, branch_name=ctx.payload.data.build.branch, repository_name=ctx.payload.data.repository.name),
"text": "Build <https://cirrus-ci.com/build/{build_id}|{build_id} (\"{change_message_title}\")> failed on branch \"{branch_name}\" in repository \"{repository_name}\".".format(
build_id=ctx.payload.data.build.id, change_message_title=ctx.payload.data.build.changeMessageTitle,
branch_name=ctx.payload.data.build.branch, repository_name=ctx.payload.data.repository.name),
})

if resp.status_code != 200:
Expand All @@ -29,3 +33,15 @@ def on_build_failed(ctx):

if resp_json["ok"] != True:
fail("got error when posting message to Slack: {}".format(resp_json["error"]))


def main(ctx):
result = fs.read(".ci/cirrus.vanilla.yml")
if env.get("CIRRUS_TAG") != None:
result += fs.read(".ci/cirrus.release.yml")
if env.get("CIRRUS_CRON") == "monthly":
result += fs.read(".ci/cirrus.base.yml")
result += fs.read(".ci/cirrus.xcode.yml")
if env.get("CIRRUS_CRON") == "weekly":
result += fs.read(".ci/cirrus.runner.yml")
return result
142 changes: 0 additions & 142 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,145 +19,3 @@ defaults: &defaults
info_script:
- tart --version
- packer --version

task:
name: "Update Vanilla Sonoma Image"
only_if: $CIRRUS_BRANCH == $CIRRUS_DEFAULT_BRANCH && changesInclude("templates/vanilla-sonoma.pkr.hcl")
<<: *defaults
build_script:
- packer init templates/vanilla-sonoma.pkr.hcl
- packer build templates/vanilla-sonoma.pkr.hcl
disable_sip_script:
- packer build -var vm_name=sonoma-vanilla templates/disable-sip.pkr.hcl
push_script:
- tart push sonoma-vanilla ghcr.io/cirruslabs/macos-sonoma-vanilla:latest ghcr.io/cirruslabs/macos-sonoma-vanilla:14.6.1
always:
cleanup_script:
- tart delete sonoma-vanilla

task:
name: "Update Vanilla Sequoia Image"
only_if: $CIRRUS_BRANCH == $CIRRUS_DEFAULT_BRANCH && changesInclude("templates/vanilla-sequoia.pkr.hcl")
<<: *defaults
build_script:
- packer init templates/vanilla-sequoia.pkr.hcl
- packer build templates/vanilla-sequoia.pkr.hcl
disable_sip_script:
- packer build -var vm_name=sequoia-vanilla templates/disable-sip.pkr.hcl
push_script:
- tart push sequoia-vanilla ghcr.io/cirruslabs/macos-sequoia-vanilla:latest ghcr.io/cirruslabs/macos-sequoia-vanilla:15.0-rc
always:
cleanup_script:
- tart delete sequoia-vanilla

task:
name: "Update Vanilla Sequoia Beta Image"
only_if: $CIRRUS_BRANCH == $CIRRUS_DEFAULT_BRANCH && changesInclude("templates/vanilla-sequoia-beta.pkr.hcl")
<<: *defaults
build_script:
- packer init templates/vanilla-sequoia-beta.pkr.hcl
- packer build templates/vanilla-sequoia-beta.pkr.hcl
disable_sip_script:
- packer build -var vm_name=sequoia-vanilla templates/disable-sip.pkr.hcl
push_script:
- tart push sequoia-vanilla ghcr.io/cirruslabs/macos-sequoia-vanilla:15.1-beta-3
always:
cleanup_script:
- tart delete sequoia-vanilla

task:
name: "Update Base Images ($MACOS_VERSION)"
alias: update-base
matrix:
- env:
MACOS_VERSION: sonoma
- env:
MACOS_VERSION: sequoia
only_if: $CIRRUS_CRON == "monthly"
<<: *defaults
pull_vanilla_script:
- tart pull ghcr.io/cirruslabs/macos-$MACOS_VERSION-vanilla:latest
build_base_script:
- packer init templates/base.pkr.hcl
- packer build -var macos_version="$MACOS_VERSION" templates/base.pkr.hcl
push_base_script:
- tart push $MACOS_VERSION-base ghcr.io/cirruslabs/macos-$MACOS_VERSION-base:latest
always:
cleanup_script:
- tart delete $MACOS_VERSION-base

task:
name: "Update Xcode Images ($MACOS_VERSION $XCODE_VERSION)"
depends_on: update-base
only_if: $CIRRUS_CRON == "monthly" # Every first Saturday of a month at 14 UTC
env:
matrix:
- MACOS_VERSION: sonoma
XCODE_VERSION: 16
LATEST: true
- MACOS_VERSION: sonoma
XCODE_VERSION: 15.4
- MACOS_VERSION: sonoma
XCODE_VERSION: 15.3
- MACOS_VERSION: sonoma
XCODE_VERSION: 15.2
<<: *defaults
pull_base_script:
- tart pull ghcr.io/cirruslabs/macos-$MACOS_VERSION-base:latest
build_xcode_script:
- packer init templates/xcode.pkr.hcl
- packer build -var macos_version="$MACOS_VERSION" -var xcode_version="[\"$XCODE_VERSION\"]" templates/xcode.pkr.hcl
push_script: |
if [[ -z "$LATEST" ]]
then
tart push "$MACOS_VERSION-xcode:$XCODE_VERSION" ghcr.io/cirruslabs/macos-$MACOS_VERSION-xcode:$XCODE_VERSION
else
tart push "$MACOS_VERSION-xcode:$XCODE_VERSION" ghcr.io/cirruslabs/macos-$MACOS_VERSION-xcode:$XCODE_VERSION ghcr.io/cirruslabs/macos-$MACOS_VERSION-xcode:latest
fi
always:
cleanup_script:
- tart delete "$MACOS_VERSION-xcode:$XCODE_VERSION"

task:
name: "Update Runner Image ($MACOS_VERSION)"
env:
matrix:
- MACOS_VERSION: sonoma
XCODE_VERSIONS: 15.2,15.3,15.4,16
- MACOS_VERSION: sequoia
XCODE_VERSIONS: "\"16.1-beta-3\",15.4,16"
only_if: $CIRRUS_CRON == "weekly" # Every Sunday at 14 UTC
<<: *defaults
pull_base_script:
- tart pull ghcr.io/cirruslabs/macos-$MACOS_VERSION-base:latest
build_xcode_script:
- packer init templates/xcode.pkr.hcl
- packer build -var tag=runner -var disk_size=300 -var disk_free_mb=100000 -var macos_version="$MACOS_VERSION" -var xcode_version="[$XCODE_VERSIONS]" templates/xcode.pkr.hcl
push_script: |
tart push "$MACOS_VERSION-xcode:runner" ghcr.io/cirruslabs/macos-runner:$MACOS_VERSION
always:
cleanup_script:
- tart delete "$MACOS_VERSION-xcode:runner"

task:
name: "Release Xcode $CIRRUS_TAG ($MACOS_VERSION)"
only_if: $CIRRUS_TAG != ""
matrix:
- env:
MACOS_VERSION: sonoma
<<: *defaults
pull_base_script:
- tart pull ghcr.io/cirruslabs/macos-$MACOS_VERSION-base:latest
build_script:
- packer init templates/xcode.pkr.hcl
- packer build -var macos_version="$MACOS_VERSION" -var xcode_version="[\"$CIRRUS_TAG\"]" templates/xcode.pkr.hcl
push_script: |
if [[ $CIRRUS_TAG == *"beta"* ]]
then
tart push $MACOS_VERSION-xcode:$CIRRUS_TAG ghcr.io/cirruslabs/macos-$MACOS_VERSION-xcode:$CIRRUS_TAG
else
tart push $MACOS_VERSION-xcode:$CIRRUS_TAG ghcr.io/cirruslabs/macos-$MACOS_VERSION-xcode:$CIRRUS_TAG ghcr.io/cirruslabs/macos-$MACOS_VERSION-xcode:latest
fi
always:
cleanup_script:
- tart delete $MACOS_VERSION-xcode:$CIRRUS_TAG || true
2 changes: 1 addition & 1 deletion templates/vanilla-sequoia-beta.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ packer {
}

source "tart-cli" "tart" {
from_ipsw = "https://updates.cdn-apple.com/2024SummerSeed/fullrestores/062-74506/D50AC8F9-4795-4711-9C1A-907B6EB829A2/UniversalMac_15.1_24B5035e_Restore.ipsw"
from_ipsw = "https://updates.cdn-apple.com/2024FallSeed/fullrestores/072-00383/7EB106DF-9B03-4C2A-ACD1-997B0BFF9364/UniversalMac_15.1_24B5070a_Restore.ipsw"
vm_name = "sequoia-vanilla"
cpu_count = 4
memory_gb = 8
Expand Down
2 changes: 1 addition & 1 deletion templates/vanilla-sonoma.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ packer {
}

source "tart-cli" "tart" {
from_ipsw = "https://updates.cdn-apple.com/2024SummerFCS/fullrestores/062-52859/932E0A8F-6644-4759-82DA-F8FA8DEA806A/UniversalMac_14.6.1_23G93_Restore.ipsw"
from_ipsw = "https://updates.cdn-apple.com/2024SummerFCS/fullrestores/052-69922/F5DA2B64-25EB-4370-9E89-FA5689859796/UniversalMac_14.6_23G80_Restore.ipsw"
vm_name = "sonoma-vanilla"
cpu_count = 4
memory_gb = 8
Expand Down

0 comments on commit 37c7784

Please sign in to comment.