Merge pull request #1 from spotify/add-workflows
Add Github workflows CI
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
name: CI
|
||||
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
SwiftLint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: SwiftLint
|
||||
uses: norio-nomura/action-swiftlint@3.1.0
|
||||
|
||||
macOS:
|
||||
runs-on: macOS-latest
|
||||
env:
|
||||
XCODE_VERSION: ${{ '12.4' }}
|
||||
steps:
|
||||
- name: Select Xcode
|
||||
run: "sudo xcode-select -s /Applications/Xcode_$XCODE_VERSION.app"
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v1
|
||||
- name: Build and Run
|
||||
run: rake build[release]
|
||||
- name: Test
|
||||
run: rake test
|
||||
@@ -0,0 +1,46 @@
|
||||
name: release_binaries
|
||||
on:
|
||||
release:
|
||||
types: created
|
||||
|
||||
jobs:
|
||||
macOS:
|
||||
name: Add macOS binaries to release
|
||||
runs-on: macOS-latest
|
||||
env:
|
||||
XCODE_VERSION: ${{ '12.4' }}
|
||||
steps:
|
||||
- name: Select Xcode
|
||||
run: "sudo xcode-select -s /Applications/Xcode_$XCODE_VERSION.app"
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v1
|
||||
- name: Set tag name
|
||||
run: echo "TAG_NAME=$(echo $GITHUB_REF | cut -c 11-)" >> $GITHUB_ENV
|
||||
- name: Build x86_64-apple-macosx
|
||||
run: "rake 'build[release, x86_64-apple-macosx]'"
|
||||
- name: Save x86_64 executable to be lipo'd later
|
||||
run: "mkdir -p tmp && unzip releases/XCRemoteCache.zip -d tmp/xcremotecache-x86_64"
|
||||
- name: Clean releases dir to not conflict with other archs
|
||||
run: "rm -rf releases"
|
||||
- name: Build arm64-apple-macosx
|
||||
run: "rake 'build[release, arm64-apple-macosx]'"
|
||||
- name: Save arm64 executable to be lipo'd later
|
||||
run: "mkdir -p tmp && unzip releases/XCRemoteCache.zip -d tmp/xcremotecache-arm64"
|
||||
- name: Clean releases dir to not conflict with other files to attach
|
||||
run: "rm -rf releases"
|
||||
- name: Zip x86_64-apple-macosx release
|
||||
run: "mkdir -p releases && zip -jr releases/XCRemoteCache-macOS-x86_64-$TAG_NAME.zip LICENSE README.md tmp/xcremotecache-x86_64"
|
||||
- name: Zip arm64-apple-macosx release
|
||||
run: "zip -jr releases/XCRemoteCache-macOS-arm64-$TAG_NAME.zip LICENSE README.md tmp/xcremotecache-arm64"
|
||||
- name: Lipo macOS executables
|
||||
run: "mkdir -p tmp/xcremotecache && ls tmp/xcremotecache-x86_64 | xargs -I {} lipo -create -output tmp/xcremotecache/{} tmp/xcremotecache-x86_64/{} tmp/xcremotecache-arm64/{}"
|
||||
- name: Zip x86_64-arm64-apple-macosx release
|
||||
run: "zip -jr releases/XCRemoteCache-macOS-arm64-x86_64-$TAG_NAME.zip LICENSE README.md tmp/xcremotecache"
|
||||
- name: Upload binaries to release
|
||||
uses: svenstaro/upload-release-action@v1-release
|
||||
with:
|
||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
file: releases/*
|
||||
file_glob: true
|
||||
tag: ${{ github.ref }}
|
||||
overwrite: true
|
||||
@@ -4,3 +4,5 @@
|
||||
/*.xcodeproj
|
||||
DerivedData
|
||||
/.swiftpm/
|
||||
releases
|
||||
tmp/
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
XCRemoteCache is a remote cache tool for Xcode projects. It reuses target artifacts generated on a remote machine, served from a simple REST server.
|
||||
|
||||
[](https://github.com/spotify/XCRemoteCache/workflows/CI/badge.svg)
|
||||
[](LICENSE)
|
||||
|
||||
## How and Why?
|
||||
|
||||
@@ -1,32 +1,15 @@
|
||||
# encoding: utf-8
|
||||
require 'open-uri'
|
||||
require 'shellwords'
|
||||
|
||||
################################
|
||||
# Rake configuration
|
||||
################################
|
||||
|
||||
# Make sure environment is UTF-8 (CI sometimes thinks it's ASCII)
|
||||
ENV['LANG'] = 'en_US.UTF-8'
|
||||
ENV['LANGUAGE'] = 'en_US.UTF-8'
|
||||
ENV['LC_ALL'] = 'en_US.UTF-8'
|
||||
Encoding.default_external = Encoding::UTF_8
|
||||
Encoding.default_internal = Encoding::UTF_8
|
||||
|
||||
# Environment variables (you can override those by adding parameters
|
||||
# to task definitions in buildconf/tasks)
|
||||
CONFIG = ENV['CONFIG'] || 'debug'
|
||||
CI = !!ENV['TEAMCITY_VERSION']
|
||||
GIT_REF = ENV['GITHUB_REF']
|
||||
|
||||
# Paths
|
||||
DERIVED_DATA_DIR = File.join('.build').freeze
|
||||
RELEASES_ROOT_DIR = File.join('releases').freeze
|
||||
|
||||
EXECUTABLE_NAME = 'XCRemoteCache'
|
||||
EXECUTABLE_NAMES = ['xclibtool', 'xcpostbuild', 'xcprebuild', 'xcprepare', 'xcswiftc', 'xcld']
|
||||
SCHEME = 'XCRemoteCacheApp'
|
||||
TEST_SCHEME = 'XCRemoteCacheTests'
|
||||
PROJECT_NAME = 'XCRemoteCache'
|
||||
|
||||
SWIFTLINT_ENABLED = true
|
||||
@@ -56,9 +39,9 @@ task :autocorrect => [:prepare] do
|
||||
end
|
||||
|
||||
desc 'build package artifacts'
|
||||
task :build, [:configuration, :sdks] do |task, args|
|
||||
task :build, [:configuration, :arch, :sdks, :is_archive] do |task, args|
|
||||
# Set task defaults
|
||||
args.with_defaults(:configuration => CONFIG.downcase, :sdks => ['macos'])
|
||||
args.with_defaults(:configuration => 'debug', :sdks => ['macos'])
|
||||
|
||||
unless args.configuration == 'Debug'.downcase || args.configuration == 'Release'.downcase
|
||||
fail("Unsupported configuration. Valid values: ['Debug', 'Release']. Found '#{args.configuration}''")
|
||||
@@ -71,7 +54,7 @@ task :build, [:configuration, :sdks] do |task, args|
|
||||
# Build
|
||||
build_paths = []
|
||||
args.sdks.each do |sdk|
|
||||
spm_build(args.configuration)
|
||||
spm_build(args.configuration, args.arch)
|
||||
|
||||
# Path of the executable looks like: `.build/(debug|release)/XCRemoteCache`
|
||||
build_path_base = File.join(DERIVED_DATA_DIR, args.configuration)
|
||||
@@ -84,7 +67,7 @@ task :build, [:configuration, :sdks] do |task, args|
|
||||
|
||||
if args.configuration == 'Release'.downcase
|
||||
puts "Creating release zip"
|
||||
package = create_release_zip(build_paths[0])
|
||||
create_release_zip(build_paths[0])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -98,15 +81,15 @@ end
|
||||
# Helper functions
|
||||
################################
|
||||
|
||||
def spm_build(configuration)
|
||||
def spm_build(configuration, arch)
|
||||
spm_cmd = "swift build "\
|
||||
"-c #{configuration}"
|
||||
"-c #{configuration} "\
|
||||
"#{arch.nil? ? "" : "--triple #{arch}"} "
|
||||
system(spm_cmd) or abort "Build failure"
|
||||
end
|
||||
|
||||
def bash(command)
|
||||
escaped_command = Shellwords.escape(command)
|
||||
system "bash -c #{escaped_command}"
|
||||
system "bash -c \"#{command}\""
|
||||
end
|
||||
|
||||
def spm_test()
|
||||
@@ -120,21 +103,21 @@ end
|
||||
|
||||
def create_release_zip(build_paths)
|
||||
release_dir = RELEASES_ROOT_DIR
|
||||
output_artifact_basename = "#{PROJECT_NAME}.zip"
|
||||
library_file = File.join(release_dir, output_artifact_basename)
|
||||
|
||||
|
||||
# Create and move files into the release directory
|
||||
mkdir_p release_dir
|
||||
build_paths.each {|p|
|
||||
cp_r p, release_dir
|
||||
}
|
||||
|
||||
output_artifact_basename = "#{PROJECT_NAME}.zip"
|
||||
|
||||
Dir.chdir(release_dir) do
|
||||
# -X: no extras (uid, gid, file times, ...)
|
||||
# -x: exclude .DS_Store
|
||||
# -r: recursive
|
||||
system("zip -X -r #{output_artifact_basename} .") or abort "zip failure"
|
||||
system("zip -X -x '*.DS_Store' -r #{output_artifact_basename} .") or abort "zip failure"
|
||||
# List contents of zip file
|
||||
system("unzip -l #{output_artifact_basename}") or abort "unzip failure"
|
||||
end
|
||||
library_file
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user