Skip to content

Commit 4edd504

Browse files
author
Jose Storopoli
committed
ci: pin stable in semver-checks and updates weekly
1 parent 1948995 commit 4edd504

3 files changed

Lines changed: 48 additions & 1 deletion

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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

.github/workflows/semver-checks.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ name: Check semver breaks
55

66
jobs:
77
PR:
8-
name: PR Semver - nightly toolchain
8+
name: PR Semver - stable toolchain
99
runs-on: ubuntu-latest
1010
strategy:
1111
fail-fast: false
@@ -16,6 +16,9 @@ jobs:
1616
fetch-depth: 0 # we need full history for cargo semver-checks
1717
- name: "Install Rustup"
1818
uses: dtolnay/rust-toolchain@stable
19+
- name: "Select stable-version"
20+
run: |
21+
rustup default $(cat ./.github/workflows/stable-version)
1922
- name: "Install cargo-binstall"
2023
uses: cargo-bins/cargo-binstall@main
2124
- name: "Binstall cargo-semver-checks"
@@ -50,6 +53,9 @@ jobs:
5053
uses: actions/checkout@v4
5154
- name: "Install Rustup"
5255
uses: dtolnay/rust-toolchain@stable
56+
- name: "Select stable-version"
57+
run: |
58+
rustup default $(cat ./.github/workflows/stable-version)
5359
- name: "Install cargo-binstall"
5460
uses: cargo-bins/cargo-binstall@main
5561
- name: "Binstall cargo-semver-checks"

.github/workflows/stable-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.79.0

0 commit comments

Comments
 (0)