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/build-esp.yml b/.github/workflows/build-esp.yml index 06fa1eb..4a7c53b 100644 --- a/.github/workflows/build-esp.yml +++ b/.github/workflows/build-esp.yml @@ -4,9 +4,7 @@ on: push: branches: ["main"] pull_request: - types: [opened, reopened, synchronize] - repository_dispatch: - types: [create-pull-request] + types: [opened, reopened, synchronize, ready_for_review] jobs: build-esp: diff --git a/.github/workflows/build-nuttx.yml b/.github/workflows/build-nuttx.yml index b70a1ba..696a008 100644 --- a/.github/workflows/build-nuttx.yml +++ b/.github/workflows/build-nuttx.yml @@ -4,9 +4,7 @@ on: push: branches: ["main"] pull_request: - types: [opened, reopened, synchronize] - repository_dispatch: - types: [create-pull-request] + types: [opened, reopened, synchronize, ready_for_review] jobs: build-nuttx: diff --git a/.github/workflows/build-pico-sdk.yml b/.github/workflows/build-pico-sdk.yml index 80d4955..b065920 100644 --- a/.github/workflows/build-pico-sdk.yml +++ b/.github/workflows/build-pico-sdk.yml @@ -4,9 +4,7 @@ on: push: branches: ["main"] pull_request: - types: [opened, reopened, synchronize] - repository_dispatch: - types: [create-pull-request] + types: [opened, reopened, synchronize, ready_for_review] jobs: build-pico-sdk: diff --git a/.github/workflows/build-rpi-baremetal.yml b/.github/workflows/build-rpi-baremetal.yml index 6b8cf93..08882d1 100644 --- a/.github/workflows/build-rpi-baremetal.yml +++ b/.github/workflows/build-rpi-baremetal.yml @@ -4,9 +4,7 @@ on: push: branches: ["main"] pull_request: - types: [opened, reopened, synchronize] - repository_dispatch: - types: [create-pull-request] + types: [opened, reopened, synchronize, ready_for_review] jobs: build-rpi-baremetal: diff --git a/.github/workflows/build-stm.yml b/.github/workflows/build-stm.yml index 5723b9a..90128ed 100644 --- a/.github/workflows/build-stm.yml +++ b/.github/workflows/build-stm.yml @@ -4,9 +4,7 @@ on: push: branches: ["main"] pull_request: - types: [opened, reopened, synchronize] - repository_dispatch: - types: [create-pull-request] + types: [opened, reopened, synchronize, ready_for_review] jobs: build-stm32: diff --git a/.github/workflows/build-zephyr.yml b/.github/workflows/build-zephyr.yml index 6344ec5..76ff817 100644 --- a/.github/workflows/build-zephyr.yml +++ b/.github/workflows/build-zephyr.yml @@ -4,9 +4,7 @@ on: push: branches: ["main"] pull_request: - types: [opened, reopened, synchronize] - repository_dispatch: - types: [create-pull-request] + types: [opened, reopened, synchronize, ready_for_review] jobs: build-zephyr: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 0687bc7..24faee0 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -4,9 +4,7 @@ on: push: branches: ["main"] pull_request: - types: [opened, reopened, synchronize] - repository_dispatch: - types: [create-pull-request] + types: [opened, reopened, synchronize, ready_for_review] jobs: validate_format_config: diff --git a/.github/workflows/update-swift-version.yml b/.github/workflows/update-swift-version.yml new file mode 100644 index 0000000..80e7aa9 --- /dev/null +++ b/.github/workflows/update-swift-version.yml @@ -0,0 +1,87 @@ +name: Update Swift Version + +on: + pull_request: + types: [opened, reopened, synchronize] + schedule: + - cron: '0 0 */14 * *' # Every 14 days at midnight UTC + workflow_dispatch: + +jobs: + update-swift-version: + name: Create or update PR + 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: Open pull request if needed + id: update + run: | + set -ex + + git fetch + branch=ci/update-swift-version + if git ls-remote --exit-code --heads origin "$branch"; then + git checkout -b "$branch" --track "origin/$branch" + else + git checkout -b "$branch" + fi + + 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" + + swift_version=".swift-version" + latest=$(swiftly list-available main-snapshot | grep main-snapshot | head -n 1 | awk '{print $1}') + echo -n "$latest" > "$swift_version" + echo "version=$latest" >> "$GITHUB_OUTPUT" + + title="Update to $latest" + body="Updates the \`.swift-version\` file to Swift \`$latest\`. + + > This PR was automatically generated." + + if [[ -n "$(git status --porcelain "$swift_version")" ]]; then + git add "$swift_version" + git commit -m "$title" -m "$body" + git push -u origin "$branch" + fi + + pr=$(gh pr list --head "$branch" --state open --json number --jq '.[0].number') + if [[ -z "$pr" ]]; then + gh pr create \ + --title "$title" \ + --body "$body" \ + --head "$branch" \ + --base "main" \ + --draft + else + gh pr edit \ + --title "$title" \ + --body "$body" + fi + + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}