Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install Xcode using xcodes (NO_JIRA) #20

Merged
merged 6 commits into from
Mar 19, 2024
Merged
Changes from 3 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
53 changes: 8 additions & 45 deletions tasks/Darwin.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,14 @@
---
- name: Check for existing Xcode installation
ansible.builtin.stat:
path: "/Applications/Xcode_{{ xcode_version }}.app"
register: xcode_app

- name: "Download XCode {{ xcode_version }}"
ansible.builtin.shell: >
jfrog rt dl
--flat
--fail-no-op
--retries=100
"--url=https://artifactory.ccdc.cam.ac.uk/artifactory"
"--user={{ ansible_deployment_artifactory_user }}"
"--password={{ ansible_deployment_artifactory_key }}"
"ccdc-3rdparty-macos-xcode-installers/Xcode_{{ xcode_version }}.xip"
~/Downloads/
environment:
PATH: "/usr/local/bin:/usr/bin"
CI: "true"
JFROG_CLI_OFFER_CONFIG: "false"
when: xcode_app.stat.isdir is not defined or not xcode_app.stat.isdir
register: download
args:
creates: "~/Downloads/Xcode_{{ xcode_version }}.xip"

- name: Extract XCode archive
ansible.builtin.command: xip -x ~/Downloads/Xcode_{{ xcode_version }}.xip
args:
chdir: "/Applications"
creates: "/Applications/Xcode.app"
when: xcode_app.stat.isdir is not defined or not xcode_app.stat.isdir
register: extract_xcode_xip

- name: Move XCode to /Applications/Xcode_{{ xcode_version }}.app # noqa: name[template]
ansible.builtin.command: mv /Applications/Xcode.app /Applications/Xcode_{{ xcode_version }}.app
when: xcode_app.stat.isdir is not defined or not xcode_app.stat.isdir
- name: Install Xcode v{{ xcode_version }} # noqa: name[template]
ansible.builtin.shell: |
XCODES_USERNAME={{ lookup("env", "CCDC_APPLE_ID_USERNAME") }} \
XCODES_PASSWORD={{ lookup("env", "CCDC_APPLE_ID_PASSWORD") }} \
xcodes install {{ xcode_version }} --experimental-unxip
args:
creates: "/Applications/Xcode_{{ xcode_version }}.app"

- name: Remove downloaded Xcode archive
ansible.builtin.file:
state: absent
path: "~/Downloads/Xcode_{{ xcode_version }}.xip"

- name: Switch to /Applications/Xcode_{{ xcode_version }}.app # noqa: no-changed-when name[template]
ansible.builtin.command: xcode-select --switch /Applications/Xcode_{{ xcode_version }}.app/Contents/Developer
become: true
- name: Switch to Xcode {{ xcode_version }} # noqa: no-changed-when name[template]
ansible.builtin.command: xcodes select {{ xcode_version }}

- name: Accept Xcode licence # noqa: no-changed-when
ansible.builtin.command: xcodebuild -license accept
Expand All @@ -63,7 +26,7 @@
register: packages

- name: Install Xcode packages # noqa: deprecated-module
ansible.builtin.include: install-pkg.yml
ansible.builtin.include_tasks: install-pkg.yml
vars:
package_file: "{{ package }}"
package_list: "{{ pkgutil_packages.stdout }}"
Expand Down
Loading