-
Notifications
You must be signed in to change notification settings - Fork 2.2k
162 lines (159 loc) · 5.86 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
name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'Release version'
required: true
type: string
title:
description: 'Release title'
required: true
type: string
env:
DEVELOPER_DIR: /Applications/Xcode_16.2.app
MACOS_BUILD_DIR: .build/universal
LINUX_BUILD_DIR: .build/linux
RELEASE_BRANCH: release/${{ inputs.version }}
jobs:
prepare-release:
name: Prepare Release
runs-on: ubuntu-24.04
outputs:
author_name: ${{ steps.configure_git_author.outputs.name }}
author_uppercase: ${{ steps.retrieve_author.outputs.name }}
author_email: ${{ steps.configure_git_author.outputs.email }}
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Checkout or create release branch
run: |
if git ls-remote --exit-code --heads origin ${{ env.RELEASE_BRANCH }}; then
git fetch origin ${{ env.RELEASE_BRANCH }}:${{ env.RELEASE_BRANCH }}
git checkout ${{ env.RELEASE_BRANCH }}
else
git checkout -b ${{ env.RELEASE_BRANCH }}
fi
- name: Lint Podspec # Make sure Podspec still builds okay on CI with old release.
run: |
make pod_lint
grep -q 'DEVELOPER_DIR: ${{ env.DEVELOPER_DIR }}' .github/workflows/post-release.yml || echo "Xcode version not in sync with post-release workflow"
env:
DEVELOPER_DIR: /Applications/Xcode_15.0.1.app # Supports iOS 17.0 simulator selected by CocoaPods.
- 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: Retrieve author in uppercase
id: retrieve_author
run: |
AUTHOR=$(echo ${{ github.actor }} | tr '[:lower:]' '[:upper:]')
echo "name=${AUTHOR}" >> "$GITHUB_OUTPUT"
- name: Configure Git author
id: configure_git_author
uses: Homebrew/actions/git-user-config@master
with:
token: ${{ secrets[format('PERSONAL_GITHUB_TOKEN_{0}', steps.retrieve_author.outputs.name)] }}
- name: Configure author
run: |
git config --local user.name "${{ steps.configure_git_author.outputs.name }}"
git config --local user.email "${{ steps.configure_git_author.outputs.email }}"
- name: Commit changes
id: pre_release
run: |
git commit -a -m "Prepare ${{ inputs.version }} release"
git push origin HEAD
build-docker:
name: Build Linux Binaries
needs: prepare-release
uses: ./.github/workflows/docker.yml
permissions:
contents: read
packages: write
secrets: inherit
with:
ref: release/${{ inputs.version }}
tag: ${{ inputs.version }}
build-macos:
name: Build macOS Binaries
needs: prepare-release
runs-on: macOS-14
permissions:
contents: read
steps:
- uses: actions/checkout@v4
with:
ref: ${{ env.RELEASE_BRANCH }}
- name: Build SwiftLint for macOS
run: make --debug bazel_release
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: swiftlint
path: |
swiftlint
bazel.tar.gz
bazel.tar.gz.sha256
retention-days: 2
if-no-files-found: error
create-release:
name: Create Release
needs:
- prepare-release
- build-docker
- build-macos
runs-on: macOS-14
permissions:
actions: read
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ env.RELEASE_BRANCH }}
- name: Configure author
run: |
git config --local user.name "${{ needs.prepare-release.outputs.author_name }}"
git config --local user.email "${{ needs.prepare-release.outputs.author_email }}"
- name: Create build folders
run: mkdir -p ${{ env.MACOS_BUILD_DIR }} ${{ env.LINUX_BUILD_DIR }}
- name: Download binary artifact for macOS
uses: actions/download-artifact@v4
with:
name: swiftlint
path: ${{ env.MACOS_BUILD_DIR }}
- name: Download binary artifact for Linux
uses: actions/download-artifact@v4
with:
name: swiftlint_linux_amd64
path: ${{ env.LINUX_BUILD_DIR }}
- name: Move Bazel release
run: mv -f ${{ env.MACOS_BUILD_DIR }}/bazel.tar.gz ${{ env.MACOS_BUILD_DIR }}/bazel.tar.gz.sha256 .
- name: Make binaries executable
run: chmod +x ${{ env.MACOS_BUILD_DIR }}/swiftlint ${{ env.LINUX_BUILD_DIR }}/swiftlint_linux_amd64
- name: Create artifacts
run: |
make --debug spm_artifactbundle
make --debug package
make --debug portable_zip
make --debug zip_linux_release
- 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: ./tools/create-github-release.sh "${{ inputs.version }}"
env:
GITHUB_TOKEN: ${{ secrets[format('PERSONAL_GITHUB_TOKEN_{0}', needs.prepare-release.outputs.author_uppercase)] }}
- name: Add new changelog section
run: |
./tools/add-new-changelog-section.sh
git commit -a -m "Add new changelog section"
git push origin HEAD