@@ -16,74 +16,66 @@ jobs:
16
16
- name : Checkout repository
17
17
uses : actions/checkout@v4
18
18
19
- # - name: Set up Git
20
- # run: |
21
- # git config --global user.name "github-actions"
22
- # git config --global user.email "[email protected] "
19
+ - name : Set up Git
20
+ run : |
21
+ git config --global user.name "github-actions"
22
+ git config --global user.email "[email protected] "
23
23
24
24
- name : Install dependencies
25
25
run : |
26
26
sudo apt-get update -qq
27
27
sudo apt-get install -y curl jq
28
28
29
- - name : Update Swift Version
29
+ - name : Create or update branch
30
30
id : latest
31
31
run : |
32
- set -ex
32
+ BRANCH=ci/update-swift-version
33
+ git checkout -B "$BRANCH"
34
+
33
35
UNAME=$(uname -m)
34
36
curl -O "https://download.swift.org/swiftly/linux/swiftly-$UNAME.tar.gz"
35
37
tar zxf "swiftly-$UNAME.tar.gz"
36
- latest=$(./swiftly list-available main-snapshot | grep main-snapshot | head -n 1 | awk '{print $1}')
38
+ ./swiftly init \
39
+ --skip-install \
40
+ --assume-yes \
41
+ --quiet-shell-followup \
42
+ --no-modify-profile
43
+ . "$HOME/.local/share/swiftly/env.sh"
44
+
45
+ latest=$(swiftly list-available main-snapshot | grep main-snapshot | head -n 1 | awk '{print $1}')
37
46
echo -n "$latest" > .swift-version
38
- git diff .swift-version
39
47
if [[ -z "$(git status --porcelain .swift-version)" ]]; then
40
48
echo "No changes. Exiting."
41
49
exit 78 # neutral exit status
42
50
fi
43
- git status
44
51
45
- - name : Create branch
46
- run : |
47
- BRANCH=ci/update-swift-version
48
- git checkout -B "$BRANCH"
49
- echo -n "${{ steps.latest.outputs.version }}" > .swift-version
50
52
git add .swift-version
51
- git commit -m "Update Swift version to ${{ steps. latest.outputs.version }}" || echo "No changes to commit "
52
- git push -u origin "$BRANCH" --force
53
+ git commit -m "Update Swift version to $latest"
54
+ git push -u origin "$BRANCH"
53
55
54
- - name : Check for existing PR
56
+ - name : Create or update PR
55
57
id : find-pr
56
58
run : |
57
59
gh auth setup-git
58
- PR_JSON=$(gh pr list --head ci/update-swift-version --state open --json number --jq '.[0]')
59
- echo "pr_number=$PR_JSON" >> $GITHUB_OUTPUT
60
- env :
61
- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
60
+ pr_number=$(gh pr list --head ci/update-swift-version --state open --json number --jq '.[0]')
62
61
63
- - name : Create or update PR
64
- id : pr
65
- run : |
66
62
TITLE="ci: update Swift version to ${{ steps.latest.outputs.version }}"
67
63
BODY="This PR updates the \`.swift-version\` file to Swift ${{ steps.latest.outputs.version }}.
68
64
69
65
> This PR was automatically generated."
70
66
71
- if [ -z "${{ steps.find-pr.outputs. pr_number }}" ]; then
67
+ if [[ -z "$pr_number" ] ]; then
72
68
gh pr create \
73
69
--title "$TITLE" \
74
70
--body "$BODY" \
75
71
--head "ci/update-swift-version" \
76
72
--base "main"
77
73
else
78
- echo "PR already exists: #${{ steps.find-pr.outputs. pr_number }} "
79
- gh pr edit ${{ steps.find-pr.outputs. pr_number }} --title "$TITLE" --body "$BODY"
74
+ echo "PR already exists: #$pr_number"
75
+ gh pr edit $pr_number --title "$TITLE" --body "$BODY"
80
76
fi
81
- env :
82
- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
83
77
84
- - name : Enable auto-merge
85
- if : steps.find-pr.outputs.pr_number != ''
86
- run : |
87
- gh pr merge ${{ steps.find-pr.outputs.pr_number }} --auto --squash
78
+ gh pr merge $pr_number --auto --squash
79
+
88
80
env :
89
- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
81
+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments