Skip to content

Commit 65ddb77

Browse files
committed
wip
1 parent 51b2715 commit 65ddb77

File tree

2 files changed

+27
-36
lines changed

2 files changed

+27
-36
lines changed

.github/actions/install-swift/action.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ runs:
1616
- name: Install Swiftly
1717
shell: bash
1818
run: |
19-
UNAME=$(uname -m)
20-
2119
export SWIFTLY_HOME_DIR="$HOME/.local/share/swiftly"
2220
echo "SWIFTLY_HOME_DIR=$SWIFTLY_HOME_DIR" >> $GITHUB_ENV
2321
echo "SWIFTLY_HOME_DIR=$SWIFTLY_HOME_DIR" >> $HOME/.bashrc
@@ -26,6 +24,7 @@ runs:
2624
echo "SWIFTLY_BIN_DIR=$SWIFTLY_BIN_DIR" >> $GITHUB_ENV
2725
echo "SWIFTLY_BIN_DIR=$SWIFTLY_BIN_DIR" >> $HOME/.bashrc
2826
27+
UNAME=$(uname -m)
2928
curl -O "https://download.swift.org/swiftly/linux/swiftly-$UNAME.tar.gz"
3029
tar zxf "swiftly-$UNAME.tar.gz"
3130
./swiftly init \

.github/workflows/update-swift-version.yml

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,74 +16,66 @@ jobs:
1616
- name: Checkout repository
1717
uses: actions/checkout@v4
1818

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]"
2323
2424
- name: Install dependencies
2525
run: |
2626
sudo apt-get update -qq
2727
sudo apt-get install -y curl jq
2828
29-
- name: Update Swift Version
29+
- name: Create or update branch
3030
id: latest
3131
run: |
32-
set -ex
32+
BRANCH=ci/update-swift-version
33+
git checkout -B "$BRANCH"
34+
3335
UNAME=$(uname -m)
3436
curl -O "https://download.swift.org/swiftly/linux/swiftly-$UNAME.tar.gz"
3537
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}')
3746
echo -n "$latest" > .swift-version
38-
git diff .swift-version
3947
if [[ -z "$(git status --porcelain .swift-version)" ]]; then
4048
echo "No changes. Exiting."
4149
exit 78 # neutral exit status
4250
fi
43-
git status
4451
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
5052
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"
5355
54-
- name: Check for existing PR
56+
- name: Create or update PR
5557
id: find-pr
5658
run: |
5759
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]')
6261
63-
- name: Create or update PR
64-
id: pr
65-
run: |
6662
TITLE="ci: update Swift version to ${{ steps.latest.outputs.version }}"
6763
BODY="This PR updates the \`.swift-version\` file to Swift ${{ steps.latest.outputs.version }}.
6864
6965
> This PR was automatically generated."
7066
71-
if [ -z "${{ steps.find-pr.outputs.pr_number }}" ]; then
67+
if [[ -z "$pr_number" ]]; then
7268
gh pr create \
7369
--title "$TITLE" \
7470
--body "$BODY" \
7571
--head "ci/update-swift-version" \
7672
--base "main"
7773
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"
8076
fi
81-
env:
82-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8377
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+
8880
env:
89-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
81+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)