-
Notifications
You must be signed in to change notification settings - Fork 2.2k
130 lines (127 loc) · 4.52 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
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
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Create release branch
run: git checkout ${{ env.RELEASE_BRANCH }} || git checkout -b ${{ env.RELEASE_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 "github-actions[bot]"
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
- 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
secrets: inherit
with:
ref: release/${{ inputs.version }}
tag: ${{ inputs.version }}
build-macos:
name: Build macOS Binaries
needs: prepare-release
runs-on: macOS-14
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:
- build-docker
- build-macos
runs-on: macOS-14
steps:
- uses: actions/checkout@v4
with:
ref: ${{ env.RELEASE_BRANCH }}
- name: Configure author
run: |
git config --local user.name "github-actions[bot]"
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
- 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: Retrieve author in uppercase
id: retrieve_author
run: |
AUTHOR=$(echo ${{ github.actor }} | tr '[:lower:]' '[:upper:]')
echo "name=${AUTHOR}" >> $GITHUB_OUTPUT
- name: Create release
run: ./tools/create-github-release.sh "${{ inputs.version }}"
env:
GITHUB_TOKEN: ${{ secrets[format('PERSONAL_GITHUB_TOKEN_{0}', steps.retrieve_author.outputs.name)] }}
- name: Add new changelog section
run: |
./tools/add-new-changelog-section.sh
git commit -a -m "Add new changelog section"
git push origin HEAD