|
| 1 | +name: Update Rust Toolchain Nightly for all Rust apps |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: # Allows manual trigger |
| 5 | + |
| 6 | +env: |
| 7 | + NIGHTLY: 'nightly-2026-01-01' # Set desired nightly version here |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: write # Required to push the new branch |
| 11 | + pull-requests: write # Required to create the PR |
| 12 | + |
| 13 | +jobs: |
| 14 | + # retrieve-rust-apps: |
| 15 | + # name: Retrieve Rust Apps |
| 16 | + # runs-on: ubuntu-latest |
| 17 | + # outputs: |
| 18 | + # rust_apps: ${{ steps.get_rust_apps.outputs.rust_apps }} |
| 19 | + # steps: |
| 20 | + # - name: Checkout repository |
| 21 | + # uses: actions/checkout@v4 |
| 22 | + # with: |
| 23 | + # repository: LedgerHQ/ledger-device-rust-sdk |
| 24 | + # ref: 'master' |
| 25 | + # - name: Set up Python |
| 26 | + # uses: actions/setup-python@v4 |
| 27 | + # with: |
| 28 | + # python-version: '3.x' |
| 29 | + # - name: Install ledgered |
| 30 | + # run: pip install ledgered |
| 31 | + # - name: Get all rust apps |
| 32 | + # id: get_rust_apps |
| 33 | + # run: | |
| 34 | + # python .github/workflows/get_rust_apps_repositories.py ${{ secrets.GITHUB_TOKEN }} |
| 35 | + # echo "rust_apps=$(cat rust_apps.json)" >> $GITHUB_OUTPUT |
| 36 | + update-toolchain: |
| 37 | + name: Create Update Rust Nightly Toolchain PR |
| 38 | + #needs: retrieve-rust-apps |
| 39 | + runs-on: ubuntu-latest |
| 40 | + strategy: |
| 41 | + fail-fast: false |
| 42 | + matrix: |
| 43 | + app-name: ["app-boilerplate-rust"] |
| 44 | + #include: ${{ fromJSON(needs.retrieve-rust-apps.outputs.rust_apps) }} |
| 45 | + steps: |
| 46 | + - name: Checkout Repository |
| 47 | + uses: actions/checkout@v4 |
| 48 | + with: |
| 49 | + fetch-depth: 0 # Fetch all history for branching |
| 50 | + repository: LedgerHQ/${{ matrix.app-name }} |
| 51 | + submodules: true |
| 52 | + path: ${{ matrix.app-name }} |
| 53 | + |
| 54 | + - name: Create Branch |
| 55 | + run: | |
| 56 | + cd ${{ matrix.app-name }} |
| 57 | + git checkout -b update_nightly |
| 58 | +
|
| 59 | + - name: Modify rust-toolchain.toml |
| 60 | + run: | |
| 61 | + # Using sed for simple text replacement in CI |
| 62 | + # This replaces the line starting with channel = "..." with the new version |
| 63 | + # You can adjust the logic to dynamically fetch the date command: $(date +%Y-%m-%d) |
| 64 | + sed -i 's/channel = ".*"/channel = "${{ env.NIGHTLY }}"/' rust-toolchain.toml |
| 65 | + |
| 66 | + # Print for verification logs |
| 67 | + cat rust-toolchain.toml |
| 68 | +
|
| 69 | + - name: Commit and Push |
| 70 | + id: commit_and_push |
| 71 | + working-directory: ${{ matrix.app-name }} |
| 72 | + run: | |
| 73 | + # Check if there are changes before committing |
| 74 | + if [[ -n $(git status -s) ]]; then |
| 75 | + git add rust-toolchain.toml |
| 76 | + git commit -m "Update rust-toolchain to latest nightly" |
| 77 | + git push origin update_nightly --force |
| 78 | + echo "changes_pushed=true" >> $GITHUB_OUTPUT |
| 79 | + else |
| 80 | + echo "No changes detected." |
| 81 | + echo "changes_pushed=false" >> $GITHUB_OUTPUT |
| 82 | + fi |
| 83 | + |
| 84 | + - name: Create Pull Request |
| 85 | + if: steps.commit_and_push.outputs.changes_pushed == 'true' |
| 86 | + env: |
| 87 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 88 | + run: | |
| 89 | + # Create PR using GitHub CLI |
| 90 | + # The '|| true' prevents failure if a PR already exists |
| 91 | + gh pr create \ |
| 92 | + --title "Update Rust Toolchain to Nightly" \ |
| 93 | + --body "Automated PR to update the rust-toolchain.toml file to the latest nightly version." \ |
| 94 | + --base main \ |
| 95 | + --head update_nightly \ |
| 96 | + --reviewer "${{ github.actor }}" || echo "PR might already exist" |
0 commit comments