|
| 1 | +name: Update Stable rustc |
| 2 | +on: |
| 3 | + schedule: |
| 4 | + - cron: "0 0 * * 5" # runs every Friday at 00:00 (generally rust releases on Thursday) |
| 5 | + workflow_dispatch: # allows manual triggering |
| 6 | +jobs: |
| 7 | + format: |
| 8 | + name: Update stable rustc |
| 9 | + runs-on: ubuntu-latest |
| 10 | + steps: |
| 11 | + - uses: actions/checkout@v4 |
| 12 | + - uses: dtolnay/rust-toolchain@stable |
| 13 | + - name: Update semver-checks.yml to use latest stable |
| 14 | + run: | |
| 15 | + set -x |
| 16 | + # Extract the version of the compiler dtolnay/rust-toolchain gives us. |
| 17 | + STABLE_VERSION=$(rustc --version | sed -ne 's/^rustc //p' | cut -d ' ' -f1) |
| 18 | + # Update the stable version in the reference file. |
| 19 | + echo "${STABLE_VERSION}" > ./.github/workflows/stable-version |
| 20 | + echo "stable_version=${STABLE_VERSION}" >> $GITHUB_ENV |
| 21 | + # If somehow the stable version has not changed. In this case don't make an empty PR. |
| 22 | + if ! git diff --exit-code > /dev/null; then |
| 23 | + echo "Updated stable. Opening PR." |
| 24 | + echo "changes_made=true" >> $GITHUB_ENV |
| 25 | + else |
| 26 | + echo "Attempted to update stable but the latest-stable date did not change. Not opening any PR." |
| 27 | + echo "changes_made=false" >> $GITHUB_ENV |
| 28 | + fi |
| 29 | + - name: Create Pull Request |
| 30 | + if: env.changes_made == 'true' |
| 31 | + uses: peter-evans/create-pull-request@v6 |
| 32 | + with: |
| 33 | + token: ${{ secrets.APOELSTRA_CREATE_PR_TOKEN }} |
| 34 | + author: Update Stable Rustc Bot <bot@example.com> |
| 35 | + committer: Update Stable Rustc Bot <bot@example.com> |
| 36 | + title: Automated weekly update to rustc stable (to ${{ env.stable_version }}) |
| 37 | + body: | |
| 38 | + Automated update to Github CI workflow `semver-checks.yml` by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action |
| 39 | + commit-message: Automated update to Github CI to rustc stable-${{ env.stable_version }} |
| 40 | + branch: create-pull-request/weekly-stable-update |
0 commit comments