From fc2485e902c707a1b1e682e862eb623bbac04285 Mon Sep 17 00:00:00 2001 From: Lukas Pistrol Date: Fri, 17 May 2024 08:58:22 +0200 Subject: [PATCH 1/4] add workflow --- .github/workflows/update-swiftlint.yml | 49 ++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/update-swiftlint.yml diff --git a/.github/workflows/update-swiftlint.yml b/.github/workflows/update-swiftlint.yml new file mode 100644 index 0000000..41dc12e --- /dev/null +++ b/.github/workflows/update-swiftlint.yml @@ -0,0 +1,49 @@ +name: Update SwiftLint + +on: + schedule: + - cron: '0 0 * * 1' # Runs every Monday at midnight + workflow_dispatch: + +jobs: + update-swiftlint: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Get latest SwiftLint release + id: swiftlint_release + run: | + latest_release=$(curl --silent "https://api.github.com/repos/realm/SwiftLint/releases/latest" | jq -r '.tag_name') + echo "Latest release: $latest_release" + echo "::set-output name=latest_release::$latest_release" + + - name: Fetch SwiftLint binary URL and checksum + id: fetch_details + run: | + latest_release=${{ steps.swiftlint_release.outputs.latest_release }} + binary_url="https://github.com/realm/SwiftLint/releases/download/${latest_release}/SwiftLintBinary-macos.artifactbundle.zip" + checksum=$(curl -L $binary_url | shasum -a 256 | awk '{ print $1 }') + echo "Binary URL: $binary_url" + echo "Checksum: $checksum" + echo "::set-output name=binary_url::$binary_url" + echo "::set-output name=checksum::$checksum" + + - name: Update Swift Package + run: | + binary_url=${{ steps.fetch_details.outputs.binary_url }} + checksum=${{ steps.fetch_details.outputs.checksum }} + sed -i '' "s|url: \".*\"|url: \"$binary_url\"|" Package.swift + sed -i '' "s|checksum: \".*\"|checksum: \"$checksum\"|" Package.swift + + - name: Commit changes + run: | + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + git add Package.swift + git commit -m "Update SwiftLint to ${{ steps.swiftlint_release.outputs.latest_release }}" + git push + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 466da666920d091578d1ba5d4d9d84a9c00face7 Mon Sep 17 00:00:00 2001 From: Lukas Pistrol Date: Fri, 17 May 2024 09:02:20 +0200 Subject: [PATCH 2/4] enable test workflow --- .github/workflows/update-swiftlint.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/update-swiftlint.yml b/.github/workflows/update-swiftlint.yml index 41dc12e..daa69ba 100644 --- a/.github/workflows/update-swiftlint.yml +++ b/.github/workflows/update-swiftlint.yml @@ -4,6 +4,7 @@ on: schedule: - cron: '0 0 * * 1' # Runs every Monday at midnight workflow_dispatch: + pull_request: jobs: update-swiftlint: @@ -40,10 +41,10 @@ jobs: - name: Commit changes run: | - git config --global user.name 'github-actions[bot]' - git config --global user.email 'github-actions[bot]@users.noreply.github.com' - git add Package.swift - git commit -m "Update SwiftLint to ${{ steps.swiftlint_release.outputs.latest_release }}" - git push + # git config --global user.name 'github-actions[bot]' + # git config --global user.email 'github-actions[bot]@users.noreply.github.com' + # git add Package.swift + # git commit -m "Update SwiftLint to ${{ steps.swiftlint_release.outputs.latest_release }}" + # git push env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From e2255b7a65f2282fb60156f8a22d50bead083ec0 Mon Sep 17 00:00:00 2001 From: Lukas Pistrol Date: Fri, 17 May 2024 09:06:35 +0200 Subject: [PATCH 3/4] enable test workflow --- .github/workflows/update-swiftlint.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/update-swiftlint.yml b/.github/workflows/update-swiftlint.yml index daa69ba..cdcc3dd 100644 --- a/.github/workflows/update-swiftlint.yml +++ b/.github/workflows/update-swiftlint.yml @@ -36,9 +36,8 @@ jobs: run: | binary_url=${{ steps.fetch_details.outputs.binary_url }} checksum=${{ steps.fetch_details.outputs.checksum }} - sed -i '' "s|url: \".*\"|url: \"$binary_url\"|" Package.swift - sed -i '' "s|checksum: \".*\"|checksum: \"$checksum\"|" Package.swift - + sed -i 's|url: "https://github.com/realm/SwiftLint/releases/download/.*"|url: "'"${binary_url}"'"|' Package.swift + sed -i 's|checksum: ".*"|checksum: "'"${checksum}"'"|' Package.swift - name: Commit changes run: | # git config --global user.name 'github-actions[bot]' From 82f3e6582825fd7b54688392e57191eb1dcc3678 Mon Sep 17 00:00:00 2001 From: Lukas Pistrol Date: Fri, 17 May 2024 09:08:33 +0200 Subject: [PATCH 4/4] disable test functionality --- .github/workflows/update-swiftlint.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/update-swiftlint.yml b/.github/workflows/update-swiftlint.yml index cdcc3dd..26fcd7a 100644 --- a/.github/workflows/update-swiftlint.yml +++ b/.github/workflows/update-swiftlint.yml @@ -4,7 +4,6 @@ on: schedule: - cron: '0 0 * * 1' # Runs every Monday at midnight workflow_dispatch: - pull_request: jobs: update-swiftlint: @@ -40,10 +39,10 @@ jobs: sed -i 's|checksum: ".*"|checksum: "'"${checksum}"'"|' Package.swift - name: Commit changes run: | - # git config --global user.name 'github-actions[bot]' - # git config --global user.email 'github-actions[bot]@users.noreply.github.com' - # git add Package.swift - # git commit -m "Update SwiftLint to ${{ steps.swiftlint_release.outputs.latest_release }}" - # git push + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + git add Package.swift + git commit -m "Update SwiftLint to ${{ steps.swiftlint_release.outputs.latest_release }}" + git push env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}