Release #22
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.event.sender.name }}" | |
git config --local user.email "${{ github.event.sender.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 | |
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.event.sender.login }} | 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 |