-
Notifications
You must be signed in to change notification settings - Fork 2.2k
200 lines (197 loc) · 6.7 KB
/
release.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'Release version'
required: true
type: string
title:
description: 'Release title'
required: true
type: string
branch:
description: 'Release branch'
required: false
type: string
default: 'main'
env:
DEVELOPER_DIR: /Applications/Xcode_16.2.app
jobs:
prepare-release:
runs-on: ubuntu-latest
outputs:
pre_release_sha: ${{ steps.pre_release.outputs.pre_release_sha }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Create release branch
if: inputs.branch != 'main'
run: git checkout -b ${{ inputs.branch }}
- name: Update changelog
run: "sed -i 's/## Main/## ${{ inputs.version }}: ${{ inputs.title }}/g' CHANGELOG.md"
- name: Update built-in versions
run: |
sed 's/__VERSION__/${{ inputs.version }}/g' tools/Version.swift.template > Source/SwiftLintFramework/Models/Version.swift
sed -i -e '3s/.*/ version = "${{ inputs.version }}",/' MODULE.bazel
- name: Configure author
run: |
git config --local user.name "Danny Mösch"
git config --local user.email "[email protected]"
- name: Commit changes
id: pre_release
run: |
git commit -a -m "Prepare ${{ inputs.version }} release"
echo "pre_release_sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
git push origin HEAD
build-docker:
needs: prepare-release
uses: ./.github/workflows/docker.yml
secrets: inherit
with:
sha: ${{ needs.prepare-release.outputs.pre_release_sha }}
tag: ${{ inputs.version }}
build-macos:
needs: prepare-release
runs-on: macOS-14
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
- name: Build SwiftLint for macOS
run: make build
- name: Upload binary as artifact
uses: actions/upload-artifact@v4
with:
name: swiftlint
path: .build/universal/swiftlint
retention-days: 2
create-release:
needs:
- build-docker
- build-macos
runs-on: macOS-14
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
- name: Configure author
run: |
git config --local user.name "Danny Mösch"
git config --local user.email "[email protected]"
- name: Create build folders
run: mkdir -p .build/universal .build/linux
- name: Download binary artifact for macOS
uses: actions/download-artifact@v4
with:
name: swiftlint
path: .build/universal
- name: Download binary artifact for Linux
uses: actions/download-artifact@v4
with:
name: swiftlint_linux_amd64
path: .build/linux
- name: Make binary executable
run: chmod +x .build/universal/swiftlint .build/linux/swiftlint_linux_amd64
- name: List downloaded files
run: tree .build
- name: Create SPM artifact bundle
run: make --debug spm_artifactbundle
- name: Update binary target in Swift package
run: ./tools/update-artifact-bundle.sh "${{ inputs.version }}"
- name: Create tag and release commit
run: |
git commit -a -m "Release ${{ inputs.version }}"
git tag -a ${{ inputs.version }} -m "${{ inputs.title }}"
git push origin HEAD
git push origin ${{ inputs.version }}
- name: Create release
run: |
release_notes=$(mktemp)
./tools/generate-release-notes.sh "${{ inputs.version }}" > "$release_notes"
gh release create ${{ inputs.version }} --title ${{ inputs.title }} -F "$release_notes" --draft
rm "$release_notes"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload artifact bundle to release
run: gh release upload ${{ inputs.version }} SwiftLintBinary.artifactbundle.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
upload-package:
needs: create-release
runs-on: macOS-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.version }}
- name: Create package
run: make package
- name: Upload package to existing release
run: gh release upload ${{ inputs.version }} SwiftLint.pkg
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
upload-bazel:
needs: create-release
runs-on: macOS-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.version }}
- name: Create Bazel release
run: make bazel_release
- name: Upload Bazel release to existing release
run: gh release upload ${{ inputs.version }} bazel.tar.gz bazel.tar.gz.sha256
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
upload-portable-zip:
needs: create-release
runs-on: macOS-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.version }}
- name: Create portable ZIP
run: make portable_zip
- name: Upload portable ZIP to existing release
run: gh release upload ${{ inputs.version }} portable_swiftlint.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-pod:
needs: create-release
runs-on: macOS-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.version }}
- name: Retrieve author in uppercase
id: retrieve_author
run: |
AUTHOR=$(echo ${{ github.actor }} | tr '[:lower:]' '[:upper:]')
echo "name=${AUTHOR}" >> $GITHUB_OUTPUT
- name: Deploy to CocoaPods
run: make pod_publish
env:
COCOAPODS_TRUNK_TOKEN: ${{ secrets[format('COCOAPODS_TRUNK_TOKEN_{0}', steps.retrieve_author.outputs.name)] }}
dispatch-plugins:
needs: create-release
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ inputs.version }}
- name: Parse checksum
id: parse_checksum
run: echo "checksum=$(grep -o '[a-fA-F0-9]\{64\}' Package.swift)" >> $GITHUB_OUTPUT
- name: Dispatch release of plugins package
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.SIMPLYDANNY_PLUGINS_SYNC }}
repository: SimplyDanny/SwiftLintPlugins
event-type: swiftlint-release
client-payload: |-
{
"title": "${{ inputs.title }}",
"tag": "${{ inputs.version }}",
"checksum": "${{ steps.parse_checksum.outputs.checksum }}"
}