Skip to content

Commit 1e6b394

Browse files
committed
Refactor autoupdate workflow
1 parent 023809f commit 1e6b394

2 files changed

Lines changed: 10 additions & 14 deletions

File tree

.github/FUNDING.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
github: [fenli]
22
buy_me_a_coffee: stevenlewi
3-
thanks_dev: gh/fenli
43
custom: ['https://www.paypal.com/ncp/payment/AW5VX3YV9C6QJ']

.github/workflows/autoupdate.yml

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,41 +13,38 @@ jobs:
1313
uses: actions/checkout@v4
1414

1515
- name: Check for latest release
16-
id: fetch_latest
1716
run: |
1817
latest_release=$(curl --silent "https://api.github.com/repos/krzysztofzablocki/Sourcery/releases/latest" | jq -r '.tag_name')
1918
echo "Latest release: $latest_release"
20-
echo "::set-output name=latest_release::$latest_release"
19+
echo "LATEST_RELEASE=$latest_release" >> $GITHUB_ENV
2120
2221
binary_url="https://github.com/krzysztofzablocki/Sourcery/releases/download/${latest_release}/sourcery-${latest_release}.artifactbundle.zip"
2322
checksum=$(curl -L $binary_url | shasum -a 256 | awk '{ print $1 }')
2423
echo "Binary URL: $binary_url"
2524
echo "Checksum: $checksum"
26-
echo "::set-output name=binary_url::$binary_url"
27-
echo "::set-output name=checksum::$checksum"
25+
echo "BINARY_URL=$binary_url" >> $GITHUB_ENV
26+
echo "BINARY_CHECKSUM=$checksum" >> $GITHUB_ENV
2827
2928
- name: Update Package.swift
30-
id: update_package_swift
29+
if: env.LATEST_RELEASE != 'null'
3130
run: |
32-
binary_url=${{ steps.fetch_latest.outputs.binary_url }}
33-
checksum=${{ steps.fetch_latest.outputs.checksum }}
34-
sed -i 's|url: "https://github.com/krzysztofzablocki/Sourcery/releases/download/.*"|url: "'"${binary_url}"'"|' Package.swift
35-
sed -i 's|checksum: ".*"|checksum: "'"${checksum}"'"|' Package.swift
31+
sed -i 's|url: "https://github.com/krzysztofzablocki/Sourcery/releases/download/.*"|url: "'"${BINARY_URL}"'"|' Package.swift
32+
sed -i 's|checksum: ".*"|checksum: "'"${BINARY_CHECKSUM}"'"|' Package.swift
3633
if git diff --quiet; then
3734
echo "No changes detected"
38-
echo "::set-output name=changes_detected::false"
35+
echo "CHANGES_DETECTED=false" >> $GITHUB_ENV
3936
else
4037
echo "Changes detected"
41-
echo "::set-output name=changes_detected::true"
38+
echo "CHANGES_DETECTED=true" >> $GITHUB_ENV
4239
fi
4340
4441
- name: Commit and Push changes
45-
if: steps.update_package_swift.outputs.changes_detected == 'true'
42+
if: env.CHANGES_DETECTED == 'true'
4643
run: |
4744
git config --global user.name 'github-actions[bot]'
4845
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
4946
git add Package.swift
50-
git commit -m "Update Sourcery binary version to ${{ steps.fetch_latest.outputs.latest_release }}"
47+
git commit -m "Update Sourcery binary version to $LATEST_RELEASE"
5148
git push
5249
env:
5350
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)