@@ -26,70 +26,46 @@ jobs:
2626 sudo apt-get update -qq
2727 sudo apt-get install -y curl jq
2828
29- - name : Install Swiftly
30- run : |
31- curl -LO "https://download.swift.org/swiftly/linux/swiftly-$(uname -m).tar.gz"
32- tar -xzf "swiftly-$(uname -m).tar.gz"
33- sudo mv swiftly /usr/local/bin/
34-
35- - name : Get latest Swift version
29+ - name : Update Swift Version
3630 id : latest
3731 run : |
38- latest=$(swiftly ls --available --major-version 5 | grep -vE '-(dev|snapshot)' | head -n1)
39- echo "latest_version=$latest" >> "$GITHUB_OUTPUT"
40-
41- - name : Read current .swift-version
42- id : current
43- run : |
44- current=$(cat .swift-version | tr -d '[:space:]')
45- echo "current_version=$current" >> "$GITHUB_OUTPUT"
46-
47- - name : Compare versions
48- id : compare
49- run : |
50- if [ "${{ steps.latest.outputs.latest_version }}" = "${{ steps.current.outputs.current_version }}" ]; then
51- echo "No update needed."
52- echo "skip=true" >> $GITHUB_OUTPUT
53- else
54- echo "New version available: ${{ steps.latest.outputs.latest_version }}"
55- echo "skip=false" >> $GITHUB_OUTPUT
56- fi
57-
58- - name : Exit if no update needed
59- if : steps.compare.outputs.skip == 'true'
60- run : exit 0
32+ UNAME=$(uname -m)
33+ curl -O "https://download.swift.org/swiftly/linux/swiftly-$UNAME.tar.gz"
34+ tar zxf "swiftly-$UNAME.tar.gz"
35+ latest=$(./swiftly list-available main-snapshot | grep main-snapshot | head -n 1 | awk '{print $1}')
36+ echo -n "$latest" > .swift-version
6137
6238 - name : Create branch
6339 run : |
64- BRANCH=chore /update-swift-version
40+ BRANCH=ci /update-swift-version
6541 git checkout -B "$BRANCH"
66- echo "${{ steps.latest.outputs.latest_version }}" > .swift-version
42+ echo -n "${{ steps.latest.outputs.version }}" > .swift-version
6743 git add .swift-version
68- git commit -m "chore: update Swift version to ${{ steps.latest.outputs.latest_version }}" || echo "No changes to commit"
44+ git commit -m "Update Swift version to ${{ steps.latest.outputs.version }}" || echo "No changes to commit"
6945 git push -u origin "$BRANCH" --force
7046
7147 - name : Check for existing PR
7248 id : find-pr
7349 run : |
7450 gh auth setup-git
75- PR_JSON=$(gh pr list --head chore /update-swift-version --state open --json number --jq '.[0]')
51+ PR_JSON=$(gh pr list --head ci /update-swift-version --state open --json number --jq '.[0]')
7652 echo "pr_number=$PR_JSON" >> $GITHUB_OUTPUT
7753 env :
7854 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
7955
8056 - name : Create or update PR
8157 id : pr
8258 run : |
83- TITLE="chore : update Swift version to ${{ steps.latest.outputs.latest_version }}"
84- BODY="This PR updates the \`.swift-version\` file to Swift ${{ steps.latest.outputs.latest_version }}.
59+ TITLE="ci : update Swift version to ${{ steps.latest.outputs.version }}"
60+ BODY="This PR updates the \`.swift-version\` file to Swift ${{ steps.latest.outputs.version }}.
8561
8662 > This PR was automatically generated."
8763
8864 if [ -z "${{ steps.find-pr.outputs.pr_number }}" ]; then
8965 gh pr create \
9066 --title "$TITLE" \
9167 --body "$BODY" \
92- --head "chore /update-swift-version" \
68+ --head "ci /update-swift-version" \
9369 --base "main"
9470 else
9571 echo "PR already exists: #${{ steps.find-pr.outputs.pr_number }}"
0 commit comments