From 2265b38a4675733707026924ae984f9ed26cf724 Mon Sep 17 00:00:00 2001 From: Rauhul Varma Date: Fri, 2 May 2025 11:06:10 -0700 Subject: [PATCH 1/5] wip --- .github/actions/install-swift/action.yml | 3 +- .github/workflows/update-swift-version.yml | 82 ++++++++++++++++++++++ 2 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/update-swift-version.yml diff --git a/.github/actions/install-swift/action.yml b/.github/actions/install-swift/action.yml index 2c88c24..dc7924a 100644 --- a/.github/actions/install-swift/action.yml +++ b/.github/actions/install-swift/action.yml @@ -16,8 +16,6 @@ runs: - name: Install Swiftly shell: bash run: | - UNAME=$(uname -m) - export SWIFTLY_HOME_DIR="$HOME/.local/share/swiftly" echo "SWIFTLY_HOME_DIR=$SWIFTLY_HOME_DIR" >> $GITHUB_ENV echo "SWIFTLY_HOME_DIR=$SWIFTLY_HOME_DIR" >> $HOME/.bashrc @@ -26,6 +24,7 @@ runs: echo "SWIFTLY_BIN_DIR=$SWIFTLY_BIN_DIR" >> $GITHUB_ENV echo "SWIFTLY_BIN_DIR=$SWIFTLY_BIN_DIR" >> $HOME/.bashrc + UNAME=$(uname -m) curl -O "https://download.swift.org/swiftly/linux/swiftly-$UNAME.tar.gz" tar zxf "swiftly-$UNAME.tar.gz" ./swiftly init \ diff --git a/.github/workflows/update-swift-version.yml b/.github/workflows/update-swift-version.yml new file mode 100644 index 0000000..41090e9 --- /dev/null +++ b/.github/workflows/update-swift-version.yml @@ -0,0 +1,82 @@ +name: Update Swift Version + +on: + schedule: + - cron: '0 0 */14 * *' # Every 14 days at midnight UTC + workflow_dispatch: + +jobs: + update-swift-version: + runs-on: ubuntu-latest + + permissions: + contents: write + pull-requests: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Git + run: | + git config --global user.name "github-actions" + git config --global user.email "github-actions@users.noreply.github.com" + + - name: Install dependencies + run: | + sudo apt-get update -qq + sudo apt-get install -y curl jq + + - name: Create or update branch + id: latest + run: | + BRANCH=ci/update-swift-version + git checkout -B "$BRANCH" + + UNAME=$(uname -m) + curl -O "https://download.swift.org/swiftly/linux/swiftly-$UNAME.tar.gz" + tar zxf "swiftly-$UNAME.tar.gz" + ./swiftly init \ + --skip-install \ + --assume-yes \ + --quiet-shell-followup \ + --no-modify-profile + . "$HOME/.local/share/swiftly/env.sh" + + latest=$(swiftly list-available main-snapshot | grep main-snapshot | head -n 1 | awk '{print $1}') + echo -n "$latest" > .swift-version + if [[ -z "$(git status --porcelain .swift-version)" ]]; then + echo "No changes. Exiting." + exit 78 # neutral exit status + fi + + git add .swift-version + git commit -m "Update Swift version to $latest" + git push -u origin "$BRANCH" + + - name: Create or update PR + id: find-pr + run: | + gh auth setup-git + pr_number=$(gh pr list --head ci/update-swift-version --state open --json number --jq '.[0]') + + TITLE="ci: update Swift version to ${{ steps.latest.outputs.version }}" + BODY="This PR updates the \`.swift-version\` file to Swift ${{ steps.latest.outputs.version }}. + + > This PR was automatically generated." + + if [[ -z "$pr_number" ]]; then + gh pr create \ + --title "$TITLE" \ + --body "$BODY" \ + --head "ci/update-swift-version" \ + --base "main" + else + echo "PR already exists: #$pr_number" + gh pr edit $pr_number --title "$TITLE" --body "$BODY" + fi + + gh pr merge $pr_number --auto --squash + + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} From ae915f995f65f765b08b8a4d79575f36f868ddd1 Mon Sep 17 00:00:00 2001 From: Rauhul Varma Date: Fri, 2 May 2025 11:54:58 -0700 Subject: [PATCH 2/5] wip --- .github/workflows/update-swift-version.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/update-swift-version.yml b/.github/workflows/update-swift-version.yml index 41090e9..ffbedae 100644 --- a/.github/workflows/update-swift-version.yml +++ b/.github/workflows/update-swift-version.yml @@ -1,6 +1,10 @@ name: Update Swift Version on: + push: + branches: ["main"] + pull_request: + branches: ["main"] schedule: - cron: '0 0 */14 * *' # Every 14 days at midnight UTC workflow_dispatch: From 33ed1776ca2d50991e7016bfe17682e1f38340a1 Mon Sep 17 00:00:00 2001 From: github-actions Date: Fri, 2 May 2025 18:55:41 +0000 Subject: [PATCH 3/5] Update Swift version to main-snapshot-2025-04-30 --- .swift-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.swift-version b/.swift-version index 79c018b..1ce3e67 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -main-snapshot-2025-04-12 +main-snapshot-2025-04-30 \ No newline at end of file From d28ff6766ebb5f2b6dbc43d609dd3de6f0cbe51b Mon Sep 17 00:00:00 2001 From: Rauhul Varma Date: Fri, 2 May 2025 11:57:41 -0700 Subject: [PATCH 4/5] polute swift-version --- .swift-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.swift-version b/.swift-version index 1ce3e67..ef88086 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -main-snapshot-2025-04-30 \ No newline at end of file +main-snapshot-2025-04-asdla \ No newline at end of file From d9b8dc1c6fa96e16f36ece3160d99af70fb80e34 Mon Sep 17 00:00:00 2001 From: github-actions Date: Fri, 2 May 2025 19:08:35 +0000 Subject: [PATCH 5/5] Update Swift version to main-snapshot-2025-04-30 --- .swift-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.swift-version b/.swift-version index ef88086..1ce3e67 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -main-snapshot-2025-04-asdla \ No newline at end of file +main-snapshot-2025-04-30 \ No newline at end of file