mirror of
https://github.com/realm/SwiftLint.git
synced 2026-05-07 20:12:49 +00:00
234 lines
8.3 KiB
YAML
234 lines
8.3 KiB
YAML
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
|
|
RELEASE_BRANCH: release/${{ inputs.version }}
|
|
|
|
jobs:
|
|
setup-credentials:
|
|
name: Setup Actor Credentials
|
|
uses: ./.github/workflows/actor-credentials.yml
|
|
with:
|
|
actor: ${{ github.actor }}
|
|
permissions:
|
|
contents: write
|
|
secrets: inherit
|
|
|
|
prepare-release:
|
|
name: Prepare Release
|
|
runs-on: ubuntu-24.04
|
|
needs: setup-credentials
|
|
permissions:
|
|
contents: write
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
|
with:
|
|
persist-credentials: true
|
|
- 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: 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
|
|
sed -i -e "s/^\(\s*s\.version\s*=\s*'\)[^']*'/\1${{ inputs.version }}'/" SwiftLint.podspec
|
|
- name: Configure Git author
|
|
uses: Homebrew/actions/git-user-config@main
|
|
with:
|
|
token: ${{ secrets[format('PERSONAL_GITHUB_TOKEN_{0}', needs.setup-credentials.outputs.author_uppercase)] }}
|
|
- name: Commit changes
|
|
id: pre_release
|
|
run: |
|
|
git commit -a -m "Prepare ${{ inputs.version }} release"
|
|
git push origin HEAD
|
|
|
|
verify-podspec:
|
|
name: Verify Podspec
|
|
runs-on: macOS-14
|
|
permissions:
|
|
contents: read
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
|
with:
|
|
persist-credentials: false
|
|
- name: Set up Ruby and Bundler
|
|
uses: ruby/setup-ruby@44511735964dcb71245e7e55f72539531f7bc0eb # v1.257.0
|
|
with:
|
|
bundler-cache: true
|
|
- name: Lint Podspec # Make sure Podspec still builds okay on CI with old release.
|
|
run: |
|
|
if ! grep -q 'DEVELOPER_DIR: ${{ env.DEVELOPER_DIR }}' .github/workflows/post-release.yml; then
|
|
echo "ERROR: Xcode version not in sync with post-release workflow"
|
|
exit 1
|
|
fi
|
|
make pod_lint
|
|
env:
|
|
DEVELOPER_DIR: /Applications/Xcode_15.0.1.app # Supports iOS 17.0 simulator selected by CocoaPods.
|
|
|
|
build-linux:
|
|
name: Build Linux ${{ matrix.arch }} Binary
|
|
needs: prepare-release
|
|
runs-on: ${{ matrix.runner }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- arch: AMD64
|
|
runner: ubuntu-24.04
|
|
artifact_name: swiftlint-linux-amd64
|
|
- arch: ARM64
|
|
runner: ubuntu-24.04-arm
|
|
artifact_name: swiftlint-linux-arm64
|
|
permissions:
|
|
contents: read
|
|
steps:
|
|
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
|
with:
|
|
ref: ${{ env.RELEASE_BRANCH }}
|
|
persist-credentials: false
|
|
- name: Install dependencies
|
|
run: sudo apt-get install -y libcurl4-openssl-dev libxml2-dev
|
|
- name: Build binary
|
|
run: make --debug spm_linux_build
|
|
- name: Upload binary
|
|
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
|
with:
|
|
name: ${{ matrix.artifact_name }}
|
|
path: .build/release/swiftlint
|
|
|
|
build-static-linux:
|
|
name: Build Static Linux ${{ matrix.arch }} Binary
|
|
runs-on: ${{ matrix.runner }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- arch: ARM64
|
|
runner: ubuntu-24.04-arm
|
|
swift_sdk: aarch64-swift-linux-musl
|
|
artifact_name: swiftlint-static-arm64
|
|
- arch: AMD64
|
|
runner: ubuntu-24.04
|
|
swift_sdk: x86_64-swift-linux-musl
|
|
artifact_name: swiftlint-static-amd64
|
|
permissions:
|
|
contents: read
|
|
env:
|
|
BINARY_PATH: .build/${{ matrix.swift_sdk }}/release/swiftlint
|
|
steps:
|
|
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
|
with:
|
|
persist-credentials: false
|
|
- name: Install SDK
|
|
run: swift sdk install https://download.swift.org/swift-6.1.2-release/static-sdk/swift-6.1.2-RELEASE/swift-6.1.2-RELEASE_static-linux-0.0.1.artifactbundle.tar.gz --checksum df0b40b9b582598e7e3d70c82ab503fd6fbfdff71fd17e7f1ab37115a0665b3b
|
|
- name: Build static binary
|
|
run: swift build -c release --product swiftlint --swift-sdk ${{ matrix.swift_sdk }} -Xswiftc -DSWIFTLINT_DISABLE_SOURCEKIT
|
|
- name: Strip binary
|
|
run: strip -s "$BINARY_PATH"
|
|
- name: Upload artifact
|
|
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
|
with:
|
|
name: ${{ matrix.artifact_name }}
|
|
path: ${{ env.BINARY_PATH }}
|
|
|
|
build-macos:
|
|
name: Build macOS Binaries
|
|
needs: prepare-release
|
|
runs-on: macOS-14
|
|
permissions:
|
|
contents: read
|
|
steps:
|
|
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
|
with:
|
|
ref: ${{ env.RELEASE_BRANCH }}
|
|
persist-credentials: false
|
|
- name: Build SwiftLint for macOS
|
|
run: make --debug bazel_release
|
|
- name: Upload build artifacts
|
|
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
|
with:
|
|
name: swiftlint-macos
|
|
path: |
|
|
swiftlint
|
|
bazel.tar.gz
|
|
bazel.tar.gz.sha256
|
|
retention-days: 2
|
|
if-no-files-found: error
|
|
|
|
create-release:
|
|
name: Create Release
|
|
needs:
|
|
- setup-credentials
|
|
- prepare-release
|
|
- build-linux
|
|
- build-static-linux
|
|
- build-macos
|
|
runs-on: macOS-14
|
|
permissions:
|
|
actions: read
|
|
contents: write
|
|
steps:
|
|
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
|
with:
|
|
ref: ${{ env.RELEASE_BRANCH }}
|
|
persist-credentials: true
|
|
- name: Configure author
|
|
uses: Homebrew/actions/git-user-config@main
|
|
with:
|
|
token: ${{ secrets[format('PERSONAL_GITHUB_TOKEN_{0}', needs.setup-credentials.outputs.author_uppercase)] }}
|
|
- name: Download binary artifacts
|
|
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
|
- name: Move artifacts
|
|
run: |
|
|
mv -f swiftlint-macos/* .
|
|
mv -f swiftlint-linux-amd64/swiftlint swiftlint_linux_amd64
|
|
mv -f swiftlint-linux-arm64/swiftlint swiftlint_linux_arm64
|
|
mv -f swiftlint-static-amd64/swiftlint swiftlint_static_amd64
|
|
mv -f swiftlint-static-arm64/swiftlint swiftlint_static_arm64
|
|
- name: Make binaries executable
|
|
run: chmod +x swiftlint*
|
|
- 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.setup-credentials.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
|