├── .github ├── CODEOWNERS ├── dependabot.yml └── workflows │ └── test.yml ├── .gitignore ├── LICENSE ├── README.md └── action.yml /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @gwynne 2 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "github-actions" 4 | directory: "/" 5 | schedule: 6 | interval: "weekly" 7 | groups: 8 | dependencies: 9 | patterns: 10 | - "*" 11 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: test 2 | concurrency: 3 | group: ${{ github.workflow }}-${{ github.ref }} 4 | cancel-in-progress: true 5 | on: 6 | push: { branches: [ main ] } 7 | pull_request: { types: [opened, reopened, synchronize, ready_for_review] } 8 | 9 | jobs: 10 | test: 11 | strategy: 12 | fail-fast: false 13 | matrix: 14 | base-image: 15 | - ubuntu:focal 16 | - ubuntu:jammy 17 | - ubuntu:noble 18 | - debian:bookworm 19 | - fedora:39 20 | - redhat/ubi9:latest 21 | test-args: 22 | - '{}' 23 | - '{"toolchain":"latest"}' 24 | - '{"toolchain":"5.10"}' 25 | - '{"toolchain":"6.0"}' 26 | runs-on: ubuntu-latest 27 | container: ${{ matrix.base-image }} 28 | steps: 29 | - name: Test 30 | uses: vapor/swiftly-action@main 31 | with: ${{ fromJSON(matrix.test-args) }} 32 | test-amznlinux2: 33 | strategy: 34 | fail-fast: false 35 | matrix: 36 | base-image: 37 | - amazonlinux:2 38 | test-args: 39 | - '{}' 40 | - '{"toolchain":"latest"}' 41 | - '{"toolchain":"5.10"}' 42 | - '{"toolchain":"6.0"}' 43 | runs-on: ubuntu-latest 44 | container: ${{ matrix.base-image }} 45 | steps: 46 | - name: Add missing dependencies 47 | run: yum install -y git tar 48 | - name: Test 49 | uses: vapor/swiftly-action@main 50 | with: ${{ fromJSON(matrix.test-args) }} 51 | test-barerunner: 52 | strategy: 53 | fail-fast: false 54 | matrix: 55 | test-args: 56 | - '{}' 57 | - '{"toolchain":"latest"}' 58 | - '{"toolchain":"5.10"}' 59 | - '{"toolchain":"6.0"}' 60 | runs-on: ubuntu-latest 61 | steps: 62 | - name: Test 63 | uses: vapor/swiftly-action@main 64 | with: ${{ fromJSON(matrix.test-args) }} 65 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | .pnpm-debug.log* 9 | 10 | # Diagnostic reports (https://nodejs.org/api/report.html) 11 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 12 | 13 | # Runtime data 14 | pids 15 | *.pid 16 | *.seed 17 | *.pid.lock 18 | 19 | # Directory for instrumented libs generated by jscoverage/JSCover 20 | lib-cov 21 | 22 | # Coverage directory used by tools like istanbul 23 | coverage 24 | *.lcov 25 | 26 | # nyc test coverage 27 | .nyc_output 28 | 29 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 30 | .grunt 31 | 32 | # Bower dependency directory (https://bower.io/) 33 | bower_components 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (https://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules/ 43 | jspm_packages/ 44 | 45 | # Snowpack dependency directory (https://snowpack.dev/) 46 | web_modules/ 47 | 48 | # TypeScript cache 49 | *.tsbuildinfo 50 | 51 | # Optional npm cache directory 52 | .npm 53 | 54 | # Optional eslint cache 55 | .eslintcache 56 | 57 | # Optional stylelint cache 58 | .stylelintcache 59 | 60 | # Microbundle cache 61 | .rpt2_cache/ 62 | .rts2_cache_cjs/ 63 | .rts2_cache_es/ 64 | .rts2_cache_umd/ 65 | 66 | # Optional REPL history 67 | .node_repl_history 68 | 69 | # Output of 'npm pack' 70 | *.tgz 71 | 72 | # Yarn Integrity file 73 | .yarn-integrity 74 | 75 | # dotenv environment variable files 76 | .env 77 | .env.development.local 78 | .env.test.local 79 | .env.production.local 80 | .env.local 81 | 82 | # parcel-bundler cache (https://parceljs.org/) 83 | .cache 84 | .parcel-cache 85 | 86 | # Next.js build output 87 | .next 88 | out 89 | 90 | # Nuxt.js build / generate output 91 | .nuxt 92 | dist 93 | 94 | # Gatsby files 95 | .cache/ 96 | # Comment in the public line in if your project uses Gatsby and not Next.js 97 | # https://nextjs.org/blog/next-9-1#public-directory-support 98 | # public 99 | 100 | # vuepress build output 101 | .vuepress/dist 102 | 103 | # vuepress v2.x temp and cache directory 104 | .temp 105 | .cache 106 | 107 | # Docusaurus cache and generated files 108 | .docusaurus 109 | 110 | # Serverless directories 111 | .serverless/ 112 | 113 | # FuseBox cache 114 | .fusebox/ 115 | 116 | # DynamoDB Local files 117 | .dynamodb/ 118 | 119 | # TernJS port file 120 | .tern-port 121 | 122 | # Stores VSCode versions used for testing VSCode extensions 123 | .vscode-test 124 | 125 | # yarn v2 126 | .yarn/cache 127 | .yarn/unplugged 128 | .yarn/build-state.yml 129 | .yarn/install-state.gz 130 | .pnp.* 131 | 132 | .DS_Store -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Vapor 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # swiftly-action 2 | 3 | A GitHub Action for installing the [Swiftly toolchain manager for Swift](https://www.swift.org/swiftly). 4 | 5 | ## Usage 6 | 7 | To use Swiftly in your workflow, specify the repository followed by a tag as with any action: 8 | 9 | ```yaml 10 | steps: 11 | - uses: actions/checkout@v4 12 | - uses: vapor/swiftly-action@v0.2 13 | with: 14 | toolchain: latest # optional 15 | ``` 16 | 17 | On completion, `swiftly`'s executable will be present in `PATH`, and the `SWIFTLY_HOME_DIR` and `SWIFTLY_BIN_DIR` environment variables will be available to all following steps. 18 | 19 | ## Arguments 20 | 21 | At this time, the only argument supported is `toolchain`, which specifies a Swift toolchain name for Swiftly to install along with Swiftly itself. If the argument is omitted, only Swiftly itself is installed. 22 | 23 | ## Contributing 24 | 25 | Contributions are welcome! Check out Vapor's [Contribution Guide](https://github.com/vapor/.github/blob/main/CONTRIBUTING.md). 26 | 27 | ## License 28 | 29 | All code in this repository is released under the [MIT License](https://github.com/vapor/swiftly-action/blob/main/LICENSE). 30 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: Swiftly 2 | description: Install and invoke the Swiftly toolchain manager for Swift 3 | 4 | inputs: 5 | toolchain: 6 | required: false 7 | default: '' 8 | description: > 9 | A Swift toolchain version to install and select as the default. If omitted, Swiftly will be installed by itself. 10 | See https://swiftpackageindex.com/swiftlang/swiftly/1.0.0/documentation/swiftlydocs/install-toolchains for a description 11 | of how to specify a toolchain version. 12 | 13 | runs: 14 | using: composite 15 | steps: 16 | - id: platform-check 17 | name: Check that the current platform is supported 18 | shell: bash 19 | run: | 20 | case '${{ runner.os }}' in 21 | 'Windows') 22 | echo 'Swiftly does not yet support Windows.' 23 | exit 1 24 | ;; 25 | *) 26 | ;; 27 | esac 28 | 29 | - id: deps-install 30 | name: Make sure curl and gpg are available 31 | shell: bash 32 | run: | 33 | command -v curl >/dev/null || { 34 | if command -v apt-get >/dev/null; then 35 | apt-get update -q && apt-get install -qy curl 36 | elif command -v yum >/dev/null; then 37 | yum install -y curl 38 | else 39 | echo "curl is not installed and we couldn't figure out how to install it." 40 | exit 1 41 | fi 42 | } 43 | command -v gpg >/dev/null || { 44 | if command -v apt-get >/dev/null; then 45 | apt-get update -q && apt-get install -qy gpg 46 | elif command -v yum >/dev/null; then 47 | yum install -y gpg 48 | else 49 | echo "gpg is not installed and we couldn't figure out how to install it." 50 | exit 1 51 | fi 52 | } 53 | 54 | - id: swiftly-install 55 | name: Download and initialize Swiftly 56 | shell: bash 57 | run: | 58 | curl -O "https://download.swift.org/swiftly/linux/swiftly-$(uname -m).tar.gz" 59 | tar zxf "swiftly-$(uname -m).tar.gz" 60 | ./swiftly init --assume-yes --no-modify-profile --skip-install --quiet-shell-followup 61 | if [[ "$(id -un)" == 'root' ]]; then 62 | . /root/.local/share/swiftly/env.sh 63 | else 64 | . "/home/${USER}/.local/share/swiftly/env.sh" 65 | fi 66 | echo "SWIFTLY_HOME_DIR=${SWIFTLY_HOME_DIR}" >>"${GITHUB_ENV}" 67 | echo "SWIFTLY_BIN_DIR=${SWIFTLY_BIN_DIR}" >>"${GITHUB_ENV}" 68 | echo "${SWIFTLY_BIN_DIR}" >>"${GITHUB_PATH}" 69 | 70 | - id: toolchain-install 71 | name: Install requested Swift toolchain 72 | if: ${{ inputs.toolchain != '' }} 73 | shell: bash 74 | env: 75 | REQUESTED_TOOLCHAIN: ${{ inputs.toolchain }} 76 | run: | 77 | swiftly install --assume-yes --use --post-install-file "${HOME}/.swiftly-postinstall-cmds.sh" "${REQUESTED_TOOLCHAIN}" 78 | if [[ -f "${HOME}/.swiftly-postinstall-cmds.sh" ]]; then 79 | export DEBIAN_FRONTEND=noninteractive # prevent Debian/Ubuntu installs from hanging on tzdata 80 | if [[ "$(id -un)" == 'root' ]]; then 81 | . "${HOME}/.swiftly-postinstall-cmds.sh" 82 | else 83 | sudo bash -c ". '${HOME}/.swiftly-postinstall-cmds.sh'" # use the current value of HOME rather than the subshell's value 84 | fi 85 | rm "${HOME}/.swiftly-postinstall-cmds.sh" 86 | fi 87 | --------------------------------------------------------------------------------