-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
96 lines (83 loc) · 3.49 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
name: "Swift install"
description: "Install Swift"
inputs:
swift-prefix:
description: "The URL prefix to download the Swift toolchain from, \
if installing Swift. The string should be a valid directory under \
download.swift.org, such as 'swift-5.10.1-release/ubuntu2404/swift-5.10.1-RELEASE'"
required: true
type: string
swift-id:
description: "The Swift toolchain version to install. This should be a full toolchain \
identifier, including the platform, like 'swift-5.10.1-RELEASE-ubuntu24.04'"
required: true
type: string
runs:
using: composite
steps:
- name: Create installation directory
shell: bash
run: |
mkdir ~/swift
### Linux-specific steps
- name: Cache Swift toolchain (Linux)
id: cache_swift_linux
if: runner.os == 'Linux'
uses: actions/cache@v4
with:
path: "~/swift/swift.tar.gz"
key: "swift:${{ inputs.swift-id }}.tar.gz"
- name: Download Swift (Linux)
shell: bash
if: runner.os == 'Linux' && steps.cache_swift_linux.outputs.cache-hit != 'true'
env:
SWIFT_PREFIX: ${{ inputs.swift-prefix }}
SWIFT_ID: ${{ inputs.swift-id }}
run: |
curl https://download.swift.org/$SWIFT_PREFIX/$SWIFT_ID.tar.gz \
--output ~/swift/swift.tar.gz
- name: Install Swift (Linux)
shell: bash
if: runner.os == 'Linux'
env:
SWIFT_ID: ${{ inputs.swift-id }}
run: |
mkdir ~/swift/$SWIFT_ID
tar -xzf ~/swift/swift.tar.gz -C ~/swift/$SWIFT_ID --strip 1
echo "SWIFT_INSTALLATION=$HOME/swift/$SWIFT_ID/usr" >> $GITHUB_ENV
echo "$HOME/swift/$SWIFT_ID/usr/bin" >> $GITHUB_PATH
### macOS-specific steps
### Please note, on macOS, the `swift-id` does not include the `-osx` suffix!
- name: Cache Swift toolchain (macOS)
id: cache_swift_macos
if: runner.os == 'macOS'
uses: actions/cache@v4
with:
path: "~/swift/swift.pkg"
key: "swift:${{ inputs.swift-id }}.pkg"
- name: Download Swift (macOS)
shell: bash
if: runner.os == 'macOS' && steps.cache_swift_macos.outputs.cache-hit != 'true'
env:
SWIFT_PREFIX: ${{ inputs.swift-prefix }}
SWIFT_ID: ${{ inputs.swift-id }}
run: |
curl https://download.swift.org/$SWIFT_PREFIX/$SWIFT_ID-osx.pkg \
--output ~/swift/swift.pkg
- name: Install Swift (macOS)
shell: bash
if: runner.os == 'macOS'
env:
SWIFT_ID: ${{ inputs.swift-id }}
run: |
sudo installer -pkg ~/swift/swift.pkg -target /
echo "SWIFT_INSTALLATION=/Library/Developer/Toolchains/$SWIFT_ID.xctoolchain/usr" >> $GITHUB_ENV
echo "TOOLCHAINS=$(plutil -extract CFBundleIdentifier raw \
/Library/Developer/Toolchains/$SWIFT_ID.xctoolchain/Info.plist)" >> $GITHUB_ENV
### End platform-specific steps
- name: Check Swift
shell: bash
run: |
$SWIFT_INSTALLATION/bin/swift --version
cat $GITHUB_PATH
swift --version