Skip to content

Document workflow YAML anchors refactoring in CHANGELOG #61

Document workflow YAML anchors refactoring in CHANGELOG

Document workflow YAML anchors refactoring in CHANGELOG #61

Workflow file for this run

name: Release

Check failure on line 1 in .github/workflows/release.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/release.yml

Invalid workflow file

(Line: 20, Col: 1): Unexpected value 'x-checkout-step', (Line: 25, Col: 1): Unexpected value 'x-checkout-release-branch', (Line: 31, Col: 1): Unexpected value 'x-upload-artifact', (Line: 87, Col: 9): Unexpected value '<<', (Line: 86, Col: 9): There's not enough info to determine what you meant. Add one of these properties: run, shell, uses, with, working-directory, (Line: 119, Col: 9): Unexpected value '<<', (Line: 119, Col: 9): There's not enough info to determine what you meant. Add one of these properties: run, shell, uses, with, working-directory, (Line: 125, Col: 9): Unexpected value '<<', (Line: 124, Col: 9): Required property is missing: uses, (Line: 151, Col: 9): Unexpected value '<<'
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_26.0.1.app
RELEASE_BRANCH: release/${{ inputs.version }}
# Common reusable configurations
x-checkout-step: &checkout-step
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
x-checkout-release-branch: &checkout-release-branch
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
ref: ${{ env.RELEASE_BRANCH }}
persist-credentials: false
x-upload-artifact: &upload-artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
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@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.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
<<: *checkout-step
- name: Set up Ruby and Bundler
uses: ruby/setup-ruby@ab177d40ee5483edb974554986f56b33477e21d0 # v1.265.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:
- <<: *checkout-release-branch
- 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
<<: *upload-artifact
with:
name: ${{ matrix.artifact_name }}
path: .build/release/swiftlint
build-static-linux:
name: Build Static Linux ${{ matrix.arch }} Binary
needs: prepare-release
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:
- <<: *checkout-release-branch
- name: Install SDK
run: swift sdk install https://download.swift.org/swift-6.2-release/static-sdk/swift-6.2-RELEASE/swift-6.2-RELEASE_static-linux-0.0.1.artifactbundle.tar.gz --checksum d2225840e592389ca517bbf71652f7003dbf45ac35d1e57d98b9250368769378
- name: Build static binary
run: |
swift build \
-c release \
--product swiftlint \
--swift-sdk ${{ matrix.swift_sdk }} \
-Xswiftc -DSWIFTLINT_DISABLE_SOURCEKIT \
-Xlinker -z -Xlinker stack-size=0x80000 # 512KiB
- name: Strip binary
run: strip -s "$BINARY_PATH"
- name: Upload artifact
<<: *upload-artifact
with:
name: ${{ matrix.artifact_name }}
path: ${{ env.BINARY_PATH }}
build-macos:
name: Build macOS Binaries
needs: prepare-release
runs-on: macOS-26
permissions:
contents: read
steps:
- <<: *checkout-release-branch
- name: Build SwiftLint for macOS
run: make --debug bazel_release
- name: Upload build artifacts
<<: *upload-artifact
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-26
permissions:
actions: read
contents: write
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.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@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.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