Skip to content

Commit c8d37ac

Browse files
authored
Use Github actions for releases (#640)
* Setup for using GH actions for releases * Fix TAG detection * Simpler dev versioning * Target is defined in Package.swift * Cleanup
1 parent 5561552 commit c8d37ac

File tree

5 files changed

+67
-14
lines changed

5 files changed

+67
-14
lines changed

.github/workflows/checks.yml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,34 @@
11
name: Checks
22

33
on:
4+
push:
5+
branches: [ master ]
46
pull_request:
57
branches: '*'
68

79
jobs:
8-
run-all-tests:
10+
test:
911
runs-on: macos-latest
1012
steps:
1113
- name: Checkout
1214
uses: actions/checkout@v2
13-
- name: Run all tests w/fastlane
15+
- name: Test
1416
uses: maierj/fastlane-action@v1.4.0
1517
with:
16-
lane: 'runalltests'
17-
release-build:
18+
lane: runalltests
19+
20+
build:
1821
runs-on: macos-latest
1922
steps:
2023
- name: Checkout
2124
uses: actions/checkout@v2
22-
- name: Build release
23-
run: swift build -v -c release -Xswiftc "-target" -Xswiftc "x86_64-apple-macosx10.11"
24-
- name: Upload build
25-
uses: actions/upload-artifact@v1.0.0
25+
- name: Set version
26+
run: |
27+
sed -i "" "s/\(static let version = \"\)Unknown\(\"\)/\1Development build: ${GITHUB_SHA}\2/" Sources/rswift/Rswift.swift
28+
- name: Build
29+
run: swift build -v -c release
30+
- name: Store artifact
31+
uses: actions/upload-artifact@v1
2632
with:
27-
name: "Release binary"
33+
name: rswift-dev
2834
path: .build/release/rswift

.github/workflows/release.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types:
6+
- created
7+
8+
jobs:
9+
release-build:
10+
runs-on: macos-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v2
14+
15+
- name: Set version
16+
run: |
17+
sed -i "" "s/\(static let version = \"\).*\(\"\)/\1${TAG}\2/" Sources/rswift/Rswift.swift
18+
env:
19+
TAG: ${{ github.event.release.tag_name }}
20+
21+
- name: Test
22+
uses: maierj/fastlane-action@v1.4.0
23+
with:
24+
lane: runalltests
25+
26+
- name: Build
27+
run: swift build -v -c release
28+
- name: Archive
29+
run: zip --junk-paths ${{ runner.temp }}/archive.zip .build/release/rswift License
30+
- name: Upload
31+
uses: actions/upload-release-asset@v1
32+
with:
33+
upload_url: ${{ github.event.release.upload_url }}
34+
asset_path: ${{ runner.temp }}/archive.zip
35+
asset_name: rswift-${{ github.ref }}.zip
36+
asset_content_type: application/zip
37+
- name: Publish to Cocoapods
38+
run: pod trunk push
39+
env:
40+
POD_VERSION: ${{ github.event.release.tag_name }}
41+
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
42+
43+
- name: Store artifact
44+
uses: actions/upload-artifact@v1
45+
with:
46+
name: rswift-${{ github.ref }}
47+
path: .build/release/rswift

R.swift.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |spec|
22

33
spec.name = "R.swift"
4-
spec.version = "5.2.0"
4+
spec.version = ENV['POD_VERSION'].slice!(0)
55
spec.license = "MIT"
66

77
spec.summary = "Get strong typed, autocompleted resources like images, fonts and segues in Swift projects"
@@ -21,7 +21,7 @@ Pod::Spec.new do |spec|
2121
spec.social_media_url = "https://twitter.com/mac_cain13"
2222

2323
spec.requires_arc = true
24-
spec.source = { :http => "https://github.com/mac-cain13/R.swift/releases/download/v#{spec.version}/rswift-#{spec.version}.zip" }
24+
spec.source = { :http => "https://github.com/mac-cain13/R.swift/releases/download/v#{spec.version}/rswift-v#{spec.version}.zip" }
2525
spec.swift_version = "5.1"
2626

2727
spec.ios.deployment_target = '8.0'

Sources/rswift/Rswift.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
import Foundation
1111

1212
struct Rswift {
13-
static let version = "5.2.0"
13+
static let version = "Unknown"
1414
static let lastRunFile = "rswift-lastrun"
1515
}

fastlane/Fastfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ lane :release do |options|
5353
UI.message "Skipping tests!".yellow
5454
end
5555

56-
sh "cd .. && swift build -c release -Xswiftc \"-target\" -Xswiftc \"x86_64-apple-macosx10.11\""
56+
sh "cd .. && swift build -c release"
5757

5858
zipPath = "/tmp/rswift-#{newVersion}.zip"
5959
sh "rm -f #{zipPath}"
@@ -97,7 +97,7 @@ desc "Runs all the tests"
9797
lane :runalltests do
9898
cocoapods(repo_update: false)
9999

100-
sh "cd .. && swift test -Xswiftc \"-target\" -Xswiftc \"x86_64-apple-macosx10.11\" && mkdir -p build/debug && cp .build/debug/rswift build/debug"
100+
sh "cd .. && swift test && mkdir -p build/debug && cp .build/debug/rswift build/debug"
101101

102102
scan(
103103
workspace: "ResourceApp.xcworkspace",

0 commit comments

Comments
 (0)